Skip to contents

Aggregate

Usage

aggregate(x, ...)

# S4 method for SingleCellExperiment
aggregate(x, col = "aggregate", fun = "sum", MARGIN = 1L)

Arguments

x

Object.

col

character(1). Name of column in either rowData() or colData() that defines the desired aggregation groupings.

fun

character(1). Name of the aggregation function to apply. Uses match.arg() internally.

MARGIN

integer(1-2). Dimension where the function will be applied. For a two-dimensional matrix: 1 indicates rows; 2 indicates columns; c(1, 2) indicates rows and columns.

...

Additional arguments.

Value

SingleCellExperiment.

Note

Updated 2022-05-24.

Methods (by class)

  • aggregate(SummarizedExperiment): Arguments pass through to matrix or Matrix method, depending on the class of matrix defined in requested assay.

Methods (by class)

  • 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.

See also

Author

Michael Steinbaugh, Rory Kirchner

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):