Entering edit mode
Jonathan Ellis
▴
30
@jonathan-ellis-6561
Last seen 10.1 years ago
Dear list,
I have a GRanges object that contains some ranges that are completely
contained within larger ranges as well as ranges that overlap. I know
I
can use reduce to merge overlapping ranges and remove the smaller,
completely contained, ranges. However, I would like to only remove
ranges that are completely within a larger range and leave overlapping
ranges intact. For example,
> g <- GRanges(seqnames = Rle('chr1', 3),
ranges = IRanges(start = c(1, 3, 8), end = c(10, 7, 15)))
> reduce(g)
GRanges with 1 range and 0 metadata columns:
seqnames ranges strand
<rle> <iranges> <rle>
[1] chr1 [1, 15] *
---
seqlengths:
chr1
NA
I would like to to get the following GRanges:
GRanges with 1 range and 0 metadata columns:
seqnames ranges strand
<rle> <iranges> <rle>
[1] chr1 [1, 10] *
[2] chr1 [8, 15] *
---
seqlengths:
chr1
NA
Does anyone know if there's an easy way to do this with GRanges?
Thanks,
Jonathan