findOverlaps - how to get adjacent ranges?
1
0
Entering edit mode
@tobiaskockmann-11966
Last seen 5.0 years ago

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

findOverlaps IRanges • 777 views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 5 months ago
United States

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)

 

ADD COMMENT

Login before adding your answer.

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