sumCountsAcrossCells {scater} | R Documentation

## Sum counts across a set of cells

### Description

Create a count matrix where counts for all cells in a set are summed together.

### Usage

    sumCountsAcrossCells(object, ids, exprs_values = "counts",
      BPPARAM = SerialParam())

### Arguments

`object` | A SingleCellExperiment object or a count matrix.
`ids` | A factor specifying the set to which each cell in `object` belongs.
`exprs_values` | A string or integer scalar specifying the assay of `object` containing counts, if `object` is a SingleCellExperiment.
`BPPARAM` | A BiocParallelParam object specifying how summation should be parallelized.

### Details

This function provides a convenient method for aggregating counts across multiple columns for each feature. A typical application would be to sum counts across all cells in each cluster to obtain “pseudo-bulk” samples for further analysis.

Any `NA` values in `ids` are implicitly ignored and will not be considered or reported. This may be useful, e.g., to remove undesirable cells by setting their entries in `ids` to `NA`.

### Value

A count matrix where counts for all cells in the same set are summed together for each feature.

### Author(s)

Aaron Lun

### Examples

    data("sc_example_counts")
    data("sc_example_cell_info")
    example_sce <- SingleCellExperiment(
        assays = list(counts = sc_example_counts),
        colData = sc_example_cell_info)

    ids <- sample(LETTERS[1:5], ncol(example_sce), replace=TRUE)
    out <- sumCountsAcrossCells(example_sce, ids)
    dimnames(out)

[Package scater version 1.12.2 Index]