I am trying to find the intersection of two GRanges objects. The first object has the coordinates for genes (grgenes below), the second mimics my data (grtest below). However, when I try to do the intersection, I appear to get an empty set. What am I doing wrong? (Sorry for the bad formatting! Can I turn the 'auto-format' off??)
grgenes
GRanges object with 23056 ranges and 1 metadata column:
seqnames ranges strand | GENEID
<Rle> <IRanges> <Rle> | <FactorList>
1 chr19 [ 58858172, 58874214] - | 1
10 chr8 [ 18248755, 18258723] + | 10
100 chr20 [ 43248163, 43280376] - | 100
seqinfo: 93 sequences (1 circular) from hg19 genome
grtest <- GRanges(seqnames = "chr19",ranges=IRanges(start=c(58857500,58857505),width=1))
grtest
GRanges object with 2 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
[1] chr19 [58857500, 58857500] *
[2] chr19 [58857505, 58857505] *
seqinfo: 1 sequence from an unspecified genome; no seqlengths
intersect(grgenes,grtest)
GRanges object with 0 ranges and 0 metadata columns:
seqnames ranges strand <rle> <iranges> <rle>
seqinfo: 93 sequences (1 circular) from hg19 genome
Unfortunately, that won't be possible in
GenomicRanges::intersect
, since the metadata for a supersequence doesn't necessarily correspond to a subsequence. You can however, usefindOverlaps
to identify rows within yourgrgenes
object that are overlapped by at least one entry of grtest, and then extract those rows. Look at the documentation