look for SNPs that span segments with R
1
1
Entering edit mode
9.5 years ago
l0ka ▴ 10

I have a file with SNPs positions and IDs:

chr    pos       dbsnp
1      909419    rs28548431
1      1120307   rs7539911

And another file with segments:

chr    start    end         logR
1      62908    8165619     0.0518
1      8165719  10573304    -0.0406

I have to look for SNPs positions (in table 1) that span within each segment (given by start and end in table 2) and I should use R code.

Any suggestion?

SNP R • 2.1k views
ADD COMMENT
1
Entering edit mode
9.5 years ago

Create GRanges objects of each and then use findOverlaps or %over%.

library(GenomicRanges)
snpDat = read.delim('SNPFILENAME')
regionDat = read.delim("REGIONFILENAME")
snpGR = GRanges(seqnames=snpDat[,1],ranges=IRanges(start=snpDat[,2],end=snpDat[,2]))
regionGR = GRanges(seqnames=regionDat[,1],ranges=IRanges(start=regionDat[,2],end=regionDat[,3]))
snpOverlapGR = snpGR[snpGR %over% regionGR]

Untested, but that should be close.

ADD COMMENT

Login before adding your answer.

Traffic: 1780 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