cellflow.preprocessing.project_pca

cellflow.preprocessing.project_pca(query_adata, ref_adata=None, ref_means=None, ref_pcs=None, layer=None, obsm_key_added='X_pca', copy=False)[source]

Projects the query data to the principal components of the reference data.

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

  • 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.

  • layer (str | None) – Layer in layers to use for PCA.

  • obsm_key_added (str) – Key in obsm to store the PCA coordinates.

  • copy (bool)

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:

  • .obsm["X_pca"]: PCA coordinates.