GenomicRanges: removing contained ranges without merging overlapping ranges
1
0
Entering edit mode
@jonathan-ellis-6561
Last seen 9.6 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
• 5.8k views
ADD COMMENT
1
Entering edit mode
@michael-lawrence-3846
Last seen 2.4 years ago
United States
Like this: g[is.na(findOverlaps(g, type="within", ignoreSelf=TRUE, select="arbitrary"))] With devel IRanges, this is also possible: g[!overlapsAny(g, type="within", ignoreSelf=TRUE)] Michael On Fri, Jun 6, 2014 at 12:18 AM, Jonathan Ellis < Jonathan.Ellis@qimrberghofer.edu.au> wrote: > 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 > > _______________________________________________ > Bioconductor mailing list > Bioconductor@r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

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