vampire.anno.pl.copy_number_stacked_violin

vampire.anno.pl.copy_number_stacked_violin#

vampire.anno.pl.copy_number_stacked_violin(adata, *, group_by=None, group_order=None, motifs=None, log=False, show_box=False, show_points=False, show_counts=True, colormap=None, row_height=50, figsize=(None, None), save=None, **kwargs)[source]#

Plot copy-number distributions for multiple motifs as stacked violins.

Each row corresponds to one motif; each column corresponds to a group defined by group_by. Useful for comparing copy-number variation across motifs and sample groups simultaneously.

Parameters:
  • adata (AnnData) – Annotated data with motif copy-number matrix in X.

  • group_by (str | None) – Column name in adata.obs used to group samples. If it is None, plot without grouping

  • group_order (Optional[Sequence[str]]) – Explicit order for the groups on the x-axis. If None, groups are sorted alphabetically.

  • motifs (Union[str, Sequence[str], None]) – Motif(s) to visualise. If None, all motifs in adata are used. If more than 30 motifs are selected a warning is emitted. A single str or a list/sequence of motif IDs / sequences is accepted.

  • log (bool) – Whether to apply log1p transform to copy-number values before plotting.

  • show_box (bool) – Whether to overlay a mini box plot inside each violin.

  • show_points (bool) – Whether to overlay individual data points on each violin.

  • show_counts (bool) – If True, the x-axis tick label of each group shows the sample count on a second line (<group><br>n={count}).

  • colormap (Union[str, Sequence[str], None]) – Colormap for the median-based violin fill. If a str, it is passed to plotly.colors.sample_colorscale (e.g. "Viridis", "Plasma"). If a sequence of hex/rgb strings, used directly. If None, the module default sequential colormap is used.

  • row_height (int) – Height in pixels allocated to each motif row.

  • figsize (tuple[int | None, int | None]) – Figure size in pixels.

  • save (str | bool | None) – If True or a str, save the figure. A string is appended to the default filename. Infer the filetype if ending on {'.pdf', '.png', '.svg'}.

  • **kwargs – Additional arguments passed to fig.update_layout().

Returns:

Plotly figure with stacked violin plots.

Return type:

Figure

Examples

>>> import vampire as vp
>>> vp.anno.pl.set_default_plotstyle()
>>> adata = vp.datasets.wdr7_hprc()
>>> vp.anno.pl.copy_number_stacked_violin(adata, group_by="haplotype")
>>> vp.anno.pl.copy_number_stacked_violin(
...     adata, group_by="ancestry", motifs=["0", "1", "2"]
... )