gedi2py.tools.pca¶
- gedi2py.tools.pca(adata, *, n_components=None, key='gedi', key_added=None, copy=False)[source]¶
Compute PCA coordinates from GEDI decomposition.
PCA coordinates are computed as
V @ diag(d)from the factorized SVD, where V are the right singular vectors (cell embeddings).- Parameters:
adata (
AnnData) – Annotated data matrix with GEDI results in.uns[key].n_components (
int|None, default:None) – Number of PCs to compute. IfNone, uses all K latent factors.key (
str, default:'gedi') – Key inadata.unswhere GEDI results are stored.key_added (
str|None, default:None) – Key to store PCA inadata.obsm. Defaults toX_{key}_pca.copy (
bool, default:False) – IfTrue, return the PCA coordinates instead of storing inadata.
- Return type:
- Returns:
If ``copy=True``,returns PCA coordinates as numpy array (n_cells,n_components).Otherwise,stores in ``adata.obsm[key_added]``andreturns ``None`.`
Examples
>>> import gedi2py as gd >>> gd.tl.gedi(adata, batch_key="sample", n_latent=10) >>> gd.tl.pca(adata, n_components=20) >>> adata.obsm["X_gedi_pca"]