sumCountsAcrossCells | R Documentation |
Sum counts or average expression values for each feature across groups of cells.
This function is deprecated; use summarizeAssayByGroup
instead.
sumCountsAcrossCells(x, ...)
## S4 method for signature 'ANY'
sumCountsAcrossCells(
x,
ids,
subset.row = NULL,
subset.col = NULL,
store.number = "ncells",
average = FALSE,
BPPARAM = SerialParam(),
subset_row = NULL,
subset_col = NULL,
store_number = NULL
)
## S4 method for signature 'SummarizedExperiment'
sumCountsAcrossCells(x, ..., assay.type = "counts", exprs_values = NULL)
x |
A numeric matrix of expression values (usually counts) containing features in rows and cells in columns. Alternatively, a SummarizedExperiment object containing such a matrix. |
... |
For the generics, further arguments to be passed to specific methods. For the SummarizedExperiment method, further arguments to be passed to the ANY method. |
ids |
A factor specifying the group to which each cell in |
subset.row |
An integer, logical or character vector specifying the features to use.
If |
subset.col |
An integer, logical or character vector specifying the cells to use.
Defaults to all cells with non- |
store.number |
String specifying the field of the output |
average |
Logical scalar indicating whether the average should be computed instead of the sum.
Alternatively, a string containing |
BPPARAM |
A BiocParallelParam object specifying whether summation should be parallelized. |
subset_row , subset_col , exprs_values , store_number |
Soft-deprecated equivalents to the arguments described above. |
assay.type |
A string or integer scalar specifying the assay of |
These functions provide a convenient method for summing or averaging expression values 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 analyses, e.g., differential expression analyses between conditions.
The behaviour of sumCountsAcrossCells
is equivalent to that of colsum
.
However, this function can operate on any matrix representation in object
;
can do so in a parallelized manner for large matrices without resorting to block processing;
and can natively support combinations of multiple factors in ids
.
Any NA
values in ids
are implicitly ignored and will not be considered during summation.
This may be useful for removing undesirable cells by setting their entries in ids
to NA
.
Alternatively, we can explicitly select the cells of interest with subset_col
.
Setting average=TRUE
will compute the average in each set rather than the sum.
This is particularly useful if x
contains expression values that have already been normalized in some manner,
as computing the average avoids another round of normalization to account for differences in the size of each set.
The same effect is obtained by setting average="mean"
,
while setting average="median"
will instead compute the median across all cells.
A SummarizedExperiment is returned with one column per level of ids
.
Each entry of the assay contains the sum or average across all cells in a given group (column) for a given feature (row).
Columns are ordered by levels(ids)
and the number of cells per level is reported in the "ncells"
column metadata.
For DataFrame ids
, each column corresponds to a unique combination of levels (recorded in the colData
).
Aaron Lun
aggregateAcrossCells
, which also combines information in the colData
.
numDetectedAcrossCells
, which computes the number of cells with detected expression in each group.
example_sce <- mockSCE()
ids <- sample(LETTERS[1:5], ncol(example_sce), replace=TRUE)
out <- sumCountsAcrossCells(example_sce, ids)
head(out)
batches <- sample(1:3, ncol(example_sce), replace=TRUE)
out2 <- sumCountsAcrossCells(example_sce,
DataFrame(label=ids, batch=batches))
head(out2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.