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 inX.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.motifs (
Union[str,Sequence[str],None]) – Motif(s) to visualise. IfNone, all motifs inadataare used. If more than 30 motifs are selected a warning is emitted. A singlestror a list/sequence of motif IDs / sequences is accepted.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 (
Union[str,Sequence[str],None]) – Colormap for the median-based violin fill. If astr, it is passed toplotly.colors.sample_colorscale(e.g."Viridis","Plasma"). If a sequence of hex/rgb strings, used directly. IfNone, 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) – 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 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"] ... )