Skip to content

Bug in unique #88

@gevro

Description

@gevro

Hi,
There is a bug in the unique function on granges. First reported here:
https://www.biostars.org/p/386553/



Just be aware that unique() will ignore the data in the GRanges mcols

a_gr <- GRanges(seqnames = 1,
            ranges = IRanges(start=c(1,1),
                             end =c(2,2)), 
            strand=c("+"),
            other=c("a","b"))
a_gr
#GRanges object with 2 ranges and 1 metadata column:
#  seqnames    ranges strand |       other
#   <Rle> <IRanges>  <Rle> | <character>
#[1]        1       1-2      + |           a
#[2]        1       1-2      + |           b

unique(a_gr)
#GRanges object with 1 range and 1 metadata column:
#seqnames    ranges strand |       other
#   <Rle> <IRanges>  <Rle> | <character>
#[1]        1       1-2      + |           a

unique should either: 1) take into account all mcols, or 2) the result should not have any mcols.

Returning a result with mcols when the function does not take it into account is misleading and could lead to undetectable bugs.

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