-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcollapseAt.Rd
43 lines (38 loc) · 1.49 KB
/
collapseAt.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/collapseAt.R
\name{collapseAt}
\alias{collapseAt}
\title{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{
\item{x}{something descended from SummarizedExperiment, with assays()}
\item{y}{something descended from a GRanges, with a granges() method}
\item{how}{how to summarize the assay values (default: median)}
\item{BPPARAM}{BPPARAM object to run in parallel (default: SerialParam())}
}
\value{
an object with same colData but with new rowData and assays
}
\description{
Collapse a SummarizedExperiment-like object over a GRanges, sensibly.
Handy for things like chromophobe model testing, GenometriCorr, etc.
}
\details{
TODO: let the user provide their own summarizer function
}
\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)
}