Skip to contents

Given a (features x cells) matrix, group cells by cell_groups and aggregate counts by method for each feature.

Usage

pseudobulk_matrix(mat, cell_groups, method = "sum", threads = 1L)

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 method is length 1, returns a matrix of shape (features x groups).

  • If method is greater than length 1, 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 of nonzeros, sum, mean, variance.

Details

Some simpler stats are calculated in the process of calculating more complex statistics. So when calculating variance, nonzeros and mean can be included with no extra calculation time, and when calculating mean, adding nonzeros will take no extra time.