gedi2py.plotting.embedding

gedi2py.plotting.embedding(adata, *, basis='X_gedi_umap', color=None, layer=None, size=None, alpha=1.0, title=None, legend_loc='right margin', legend_fontsize=10, cmap='viridis', palette=None, frameon=False, ncols=4, wspace=0.4, show=None, save=None, ax=None, return_fig=False, **kwargs)[source]

Plot GEDI embedding colored by various attributes.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • basis (str, default: 'X_gedi_umap') – Key in adata.obsm for the embedding coordinates. Defaults to X_gedi_umap.

  • color (Union[str, Sequence[str], None], default: None) – Key(s) for annotation in adata.obs or gene names to color by. Can be a single key or a list of keys.

  • layer (str | None, default: None) – Layer to use for gene expression values.

  • size (float | None, default: None) – Point size. If None, automatically determined.

  • alpha (float, default: 1.0) – Point transparency (0-1).

  • title (Union[str, Sequence[str], None], default: None) – Panel title(s). If None, uses the color key(s).

  • legend_loc (str, default: 'right margin') – Location of the legend. Options: 'right margin', 'on data', 'best', 'upper right', etc.

  • legend_fontsize (int | float, default: 10) – Font size for legend text.

  • cmap (str, default: 'viridis') – Colormap for continuous variables.

  • palette (Union[str, Sequence[str], None], default: None) – Color palette for categorical variables.

  • frameon (bool, default: False) – Whether to show axis frame.

  • ncols (int, default: 4) – Number of columns for multi-panel plots.

  • wspace (float, default: 0.4) – Width space between panels.

  • show (bool | None, default: None) – If True, show the figure. If None, defaults to True unless save is specified.

  • save (str | None, default: None) – Path to save the figure.

  • ax (Axes | None, default: None) – Pre-existing axes for the plot. Only valid when color is a single key.

  • return_fig (bool, default: False) – If True, return the figure object.

  • **kwargs – Additional arguments passed to matplotlib.pyplot.scatter.

Returns:

  • If return_fig=True: Returns the Figure object

  • If ax is provided: Returns the Axes object

  • Otherwise: Returns None

Return type:

Depending on ``return_fig`` and ax

Examples

>>> import gedi2py as gd
>>> gd.tl.gedi(adata, batch_key="sample", n_latent=10)
>>> gd.tl.umap(adata)
>>> gd.pl.embedding(adata, color="cell_type")
>>> gd.pl.embedding(adata, color=["batch", "cell_type", "total_counts"])