Skip to content

msmu.pl.plot_umap

Plot the first two coordinates of a previously computed UMAP embedding.

Parameters:

Name Type Description Default
mdata MuData

MuData containing the selected modality and observation metadata.

required
modality str

Name of the modality to plot, such as "protein" or "psm".

'protein'
groupby str | None

Grouping column in observation metadata (or feature metadata where supported). None uses the resolved obs_column.

None
colorby str | None

Observation column used to assign sample colors when groupby resolves to obs_column; ignored for other groupings. None uses the template palette.

None
template str

Registered plotly template name, normally "msmu".

DEFAULT_TEMPLATE
obs_column str | None

Sample identifier in mdata.obs. If omitted, uses .uns["plotting"]["default_obs_column"], then source name/source_name/sample/filename, then the observation index.

None
key str

Key containing embedding coordinates in modality .obsm.

'X_umap'
kwargs str

Additional plotly layout options, for example width=800 or title_text="QC".

{}

Returns:

Type Description
Figure

plotly Figure. Call .show() to display or .write_html("plot.html") to export.

Notes

Run umap first. Match key to its key_added; at least two embedding dimensions must exist. Quantification and embeddings are unchanged. Resolving an existing sample-identifier column can convert that column in mdata.obs to categorical; pass a copy to preserve its dtype.

Examples:

import msmu as mm
mdata = mm.tl.umap(mdata, modality="protein", n_components=2)
fig = mm.pl.plot_umap(mdata, modality="protein")
fig.show()