sumCountsAcrossFeatures {scater} | R Documentation |
Create a count matrix where counts for all features in a set are summed together.
sumCountsAcrossFeatures(object, ids, exprs_values = "counts")
object |
A SingleCellExperiment object or a count matrix. |
ids |
A factor specifying the set to which each feature in |
exprs_values |
A string or integer scalar specifying the assay of |
This function provides a convenient method for aggregating counts across multiple rows for each cell.
For example, genes with multiple mapping locations in the reference will often manifest as multiple rows with distinct Ensembl/Entrez IDs.
These counts can be aggregated into a single feature by setting the shared identifier (usually the gene symbol) as ids
.
It is theoretically possible to aggregate transcript-level counts to gene-level counts with this function.
However, it is often better to do so with functions like readTxResults
that account for differences in transcript lengths between isoforms.
Any NA
values in ids
are implicitly ignored and will not be considered or reported.
This may be useful, e.g., to remove undesirable feature sets by setting their entries in ids
to NA
.
A count matrix where counts for all features in the same set are summed together within each cell.
Aaron Lun
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, nrow(example_sce), replace=TRUE) out <- sumCountsAcrossFeatures(example_sce, ids) dimnames(out)