Keep unique ranges by 'chopping' mcols
chopMC(x, simplify = TRUE)
A GRanges object
This function finds unique ranges and chops all mcols in a manner similar
to chop.
Chopped columns will be returned as CompressedList
columns, unless
simplify = TRUE
(the default).
In this case, columns will be returned as vectors where possible.
gr <- GRanges(rep(c("chr1:1-10"), 2))
gr$id <- paste0("range", seq_along(gr))
gr$gene <- "gene1"
gr
#> GRanges object with 2 ranges and 2 metadata columns:
#> seqnames ranges strand | id gene
#> <Rle> <IRanges> <Rle> | <character> <character>
#> [1] chr1 1-10 * | range1 gene1
#> [2] chr1 1-10 * | range2 gene1
#> -------
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
chopMC(gr)
#> GRanges object with 1 range and 2 metadata columns:
#> seqnames ranges strand | id gene
#> <Rle> <IRanges> <Rle> | <CharacterList> <character>
#> [1] chr1 1-10 * | range1,range2 gene1
#> -------
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths