Fix #755: calculate marker positions from DataFrame, not rendered labels#970
Conversation
…red labels Previous approach extracted tick labels from the rendered plot, which failed when seaborn hid labels (small figsize, many genes, or explicit xticklabels=False). New approach calculates positions directly from DataFrame structure: - Seaborn places cell centers at 0.5, 1.5, 2.5, etc. - Works regardless of label visibility - Faster (no DOM extraction) - Immune to matplotlib rendering changes Test updated to actually reproduce the bug (50 genes + small figsize).
Gemini review noted that position calculation assumes non-clustered heatmap. If future maintainer changes to clustermap, marker positions would be wrong. Added comment to make this assumption explicit.
|
Rebased onto main, conflicts resolved. This supersedes #966 which was closed during the rebase. The approach here is different from #965: instead of forcing tick labels on (which breaks if a user explicitly hides them), this calculates marker positions directly from the DataFrame. Works regardless of label visibility. |
|
There's test failures now: could you please also ensure that LLM comments that aren't helpful and/or noisy are kept to a minimum? Thank you! |
plot_multicomparison_fc uses **heatmap_kwargs, so xticklabels must be passed as a keyword argument, not inside a dict.
|
Fixed. All 3 parametrized variants pass. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #970 +/- ##
==========================================
- Coverage 73.54% 71.85% -1.69%
==========================================
Files 48 48
Lines 5613 5731 +118
==========================================
- Hits 4128 4118 -10
- Misses 1485 1613 +128
🚀 New features to boost your workflow:
|
Could you please address these comments? Thank you! |
|
The new The two red |
|
Thanks! Don't worry about the failing unrelated tests. Am I stupid or is the before & after switched? We'd expect to see the x-tick labels right? |
|
@Zethson silly mistake 🤪 Also added ! for easier viewing |
Follow-up to #965 (merged). Supersedes #966 (closed due to branch recreation during rebase).
#965 fixed the immediate crash by forcing tick labels on, but this still breaks if a user passes
xticklabels=Falseviaheatmap_kwargs. This PR removes the dependency on rendered tick labels entirely.Before:

After:

Changes: