Skip to content

fix: render heatmap metadata colour bars - #21

Merged
eilidhmacnicol merged 3 commits into
mainfrom
fix/heatmap-colour-bars
Jun 4, 2026
Merged

fix: render heatmap metadata colour bars#21
eilidhmacnicol merged 3 commits into
mainfrom
fix/heatmap-colour-bars

Conversation

@eilidhmacnicol

Copy link
Copy Markdown
Contributor

Goal 5 — complete a half-wired feature (pre-1.0 bug fix)

plot_lv_heatmap and plot_bootstrap_heatmap pass row_colors/col_colors (the --x-meta/--y-meta category colours) into plot_heatmap, but plot_heatmap builds the figure with sns.heatmap, which has no row/column colour-bar support — so the colours were silently dropped and the metadata colour-coding never appeared on --all-plots heatmaps. This completes the wiring rather than removing it.

Approach

When colour bars are requested, render them via sns.clustermap(row_cluster=False, col_cluster=False, row_colors=..., col_colors=...) — a non-clustered heatmap that does support colour strips, with the empty dendrogram axes hidden. The diverging vlag scale, symmetric [-v, v] range, and annotation-suppression behaviour are preserved.

Heatmaps without metadata are unchanged — they keep the original sns.heatmap path (used by the cross-correlation heatmap and metadata-free bootstrap heatmaps). Only the previously-broken colour-bar path changes.

Changes

  • plotting.plot_heatmap: branch to a new _heatmap_with_colour_bars helper when row_colors/col_colors are present.
  • Docs: note the colour bars in docs/usage.md; CHANGELOG fix entry.

Tests (written first, watched fail)

  • test_plotting: LV heatmap renders both row and column colour bars; bootstrap heatmap renders a row colour bar only (columns are LVs, no metadata); the no-colour path does not invoke clustermap (behaviour-unchanged guard). Assertions check the colour-bar axes actually drew artists, not just that a file was written.

All tests pass; ruff clean; coverage 97.8% (floor 95%). Verified the output visually — the row/column category bars render with the correct colours.

🤖 Generated with Claude Code

@eilidhmacnicol
eilidhmacnicol force-pushed the fix/heatmap-colour-bars branch from 71eae5c to 1be0a60 Compare June 4, 2026 13:19
@eilidhmacnicol
eilidhmacnicol merged commit 674181b into main Jun 4, 2026
4 checks passed
@eilidhmacnicol
eilidhmacnicol deleted the fix/heatmap-colour-bars branch June 4, 2026 13:23
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