Skip to content

msmu.pl.plot_var

Plot a feature annotation by group.

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

'psm'
groupby str | None

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

None
var_column str | None

Required column in the selected modality .var, such as "charge" or "purity".

None
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
ptype str | None

"stack" (aliases "stackd", "stacked_bar"), "box", "simple_box"/"simplebox", "vln"/"violin", or "hist"/"histogram". None selects box for numeric columns with more than 20 distinct values, otherwise stacked bars.

None
bins int

Histogram bin count; ignored for other plot types.

30
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

The selected feature annotation must exist; numeric plot types require numeric values. 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
fig = mm.pl.plot_var(mdata, modality="psm", var_column="charge")
fig.show()