vampire.anno.pl.copy_number_violin

vampire.anno.pl.copy_number_violin#

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

Plot copy-number distribution across sample groups as a violin plot.

Parameters:
  • adata (AnnData) – Annotated data with copy-number information.

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

  • motif (str | int | None) – If None, the total copy number per sample (adata.obs["copy_number"]) is used. If str, the motif is looked up in adata.var.index first, then in adata.var["motif"], and the matching column from adata.X is used. If int, adata.X[:, motif] is used directly.

  • 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 (dict[str, str] | list[str] | str | None) – Colormap for the violins. If a str, it is looked up in the module and plotly default colormap options. If a list of color strings, used directly. If a dict, keys are group names and values are color strings. If None, the module default rainbow colormap is used.

  • 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 the violin plot.

Return type:

Figure

Examples

>>> import vampire as vp
>>> vp.anno.pl.set_default_plotstyle()
>>> adata = vp.datasets.wdr7_hprc()
>>> vp.anno.pl.copy_number_violin(adata, group_by="haplotype")
>>> vp.anno.pl.copy_number_violin(adata, group_by="ancestry", motif=0)