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]]

