| aggregate | R Documentation |
Aggregate
aggregate(x, ...)
aggregateCols(x, ...)
aggregateRows(x, ...)
## S4 method for signature 'Matrix'
aggregate(x, by, fun = c("sum", "mean", "n"), MARGIN = 1L)
## S4 method for signature 'SummarizedExperiment'
aggregate(x, col = "aggregate", fun = "sum", MARGIN = 1L)
## S4 method for signature 'matrix'
aggregate(
x,
by,
fun = c("sum", "mean", "median", "geometricMean", "n"),
MARGIN = 1L
)
## S4 method for signature 'Matrix'
aggregateCols(x, ...)
## S4 method for signature 'SummarizedExperiment'
aggregateCols(x, ...)
## S4 method for signature 'matrix'
aggregateCols(x, ...)
## S4 method for signature 'Matrix'
aggregateRows(x, ...)
## S4 method for signature 'SummarizedExperiment'
aggregateRows(x, ...)
## S4 method for signature 'matrix'
aggregateRows(x, ...)
x |
Object. |
by |
|
fun |
|
MARGIN |
|
col |
|
... |
Additional arguments. |
Modified object.
aggregate(SummarizedExperiment): Arguments pass through to matrix or Matrix method, depending on the class
of matrix defined in requested assay.
matrix, Matrix:
Aggregate using a grouping factor.
SummarizedExperiment:
Aggregate data slotted in assays() using an automatically generated
grouping factor, which is obtained from a user-defined column
(col argument) in either the rowData() or colData() of the object.
Slot an aggregate column into rowData() for aggregateRows(), or into
colData() for aggregateCols(). This method will define the groupings
automatically, and perform the aggregation.
Updated 2021-09-13.
Michael Steinbaugh, Rory Kirchner
stats::aggregate().
S4Vectors::aggregate().
Matrix.utils::aggregate.Matrix().
muscat::aggregateData().
counts <- matrix(
data = c(
0L, 2L, 2L, 2L,
2L, 0L, 2L, 2L,
2L, 2L, 0L, 2L,
2L, 2L, 2L, 0L
),
nrow = 4L,
ncol = 4L,
byrow = TRUE,
dimnames = list(
paste0("transcript", seq_len(4L)),
paste(
paste0("sample", rep(seq_len(2L), each = 2L)),
paste0("replicate", rep(seq_len(2L), times = 2L)),
sep = "_"
)
)
)
genes <- factor(paste0("gene", rep(seq_len(2L), each = 2L)))
names(genes) <- rownames(counts)
print(genes)
samples <- factor(paste0("sample", rep(seq_len(2L), each = 2L)))
names(samples) <- colnames(counts)
print(samples)
## matrix ====
object <- counts
print(object)
aggregate(object, by = genes, MARGIN = 1L)
aggregateRows(object, by = genes)
aggregate(object, by = samples, MARGIN = 2L)
aggregateCols(object, by = samples)
## Matrix ====
object <- as(counts, "sparseMatrix")
print(object)
aggregate(object, by = genes, MARGIN = 1L)
aggregateRows(object, by = genes)
aggregate(object, by = samples, MARGIN = 2L)
aggregateCols(object, by = samples)
## SummarizedExperiment ====
object <- SummarizedExperiment::SummarizedExperiment(
assays = S4Vectors::SimpleList(
"counts" = counts
),
rowData = S4Vectors::DataFrame(
"aggregate" = genes
),
colData = S4Vectors::DataFrame(
"sampleName" = as.factor(names(samples)),
"aggregate" = samples
)
)
print(object)
aggregate(object, MARGIN = 1L)
aggregateRows(object)
aggregate(object, MARGIN = 2L)
aggregateCols(object)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.