[BioC] GRanges setdiff With Features on Both Strands

Dario Strbenac D.Strbenac at garvan.org.au
Mon Jan 16 07:00:05 CET 2012


Hi,

setdiff doesn't work the way I thought it would when one GRanges has strands and the other does not. I thought that features stranded as * would be taken as being on both strands. The output is even stranger if I use ignore.strand = TRUE.

> x
GRanges with 1 range and 0 elementMetadata values:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1    [2, 7]      +
  ---
  seqlengths:
   chr1
     NA
> y
GRanges with 1 range and 0 elementMetadata values:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1   [5, 10]      *
  ---
  seqlengths:
   chr1
     NA
> setdiff(x, y)
GRanges with 1 range and 0 elementMetadata values:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1    [2, 7]      +
  ---
  seqlengths:
   chr1
     NA
> setdiff(x, y, ignore.strand = TRUE)
GRanges with 2 ranges and 0 elementMetadata values:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1   [1, 10]      -
  [2]     chr1   [1, 10]      *
  ---
  seqlengths:
   chr1
     NA

How do I get a result of chr1 [2, 4] + ?

R version 2.14.0 (2011-10-31), GenomicRanges_1.6.4, IRanges_1.12.5

--------------------------------------
Dario Strbenac
Research Assistant
Cancer Epigenetics
Garvan Institute of Medical Research
Darlinghurst NSW 2010
Australia



More information about the Bioconductor mailing list