Bioconductor / GenomicRanges

Representation and manipulation of genomic intervals
https://bioconductor.org/packages/GenomicRanges
43 stars 18 forks source link

setdiff not behaving as expected #67

Open gevro opened 2 years ago

gevro commented 2 years ago

Hi, For some reason the below setdiff is not filtering out the element in x, even though it is encompassed by y.

x:

> mutations.gr[[1]][2]
GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1  15003249      +
  -------
  seqinfo: 23 sequences from an unspecified genome; no seqlengths

y:

> genes[266]
GRanges object with 1 range and 0 metadata columns:
      seqnames            ranges strand
         <Rle>         <IRanges>  <Rle>
  [1]     chr1 14971680-15048506      *
  -------
  seqinfo: 24 sequences from an unspecified genome; no seqlengths
> setdiff(mutations.gr[[1]][2],genes[266])
GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1  15003249      +
  -------
  seqinfo: 24 sequences from an unspecified genome; no seqlengths

=> The result should be an empty GRanges.

But adding ignore.strand=TRUE works:

> setdiff(mutations.gr[[1]][2],genes[266],ignore.strand=TRUE)
GRanges object with 0 ranges and 0 metadata columns:
   seqnames    ranges strand
      <Rle> <IRanges>  <Rle>
  -------
  seqinfo: 24 sequences from an unspecified genome; no seqlengths

Shouldn't setdiff of a range with strand = + that is encompassed by a range with strand = * be considered an overlap and removed by setdiff?