R/GenomicRangesList-class.R

Defines functions GenomicRangesList

Documented in GenomicRangesList

### =========================================================================
### GenomicRangesList objects
### -------------------------------------------------------------------------
###
### A List of GenomicRanges objects. Subclasses not necessarily have the same
### "compound" semantics as GRangesList.
###

setClass("GenomicRangesList",
         prototype = prototype(elementType = "GenomicRanges"),
         contains = "List")

setClass("SimpleGenomicRangesList",
         contains = c("GenomicRangesList", "SimpleList"))

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Constructor.
###

GenomicRangesList <- function(...) {
  args <- list(...)
  if (length(args) == 1 && is.list(args[[1]]))
    args <- args[[1]]
  S4Vectors:::new_SimpleList_from_list("SimpleGenomicRangesList", args)
}

### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
### Utilities.
###

setMethod("stack", "GenomicRangesList", function(x, indName = "sample") {
  x_flat <- unlist(x, use.names = FALSE)
  mcols(x_flat) <- cbind(IRanges:::.stack.ind(x, indName), mcols(x_flat))
  x_flat
})
LiNk-NY/GenomicRanges documentation built on May 9, 2017, 5:14 a.m.