SNP and Genes position matching dataframes in R
0
0
Entering edit mode
8 months ago
QX ▴ 60

Hi all,

I have 2 datasets that look like this:

data1:

enter image description here

data2

enter image description here

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?

R dataframe • 292 views
ADD COMMENT
0
Entering edit mode

There are many ways you can do this. Base R you can use subset, with the library data.table you can use the foverlaps functions, and there are also implementations in the granges 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.

ADD REPLY

Login before adding your answer.

Traffic: 996 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6