Aggregate counts matrices by cell group or feature.
Source:R/singlecell_utils.R
pseudobulk_matrix.RdGiven a (features x cells) matrix, group cells by cell_groups and aggregate counts by method for each
feature.
Arguments
- mat
IterableMatrix object of dimensions features x cells
- cell_groups
(Character/factor) Vector of group/cluster assignments for each cell. Length must be
ncol(mat).- method
(Character vector) Method(s) to aggregate counts. If one method is provided, the output will be a matrix. If multiple methods are provided, the output will be a named list of matrices.
Current options are:
nonzeros,sum,mean,variance.- threads
(integer) Number of threads to use.
Value
If
methodis length1, returns a matrix of shape(features x groups).If
methodis greater than length1, returns a list of matrices with each matrix representing a pseudobulk matrix with a different aggregation method. Each matrix is of shape(features x groups), and names are one ofnonzeros,sum,mean,variance.
