This is a test version of Biostars. For the public version, visit https://www.biostars.org.
SNP and Genes position matching dataframes in R

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

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.

0 answers

No answers yet.

Log in to answer this question.