collapseAt: Collapse a SummarizedExperiment-like object over a GRanges,...

View source: R/collapseAt.R

collapseAtR Documentation

Collapse a SummarizedExperiment-like object over a GRanges, sensibly. Handy for things like chromophobe model testing, GenometriCorr, etc.

Description

Collapse a SummarizedExperiment-like object over a GRanges, sensibly. Handy for things like chromophobe model testing, GenometriCorr, etc.

Usage

collapseAt(x, y, how = c("median", "mean", "sum"), BPPARAM = SerialParam())

Arguments

x

something descended from SummarizedExperiment, with assays()

y

something descended from a GRanges, with a granges() method

how

how to summarize the assay values (default: median)

BPPARAM

BPPARAM object to run in parallel (default: SerialParam())

Details

TODO: let the user provide their own summarizer function

Value

an object with same colData but with new rowData and assays

Examples


set.seed(123)
rr <- as(c("chr8:11657801-11665899","chr8:11665900-11700200"), "GRanges")
cd <- DataFrame(sample=letters[1:4], treatment=c(0,1,0,1))
rownames(cd) <- cd$sample
beta <- matrix(runif(8), nrow=length(rr), ncol=nrow(cd), 
               dimnames=list(as.character(rr), rownames(cd)))
tpm <- matrix(exp(rnorm(8)), nrow=length(rr), ncol=nrow(cd), 
              dimnames=list(as.character(rr), rownames(cd)))
se <- SummarizedExperiment(list(beta=beta,tpm=tpm), rowRanges=rr, colData=cd)
gr <- as("chr8:11665843-11665969", "GRanges")
collapseAt(se, gr)


ttriche/chromophobe documentation built on Oct. 14, 2024, 11:59 a.m.