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 inadata.obsused to group samples. If it is None, plot without groupinggroup_order (
Optional[Sequence[str]]) – Explicit order for the groups on the x-axis. IfNone, groups are sorted alphabetically.motif (
str|int|None) – IfNone, the total copy number per sample (adata.obs["copy_number"]) is used. Ifstr, the motif is looked up inadata.var.indexfirst, then inadata.var["motif"], and the matching column fromadata.Xis used. Ifint,adata.X[:, motif]is used directly.log (
bool) – Whether to applylog1ptransform 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) – IfTrue, 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 astr, 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. IfNone, the module default rainbow colormap is used.figsize (
tuple[int|None,int|None]) – Figure size in pixels.save (
str|bool|None) – IfTrueor astr, 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)