Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

vm.pl.violin

Plot fitted metrics with lower (dashed) and upper (dotted) cutoffs.

Signature

def violin(
    data: ad.AnnData | pd.DataFrame,
    *,
    metrics: Sequence[str] | str | None = None,
    key_added: str | None = None,
    groupby: str | None = None,
    order: Sequence[str | None] | None = None,
    transformed: bool = False,
    inner: str | None = "box",
    show_thresholds: bool = True,
    palette: str | Sequence = "Set2",
    titles: Sequence[str] | None = None,
    figsize: tuple[float, float] | None = None,
    ax: Axes | Sequence[Axes] | np.ndarray | None = None,
    max_points: int | None = 2000,
    random_state: int = 0,
    show: bool = True,
    save: str | Path | None = None,
) -> tuple[Axes, ...] | None: ...

Parameters

NameTypeDefaultDescription
data`ad.AnnDatapd.DataFrame`required
metrics`Sequence[str]strNone`
key_added`strNone`None
groupby`strNone`None
order`Sequence[strNone]None`
transformedboolFalsePlot fitting units instead of the original metric units.
inner`strNone`'box'
show_thresholdsboolTrueOverlay stored thresholds. Batch cutoffs require the fitted grouping.
palette`strSequence`'Set2'
titles`Sequence[str]None`None
figsize`tuple[float, float]None`None
ax`AxesSequence[Axes]np.ndarray
max_points`intNone`2000
random_stateint0Seed for display sampling. Thresholds always use the full fit.
showboolTrueDisplay the figure.
save`strPathNone`

Returns

tuple of matplotlib.axes.Axes or None

One axes per metric when show is False.

Raises

ImportError

If the optional plotting dependencies are not installed.

KeyError

If a requested metric, grouping column, or fitted run is missing.

ValueError

If the metric selection, group order, or display options are invalid.

Notes

Metric values and fitted thresholds are read from the existing observation table and stored fit. Thresholds are never refitted. In original units, overlays use inverse-transformed stored thresholds; transformed=True plots and labels values in fitting units. Display subsampling controlled by max_points and random_state does not affect thresholds.

See Also

Examples

import verymadpy as vm

axes = vm.pl.violin(adata, groupby="sample_id", show=False)