Aggregates cells into coarse-grained groups using k-means clustering, and updates the gene expression matrix and cell-cell affinity matrix accordingly. This is useful for testing or reducing computational complexity in downstream analyses.

CoarseGrain(
  feature_space,
  expression,
  graph.affinity,
  N = 5000,
  random.seed = 1
)

Arguments

feature_space

matrix; the low-dimensional feature space of cells (e.g., PCA or UMAP coordinates), with cells as rows and dimensions as columns.

expression

matrix; the gene expression matrix with features (genes) as rows and cells as columns.

graph.affinity

matrix; the cell-cell affinity matrix to be coarse-grained.

N

integer; the number of coarse-grained groups to form using k-means clustering. Default is 5000.

random.seed

integer; random seed to ensure reproducibility. Default is 1.

Value

A list containing:

expression

matrix; coarse-grained gene expression matrix (genes × groups).

graph

matrix; updated cell-cell affinity matrix between coarse-grained groups.