scmorph.pp.pca#
- scmorph.pp.pca(adata, n_comps=None, whiten=False, *, copy=False, zero_center=True, random_state=0, **kwargs)#
Principal component analysis [Pedregosa et al., 2011].
Computes PCA coordinates, loadings and variance decomposition. Uses the implementation of scikit-learn [Pedregosa et al., 2011].
This function wraps the higher-level function
pca()([Wolf et al., 2018]).It provides addional functionality to whiten the resulting PCA coordinates, which may help de-correlate them.
- Parameters:
adata (
AnnData) – AnnData objectn_comps (
Optional[int] (default:None)) – Number of principal components to compute. Defaults to 50, or 1 - minimum dimension size of selected representation.whiten (
bool(default:False)) – Whether to whiten the data. This can help remove correlation in the resulting PC axes.copy (
bool(default:False)) – Return a copy instead of writing to adata.zero_center (
bool|None(default:True)) – IfTrue, compute standard PCA from covariance matrix (strongly recommended). IfFalse, omit zero-centering variable.random_state (
int|None(default:0)) – Change to use different initial states for the optimization.kwargs (
Any) – Additional arguments passed topca().
- Return type:
AnnData|None- Returns:
Returns
Noneifcopy=False, else returns anAnnDataobject. Sets the following fields:.obsm['X_pca' | key_added]spmatrix|ndarray(shape(adata.n_obs, n_comps))PCA representation of data.
.varm['PCs' | key_added]ndarray(shape(adata.n_vars, n_comps))The principal components containing the loadings.
.uns['pca' | key_added]['variance_ratio']ndarray(shape(n_comps,))Ratio of explained variance.
.uns['pca' | key_added]['variance']ndarray(shape(n_comps,))Explained variance, equivalent to the eigenvalues of the covariance matrix.