scviva.tools.vision.apply_pca#
- scviva.tools.vision.apply_pca(X, max_components=200)[source]#
PCA via randomized truncated SVD with gene-mean centering.
Mirrors R VISION’s
applyPCAwhich runs IRLBA ont(exprData)withcenter = rowMeans(exprData). The Python equivalent works on the (cells × genes) layout and centers by subtracting per-gene means before the SVD.- Parameters:
- Return type:
- Returns:
- pca_coordsndarray of shape (n_cells, n_components)
Cell coordinates in PC space (scores).
- variance_explainedndarray of shape (n_components,)
Proportion of total variance captured by each PC.
- gene_loadingsndarray of shape (n_genes, n_components)
Right singular vectors (variable loadings) for each PC.
Notes
total_varis computed assum((X - mu)²)which equals R’ssum(exprData²) - ncol(exprData) * sum(rM²)— algebraically identical expressions for the variance of the centered matrix.