ocelli.pl.violin#
- ocelli.pl.violin(adata: AnnData, groups: str, values: str, cdict=None, figsize=None, fontsize: int = 6, showlegend: bool = True, markerscale: float = 1.0, save: str | None = None, dpi: int = 300)#
Feature violin plots
Generates violin plots showing the distribution of feature values stored in adata.obs or adata.obsm. Separate violin plots are created for each group defined by adata.obs[groups].
- Parameters:
adata (anndata.AnnData) – The annotated data matrix.
groups (str) – Key in adata.obs specifying the groups or clusters for which violin plots are generated.
values (str) – Key in adata.obs or adata.obsm specifying the values to be plotted.
cdict (dict or None) – A dictionary mapping groups to colors. If None, colors are generated automatically. (default: None)
figsize (tuple or None) – Size of the plot figure. (default: None)
fontsize (int) – Font size for plot labels and legends. (default: 6)
showlegend (bool) – Whether to display a legend for the groups. (default: True)
markerscale (float) – Scale of the legend markers. (default: 1.0)
save (str or None) – Path to save the plot as an image. If None, the plot is returned as a Matplotlib figure. (default: None)
dpi (int) – Resolution of the saved figure in dots per inch (DPI). Controls the image quality. (default: 300)
- Returns:
If save=None: Returns a Matplotlib figure object.
Otherwise, saves the plot to the specified path and does not return anything.
- Return type:
matplotlib.figure.Figure or None
- Example:
import ocelli as oci from anndata import AnnData import numpy as np import pandas as pd # Example data adata = AnnData(X=np.random.rand(100, 50)) adata.obs["groups"] = np.random.choice(["A", "B", "C"], 100) adata.obs["values"] = np.random.rand(100) # Generate violin plot oci.pl.violin(adata, groups="groups", values="values", fontsize=10, showlegend=True)