FACSPy.tl._compute_pca#
- FACSPy.tl._compute_pca(adata, n_comps=None, zero_center=True, svd_solver='arpack', random_state=187, chunked=False, chunk_size=None)#
Internal function to compute the PCA embedding. The core of the function is implemented from scanpy with the important difference that the PCA coordinates are returned and not written to the adata object.
- Parameters:
adata (
AnnData) – The anndata object of shape n_obs x n_vars where rows correspond to cells and columns to the channelsn_comps (
Optional[int]) – Number of components to be calculated.zero_center (
Optional[bool]) – If True, compute standard PCA from covariance matrix. If False, omit zero-centering variables (usesTruncatedSVD), which allows to handle sparse input efficiently. Passing None decides automatically based on sparseness of the data.svd_solver (
str) – One of auto, full, arpack, randomizedrandom_state (
int) – Sets the random state.chunked (
bool) – 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 (
Optional[int]) – Number of observations to include in each chunk. Required if chunked=True was passed.
- Return type:
tuple[ndarray,ndarray,dict,dict]- Returns:
X_pca – The PCA coordinates
pca_.components – Principal components containing the loadings
pca_variances – Explained variance, equivalent to the eigenvalues of the covariance matrix
pca_settings – A dictionary containing the parameters used for analysis.