Entering edit mode
7 months ago
QX
▴
60
Hi all,
I have 2 datasets that look like this:
data1:
data2
Now I want to loop BP columns in data1, if it fall into the range of start - end in data 2, then assign the gene_name in data 2 to data 1 gene_id.
Can anyone suggest me the code or approach to perform this?
There are many ways you can do this. Base R you can use
subset
, with the librarydata.table
you can use thefoverlaps
functions, and there are also implementations in thegranges
library too, among many others. Logically, this loop or vectorised function would be relatively simple, so have a go and if you can't solve it post what you've tried and we can help more.As an aside, please don't put screenshots of data, instead paste data in markdown or provide useable snippets of code to replicate your data.