gedi2py.tools.get_projection

gedi2py.tools.get_projection(adata, which='zdb', *, key='gedi', key_added=None, copy=False)[source]

Compute and retrieve GEDI projections.

Projections transform the learned GEDI parameters into interpretable representations:

  • ZDB: Shared manifold projection (genes × cells) = Z @ diag(D) @ B

  • DB: Latent factor embedding (K × cells) = diag(D) @ B

  • ADB: Pathway activity projection (pathways × cells) = C_rot @ A @ diag(D) @ B

Parameters:
  • adata (AnnData) – Annotated data matrix with GEDI results in .uns[key].

  • which (Literal['zdb', 'db', 'adb'], default: 'zdb') – Which projection to compute: "zdb", "db", or "adb".

  • key (str, default: 'gedi') – Key in adata.uns where GEDI results are stored.

  • key_added (str | None, default: None) – Key to store the result in adata.obsm. If None, defaults to X_{key}_{which} (e.g., X_gedi_zdb).

  • copy (bool, default: False) – If True, return a copy of the projection array instead of storing in adata.

Return type:

AnnData | ndarray | None

Returns:

  • If ``copy=True``, returns the projection as a numpy array.

  • Otherwise, stores the result in ``adata.obsm[key_added]`` and returns ``None`.`

Examples

>>> import gedi2py as gd
>>> gd.tl.gedi(adata, batch_key="sample", n_latent=10)
>>> gd.tl.get_projection(adata, "zdb")
>>> adata.obsm["X_gedi_zdb"]  # (n_cells, n_genes)