Entering edit mode
Fahim Md
▴
250
@fahim-md-4018
Last seen 10.4 years ago
Hi
findOverlap function depends on the 'strand'edness of the subject and
query. In the example below, I am using findOverlap function to find
overlapping ranges. Is there a way to completely ignore this feature
and
report all overlaps.
grSubject <-
GRanges(
seqnames =Rle(rep("chr1", 7)),
ranges = IRanges(c(1,5,15,22,5,15,22),c(11,8,20,30,8,17,25)),
strand = Rle(strand(c("-", rep("+",6)))),
name = c('a', 'b','b','b','c','c','c')
)
> grSubject
GRanges with 7 ranges and 1 elementMetadata value:
seqnames ranges strand | name
<rle> <iranges> <rle> | <character>
[1] chr1 [ 1, 11] - | a
[2] chr1 [ 5, 8] + | b
[3] chr1 [15, 20] + | b
[4] chr1 [22, 30] + | b
[5] chr1 [ 5, 8] + | c
[6] chr1 [15, 17] + | c
[7] chr1 [22, 25] + | c
---
seqlengths:
chr1
NA
grQuery <-
GRanges(
seqnames =Rle(rep("chr1", 3)),
ranges = IRanges(c(6,14,22),c(10,16,27)),
strand = Rle(strand(rep("-",3))),
name = c('x', 'y','z')
)
> grQuery
GRanges with 3 ranges and 1 elementMetadata value:
seqnames ranges strand | name
<rle> <iranges> <rle> | <character>
[1] chr1 [ 6, 10] - | x
[2] chr1 [14, 16] - | y
[3] chr1 [22, 27] - | z
---
seqlengths:
chr1
NA
as.matrix(findOverlaps(grQuery, grSubject))
query subject
[1,] 1 1
When I change the strand of the query like this:
grQuery <-
GRanges(
seqnames =Rle(rep("chr1", 3)),
ranges = IRanges(c(6,14,22),c(10,16,27)),
strand = Rle(strand(c("-", rep("+",2)))),
name = c('x', 'y','z')
)
I get
> as.matrix(findOverlaps(grQuery, grSubject))
query subject
[1,] 1 1
[2,] 2 3
[3,] 2 6
[4,] 3 4
[5,] 3 7
>
Thanks
Fahim
[[alternative HTML version deleted]]