Skip to content

Strange setdiff behavior - identified bug #95

Description

@gevro

Hi,
I'm seeing strange behavior in setdiff. GenomicRanges v1.58.0

Two GRangesLists, examine list element 16384 in each of them:

> x_list %>% class
[1] "CompressedGRangesList"
attr(,"package")
[1] "GenomicRanges"
> rem_list %>% class
[1] "CompressedGRangesList"
attr(,"package")
[1] "GenomicRanges"

> x_list[[16384]]
GRanges object with 1 range and 2 metadata columns:
      seqnames            ranges strand |
         <Rle>         <IRanges>  <Rle> |
  [1]     chr4 85143672-85143727      + |
                                          run_id        zm
                                        <factor> <integer>
  [1] Lib1 233832556
  -------
  seqinfo: 195 sequences (1 circular) from hg38 genome

> rem_list[[16384]]
GRanges object with 1 range and 3 metadata columns:
      seqnames            ranges strand |
         <Rle>         <IRanges>  <Rle> |
  [1]     chr4 85143672-85143727      + |
                                          run_id        zm       hit
                                        <factor> <integer> <logical>
  [1] Lib1 233832556      TRUE
  -------
  seqinfo: 195 sequences (1 circular) from hg38 genome

setdiff between the two GRangesLists, and examine list element 16384 in the result:

> out_list <- GenomicRanges::setdiff(x_list, rem_list, ignore.strand = TRUE)

> out_list[[16384]]
GRanges object with 1 range and 0 metadata columns:
      seqnames            ranges strand
         <Rle>         <IRanges>  <Rle>
  [1]     chr4 85143672-85143727      *
  -------
  seqinfo: 195 sequences (1 circular) from hg38 genome

The result in out_list[[16384]] should be empty.

Confirmation that seqnames were encoded identically:

> as.integer(seqnames(x_list[[16384]]))
[1] 4
> as.integer(seqnames(rem_list[[16384]]))
[1] 4

Direct setdiff between the individual elements works correctly:

> GenomicRanges::setdiff(x_list[[16384]], rem_list[[16384]], ignore.strand = TRUE)
GRanges object with 0 ranges and 0 metadata columns:
   seqnames    ranges strand
      <Rle> <IRanges>  <Rle>
  -------
  seqinfo: 195 sequences (1 circular) from hg38_SMaHT genome

There might be something fundamental I'm not understanding about setdiff. Or perhaps this is some weird bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions