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
| Name | Type | Default | Description |
|---|---|---|---|
data | `ad.AnnData | pd.DataFrame` | required |
metrics | `Sequence[str] | str | None` |
key_added | `str | None` | None |
groupby | `str | None` | None |
order | `Sequence[str | None] | None` |
transformed | bool | False | Plot fitting units instead of the original metric units. |
inner | `str | None` | 'box' |
show_thresholds | bool | True | Overlay stored thresholds. Batch cutoffs require the fitted grouping. |
palette | `str | Sequence` | 'Set2' |
titles | `Sequence[str] | None` | None |
figsize | `tuple[float, float] | None` | None |
ax | `Axes | Sequence[Axes] | np.ndarray |
max_points | `int | None` | 2000 |
random_state | int | 0 | Seed for display sampling. Thresholds always use the full fit. |
show | bool | True | Display the figure. |
save | `str | Path | None` |
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)