Skip to content

0.1.1b3: cn_palette option with a cnamaste (a, b) palette - #2

Merged
RunpengLuo merged 1 commit into
mainfrom
dev
Nov 12, 2026
Merged

RunpengLuo merged 1 commit into
mainfrom
dev

Conversation

@RunpengLuo

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a second palette for (a, b) copy-number states, "cnamaste", taken from cnamaste.palette.COPY_STATES: hue by minor-allele fraction, darker for more copies. The existing palette is now named "hatchet" and remains the default, so current calls and output are unchanged.
  • cn_palette= is accepted by get_cn_cmap, get_mixcn_cmap and plot_cnv_profile (which passes it to its key). plot_scatter_1d_multisample and plot_heatmap_cnp forward it through their profile kwargs.
  • CN_PALETTES = ("hatchet", "cnamaste") is exported for use as argparse choices. An unknown name raises ValueError.
  • States a palette does not list take the default color. The key's overflow box is labelled from the palette: >7 under "hatchet", >6 under "cnamaste".
  • examples/plot_gallery.py takes --cn_palette {hatchet,cnamaste} and --outdir.
  • Version 0.1.1b3.

Usage

Pass the same palette to the scatter colors and the profile so points, profile and key agree:

palette = get_mixcn_cmap(cnps, cn_palette="cnamaste")
plot_cnv_profile(ax, seg_df, genome_axis, ax_leg=ax_leg, cn_palette="cnamaste")

Not included

cnamaste's FLIP_OPACITY (B > A drawn at half opacity) and TRACK_NORMAL ((1, 1) shown as steelblue on scatter tracks) are not ported. (a, b) and (b, a) still share one color, and mixed phase is still marked by the "/" hatch.

Test plan

  • ruff format --check and ruff check are clean
  • pytest: new tests cover the default palette, the cnamaste colors and coverage, the unknown-name error, get_mixcn_cmap under cnamaste, and the profile and key under cnamaste
  • Gallery rendered with the default palette is pixel-identical to the committed examples/*.png

- New "cnamaste" palette for (a, b) states, from cnamaste.palette.COPY_STATES:
  hue by minor-allele fraction, darker for more copies. The existing palette
  is named "hatchet" and stays the default.
- cn_palette= on get_cn_cmap, get_mixcn_cmap and plot_cnv_profile (passed on
  to its key); the figure helpers forward it through profile_kwargs.
- CN_PALETTES lists the names, for an argparse choices; an unknown name
  raises ValueError.
- The key's overflow box is labelled from the palette: >7 under hatchet,
  >6 under cnamaste.
- examples/plot_gallery.py takes --cn_palette {hatchet,cnamaste} and --outdir.
- Version 0.1.1b3.
@RunpengLuo
RunpengLuo merged commit b20e89a into main Nov 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant