cellflow.preprocessing.reconstruct_pca

cellflow.preprocessing.reconstruct_pca(query_adata, use_rep='X_pca', ref_adata=None, ref_means=None, ref_pcs=None, layers_key_added='X_recon', copy=False)[source]

Performs PCA on the data matrix and projects the data to the principal components.

Parameters:
  • query_adata (AnnData) – An AnnData object with the query data.

  • use_rep (str) – Representation to use for PCA. If 'X', uses X. Otherwise, uses adata.obsm[use_rep].

  • ref_adata (AnnData | None) – An AnnData object with the reference data containing adata.varm["X_mean"] and adata.varm["PCs"].

  • ref_means (ndarray[tuple[Any, ...], dtype[float64]] | None) – Mean of the reference data. Only used if ref_adata is None.

  • ref_pcs (ndarray[tuple[Any, ...], dtype[float64]] | None) – Principal components of the reference data. Only used if ref_adata is None.

  • layers_key_added (str) – Key in layers to store the reconstructed data matrix.

  • copy (bool) – Return a copy of adata instead of updating it in place.

Return type:

AnnData | None

Returns:

: If copy is True, returns a new AnnData object with the PCA results stored in obsm. Otherwise, updates adata in place.

Sets the following fields:

  • .layers["X_recon"]: Reconstructed data matrix.