Skip to content

fix(pl): plotting fixes from the 0.7.0 review - #218

Merged
timtreis merged 8 commits into
mainfrom
fix/review-plotting
Nov 15, 2026
Merged

timtreis merged 8 commits into
mainfrom
fix/review-plotting

Conversation

@timtreis

Copy link
Copy Markdown
Member

Summary: The second of three PRs with fixes from the review of the 0.7.0 refactor. This one covers the plotting functions.

Changes:

  • The legacy heatmap passes scanpy an AnnData instead of a view.
  • Chromosome heatmaps save the way scanpy's savefig_or_show does.
  • pl.spatial_cnv saves the figure once and draws the tissue the way sc.pl.spatial does.
  • The fast heatmap dendrogram and standard_scale='var' now match the legacy output.
  • The heatmap dendrogram is computed from the window covariance on every call and stored in uns, and the docs describe how. scanpy no longer warns about a PCA fallback.
  • Group labels are thinned with matplotlib's FixedFormatter instead of custom code.

Testing: the full test suite passes on the cluster (679 passed, 12 skipped).

scanpy then stores the group colours it picks in the caller's uns, as in
0.6.1, without an ImplicitModificationWarning or another dense copy.
save='.png' wrote heatmap.png.pdf and save='' saved nothing in the fast
mode. A saved figure is now closed unless it is returned or drawn into a
given ax, as in 0.6.1. Legacy mode saves through the same code, so
autosave no longer overwrites the heatmap with a blank figure and
save=True no longer raises scanpy's FutureWarning.
sc.pl.embedding no longer saves (with autosave it closed the figure, and
the second save wrote a blank image); saving and showing go through the
heatmap's code, so save=True does not raise scanpy's FutureWarning.
Region panels are found by position, so title= keeps their colour bar
label, and only they are centred at 0. The panels have an equal aspect
and the y axis pointing down, as sc.pl.spatial draws them without an
image.
The dendrogram is now scanpy.tl.dendrogram with its defaults, as legacy
and 0.6.1 compute it: with more windows than N_PCS, from the group means
of a PCA of all cells, not of the raw group means. For a lazy matrix the
PCA comes from the covariance of the windows in one pass. The summary
clusters every group mean 10 times in name order, as legacy does.
standard_scale='var' scales each window with its minimum and maximum
over all cells instead of the drawn rows.
The message tells the caller of scanpy.tl.dendrogram to set use_rep,
which does not apply to chromosome_heatmap.
The fast heatmaps now compute the PCA behind scanpy's dendrogram from the
covariance of the windows in one pass for all matrices, not only lazy
ones, instead of running scanpy's PCA on a copy of the cells. The group
order matches legacy. The result is stored in
uns['dendrogram_<groupby>'] as scanpy.tl.dendrogram writes it, as legacy
does, so later calls (also legacy ones) reuse it.
@codecov-commenter

codecov-commenter commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.62%. Comparing base (ea800d5) to head (b2bd6d9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #218      +/-   ##
==========================================
+ Coverage   93.17%   93.62%   +0.45%     
==========================================
  Files          21       21              
  Lines        1611     1631      +20     
==========================================
+ Hits         1501     1527      +26     
+ Misses        110      104       -6     
Files with missing lines Coverage Δ
src/infercnvpy/pl/_chromosome_heatmap.py 96.90% <100.00%> (+0.42%) ⬆️
src/infercnvpy/pl/_chromosome_heatmap_legacy.py 100.00% <100.00%> (+5.40%) ⬆️
src/infercnvpy/pl/_heatmap_kernels.py 98.80% <100.00%> (+0.37%) ⬆️
src/infercnvpy/pl/_spatial.py 92.72% <100.00%> (+1.49%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis
timtreis merged commit 2d9233b into main Nov 15, 2026
12 checks passed
@timtreis
timtreis deleted the fix/review-plotting branch November 15, 2026 04:48
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.

2 participants