Skip to content

Fix plot_multicomparison_fc with default figsize#966

Closed
kimjune01 wants to merge 3 commits into
scverse:mainfrom
kimjune01:fix-plot-multicomparison-fc-755
Closed

Fix plot_multicomparison_fc with default figsize#966
kimjune01 wants to merge 3 commits into
scverse:mainfrom
kimjune01:fix-plot-multicomparison-fc-755

Conversation

@kimjune01
Copy link
Copy Markdown
Contributor

Fixes #755.

Seaborn heatmap suppresses tick labels when the figure is too narrow, causing plot_multicomparison_fc to crash with ValueError when trying to position significance markers (the code looks up gene names in x_labels, but those labels are missing).

This sets xticklabels=True and yticklabels=True as defaults so tick labels are always visible. Users can still override via heatmap_kwargs if needed.

Also adds a comment noting that the marker positioning assumes a non-clustered heatmap (if a future maintainer switches to clustermap, marker positions would be wrong).

kimjune01 added 3 commits May 11, 2026 12:11
Fixes scverse#755

The function failed when seaborn's heatmap didn't display tick labels
(which happens with certain figsize values). This occurred because the code
assumed tick labels would always be present when plotting significance markers.

The fix ensures xticklabels=True and yticklabels=True are set by default,
while still allowing users to override via heatmap_kwargs.

Changes:
- Set default xticklabels=True and yticklabels=True in heatmap call
- Add regression test for default figsize behavior
…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.
@Zethson
Copy link
Copy Markdown
Member

Zethson commented May 12, 2026

Could you please fix the merge conflicts? Thank you

@kimjune01 kimjune01 closed this May 12, 2026
@kimjune01 kimjune01 deleted the fix-plot-multicomparison-fc-755 branch May 12, 2026 09:15
@kimjune01
Copy link
Copy Markdown
Contributor Author

Closed during rebase (branch delete + recreate). Replaced by #970.

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.

buggy defaults for plot_multicomparison_fc

2 participants