simulation_umap#
- scdiffeq.plotting._simulation_umap.simulation_umap(adata_sim: AnnData, color: str = 't', use_key: str = 'X_umap', gene_key: str = 'X_gene_inv', gene_ids_key: str = 'gene_ids', ax: Axes | None = None, figsize: tuple = (4, 4), cmap: str | Colormap = 'viridis', categorical_cmap: Dict[str, str] | None = None, s: float = 1.0, alpha: float = 0.8, title: str | None = None, show_colorbar: bool = True, colorbar_label: str | None = None, show_legend: bool = True, legend_loc: str = 'best', save: bool = False, savename: str | None = None, save_format: str = 'svg', dpi: int = 300, **kwargs) Axes[source]#
Plot UMAP embedding of simulated data, colored by obs attribute or gene expression.
- Parameters:
adata_sim (AnnData) – Simulated data from
sdq.tl.simulate(), with UMAP coordinates in obsm and optionally gene expression in obsm after callingsdq.tl.invert_scaled_gex().color (str, default="t") – What to color points by. Can be: - Column name in
adata_sim.obs(e.g., “t”, “fate”, “sim_i”) - Gene name (will look up in gene_ids_key and extract from gene_key)use_key (str, default="X_umap") – Key in
adata_sim.obsmcontaining UMAP coordinates.gene_key (str, default="X_gene_inv") – Key in
adata_sim.obsmcontaining gene expression matrix.gene_ids_key (str, default="gene_ids") – Key in
adata_sim.unscontaining gene names.ax (plt.Axes, optional) – Matplotlib axes to plot on. If None, creates new figure.
figsize (tuple, default=(4, 4)) – Figure size (width, height) in inches if creating new figure.
cmap (str or Colormap, default="viridis") – Colormap for continuous values.
categorical_cmap (Dict[str, str], optional) – Mapping from category names to colors for categorical data.
s (float, default=1.0) – Point size.
alpha (float, default=0.8) – Point transparency.
title (str, optional) – Plot title. If None, uses the color parameter.
show_colorbar (bool, default=True) – Whether to show colorbar for continuous values.
colorbar_label (str, optional) – Label for colorbar. If None, uses the color parameter.
show_legend (bool, default=True) – Whether to show legend for categorical values.
legend_loc (str, default="best") – Legend location.
save (bool, default=False) – Whether to save the figure.
savename (str, optional) – Filename for saving. If None, auto-generates from color parameter.
save_format (str, default="svg") – Format for saving figure.
dpi (int, default=300) – Resolution for saving figure.
**kwargs – Additional keyword arguments passed to
ax.scatter()(e.g.,zorder,edgecolors,linewidths).
- Returns:
The matplotlib axes object.
- Return type:
plt.Axes
Examples
>>> import scdiffeq as sdq >>> # Color by time >>> sdq.pl.simulation_umap(adata_sim, color="t") >>> # Color by fate >>> sdq.pl.simulation_umap(adata_sim, color="fate", categorical_cmap={"Mon.": "orange", "Neu.": "blue"}) >>> # Color by gene expression >>> sdq.pl.simulation_umap(adata_sim, color="Myc")