Question: findOverlaps - how to get adjacent ranges?
0
2.6 years ago by
tobias.kockmann20 wrote:

Hi there,

I am trying to locate a function that finds pairs of adjacent ranges - ranges where the end of range A is exactly start-1 of range B. Example with 3 ranges:

AAAAABBBBBCCCCC

pair 1 AAAAA BBBBB

pair 2 BBBBB CCCCC

I thought that would be possible using findOverlaps() or findOverlapPairs() in the IRanges package, but the type argument only lets me select

type=c("any", "start", "end", "within", "equal")

so I can either compare the start pos., the end or both,  but I cannot find a way to compare start vs. end.

Is there really no way to do this with the current functions?

Greetings,

Tobi

iranges findoverlaps • 564 views
modified 2.6 years ago by Michael Lawrence11k • written 2.6 years ago by tobias.kockmann20
0
2.6 years ago by
United States
Michael Lawrence11k wrote:

There's always the option of finding all overlaps, and then filtering them. By setting maxgap=1L, adjacent ranges will be considered overlapping. Then, just filter the result for those that are adjacent:

p <- findOverlapPairs(a, b, maxgap=1L)
subset(p, start(first) == end(second) + 1L | end(first) == start(second) - 1L)

Content
Help
Access

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