vampire.anno.pl.waterfall_legend#
- vampire.anno.pl.waterfall_legend(adata, feature='motif', sample_order=None, color='id', colormap='rainbow', figsize=(None, None), track_name_dx=-0.01, save=None, **kwargs)[source]#
Create a legend figure for the waterfall plot.
Displays colored squares alongside their corresponding motif sequences (or color-column values) in a separate figure. The order and coloring are consistent with vp.anno.pl.waterfall().
- Parameters:
adata (
AnnData) – Annotated data object generated from pp.read_anno().feature (
str) – Key prefix for the feature arrays stored inadata.uns. The function looks upuns[f"{feature}_array"]anduns[f"{feature.replace('motif', 'orientation')}_array"]. Common values:"motif"(raw arrays),"aligned_motif"(alignment output fromvp.anno.tl.sample_msa()).sample_order (
list[str] |None) – Unused in legend, kept for API consistency with waterfall().color (
str) – Column name in adata.var used to assign coloring. Whencolor="id", legend labels show motif ids; otherwise labels show values from the specified column.colormap (
dict|list|str) – Color mapping specification. Must match the colormap used in the corresponding waterfall() call for consistent coloring.figsize (
tuple[int|None,int|None]) –Figure size as (width, height) in pixels. Default is (None, None).
(None, None): auto-compute both dimensions from data.
(w, None): fixed width, auto-compute height from element count.
(None, h): fixed height, auto-compute width from label length.
(w, h): use user-specified size.
track_name_dx (
float) – Unused in legend, kept for API consistency with waterfall().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 keyword arguments passed to Plotly update_layout.
- Returns:
fig – Plotly figure object with colored squares and their labels.
- Return type:
Figure
Examples
>>> import vampire as vp >>> vp.anno.pl.set_default_plotstyle() >>> adata = vp.datasets.wdr7_hprc() >>> vp.anno.pl.waterfall_legend( ... adata, ... color = "motif", ... colormap = "rainbow", ... )