Aggregate
Usage
aggregate(x, ...)
# S4 method for class 'SingleCellExperiment'
aggregate(x, col = "aggregate", fun = "sum", MARGIN = 1L)Arguments
- x
Object.
- col
character(1). Name of column in eitherrowData()orcolData()that defines the desired aggregation groupings.- fun
character(1). Name of the aggregation function to apply. Usesmatch.arg()internally.- MARGIN
integer(1-2). Dimension where the function will be applied. For a two-dimensional matrix:1indicates rows;2indicates columns;c(1, 2)indicates rows and columns.- ...
Additional arguments.
Methods (by class)
aggregate(SummarizedExperiment): Arguments pass through tomatrixorMatrixmethod, depending on the class of matrix defined in requestedassay.
Methods (by class)
matrix,Matrix: Aggregate using a groupingfactor.SummarizedExperiment: Aggregate data slotted inassays()using an automatically generated groupingfactor, which is obtained from a user-defined column (colargument) in either therowData()orcolData()of the object. Slot anaggregatecolumn intorowData()foraggregateRows(), or intocolData()foraggregateCols(). This method will define thegroupingsautomatically, and perform the aggregation.
Examples
data(SingleCellExperiment_lanesplit, package = "AcidTest")
## SingleCellExperiment ====
x <- SingleCellExperiment_lanesplit
levels(SummarizedExperiment::colData(x)[["aggregate"]])
#> [1] "sample_1" "sample_2"
x <- aggregate(
x = x,
col = "aggregate",
fun = "sum",
MARGIN = 2L
)
#> → Remapping cells to aggregate samples: "sample_1", "sample_2"
print(x)
#> class: SingleCellExperiment
#> dim: 100 8
#> metadata(2): aggregate aggregateCols
#> assays(1): counts
#> rownames(100): gene001 gene002 ... gene099 gene100
#> rowData names(10): broadClass description ... ncbiGeneId seqCoordSystem
#> colnames(8): sample_1_AAAAAA_AAAAAA_AAAAAA
#> sample_1_CCCCCC_CCCCCC_CCCCCC ... sample_2_GGGGGG_GGGGGG_GGGGGG
#> sample_2_TTTTTT_TTTTTT_TTTTTT
#> colData names(1): sampleId
#> reducedDimNames(0):
#> mainExpName: NULL
#> altExpNames(0):