I am trying to classify genomic locations, and I have DataFrame like the following, with all locations and their respective classification types. The Type column does not have unique classifications, but each row will have a unique combination of Chr, Low, High.
pd.DataFrame({
'Chr':[1,1,3],
'Low':[100,200,300],
'High':[150,250,350],
'Type':['Foo','Bar','Foo']
})
I then have my sample set that needs to be classified like the DataFrame below.
pd.DataFrame({
'Chr':[1,1,5],
'Loc':[125,325,325]
})
To classify the data, for each location in the sample set, the Chromosome position found within the Chr column must match a Chr value found within the reference DataFrame and the Loc value must be >= the Low value and <= the High value. If this happens, that row should then be labeled with the respective Type in the reference DataFrame. In the example I provide, the sample set should be labeled like the following.
pd.DataFrame({
'Chr':[1,1,5],
'Loc':[125,325,325],
'Type':['Foo','None','None']
})
which looks like:
Chr Loc Type
0 1 125 Foo
1 1 325 None
2 5 325 None
