rapids_singlecell.pp.pca

Contents

rapids_singlecell.pp.pca#

rapids_singlecell.pp.pca(adata, n_comps=None, *, layer=None, zero_center=True, svd_solver=None, random_state=0, mask_var=Empty.token, use_highly_variable=None, dtype='float32', copy=False, chunked=False, chunk_size=None)[source]#

Performs PCA using the cuml decomposition function.

Parameters:
adata AnnData

AnnData object

n_comps int | None (default: None)

Number of principal components to compute. Defaults to 50, or 1 - minimum dimension size of selected representation

layer str (default: None)

If provided, use adata.layers[layer] for expression values instead of adata.X.

zero_center bool (default: True)

If True, compute standard PCA from covariance matrix. If False, omit zero-centering variables

svd_solver str (default: None)

Solver to use for the PCA computation. Must be one of {‘full’, ‘jacobi’, ‘auto’}. Defaults to ‘auto’.

random_state int | None (default: 0)

Change to use different initial states for the optimization.

mask_var ndarray[Any, dtype[bool_]] | str | None | Empty (default: _empty)

Mask to use for the PCA computation. If None, all variables are used. If np.ndarray, use the provided mask. If str, use the mask stored in adata.var[mask_var].

use_highly_variable bool | None (default: None)

Whether to use highly variable genes only, stored in .var['highly_variable']. By default uses them if they have been determined beforehand.

dtype str (default: 'float32')

Numpy data type string to which to convert the result.

copy bool (default: False)

Whether to return a copy or update adata.

chunked bool (default: False)

If True, perform an incremental PCA on segments of chunk_size. The incremental PCA automatically zero centers and ignores settings of random_seed and svd_solver. If False, perform a full PCA.

chunk_size int (default: None)

Number of observations to include in each chunk. Required if chunked=True was passed.

Return type:

None | AnnData

Returns:

adds fields to adata:

.obsm['X_pca']

PCA representation of data.

.varm['PCs']

The principal components containing the loadings.

.uns['pca']['variance_ratio']

Ratio of explained variance.

.uns['pca']['variance']

Explained variance, equivalent to the eigenvalues of the covariance matrix.