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 ofadata.X
.- zero_center
bool
(default:True
) If
True
, compute standard PCA from covariance matrix. IfFalse
, 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. Ifnp.ndarray
, use the provided mask. Ifstr
, use the mask stored inadata.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 ofchunk_size
. The incremental PCA automatically zero centers and ignores settings ofrandom_seed
andsvd_solver
. IfFalse
, perform a full PCA.- chunk_size
int
(default:None
) Number of observations to include in each chunk. Required if
chunked=True
was passed.
- adata
- Return type:
- 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.