scviva.tools.vision.pool_matrix#

scviva.tools.vision.pool_matrix(X, pools, obs_names)[source]#

Average expression within each micro-cluster via sparse matrix multiply.

Mirrors R VISION’s poolMatrixCols_Inner. Builds a binary n_cells × n_pools indicator matrix and multiplies it against the expression matrix in a single sparse operation, then divides each row by its pool size.

Parameters:
X ndarray | spmatrix

Expression matrix, cells × genes.

pools dict[str, list[str]]

Mapping pool_id → list[obs_name] as returned by apply_micro_clustering().

obs_names list[str] | ndarray

Cell names aligned to rows of X.

Return type:

ndarray

Returns:

ndarray of shape (n_pools, n_genes) Per-pool mean expression.