Conversation
… row_colors matches heatmap zoom coordinates
…sync by matching yaxis9 and xaxis3
|
Hi @HammadTheOne, would it be possible to have this PR reviewed? Thank you very much! |
| tickvals=[], | ||
| ticktext=[] | ||
| ) | ||
| fig["layout"]["xaxis6"].update( |
There was a problem hiding this comment.
I believe only xaxis7 needs to be updated for this.
| showticklabels=True, | ||
| side="right", | ||
| showline=False, | ||
| ticks="", |
There was a problem hiding this comment.
Is there a reason that we're hiding tick marks here while having showticklabels=True? Was this intended for this PR?
On a similar note, showgrid and fixedranged are also set via https://github.com/JTL-lab/dash-bio/blob/d83da34b11f41902b29e6d617f791180f65d0f1c/dash_bio/component_factory/_clustergram.py#L525 🙂
| # with the heatmap and dendrograms zoom synchronously | ||
| yaxis9 = fig["layout"]["yaxis9"] # pylint: disable=invalid-sequence-index | ||
| yaxis9.update(scaleanchor="y11") | ||
| yaxis9.update(scaleanchor="y11", matches="y11") |
There was a problem hiding this comment.
Plotly.js silently drops scaleanchor when matches is also set on the same axis. We can simplify it to just matches="y11" / matches="x11".
Same with on line 565.
|
Hi @HammadTheOne, thank you for your review! I've addressed your feedback in my latest commit. Please let me know if anything else is needed! |
Overview
Closes #780 and closes #778 related to bugs with Clustergram zooming behavior.
About
Description of changes
This PR fixes two related zoom synchronization bugs in the Clustergram component:
1. Fix column_colors and row_colors zoom synchronization
Problem: When zooming into a region of the heatmap, the
column_colorsandrow_colorsannotation bars were remaining at their original scale rather than zooming in to match the selected region. This made it impossible to identify which color annotations corresponded to the zoomed cells (Issue #780).Solution Implemented:
_get_row_colors_heatmap()and_get_column_colors_heatmap()to accepttickvalsparameters and use the same coordinate system as the main heatmap.matchesparameter to link color heatmap axes (xaxis6, xaxis7 for column colors; yaxis10 for row colors) with the main heatmap axes (xaxis11, yaxis11).2. Fix dendrogram zoom synchronization
Problem: When zooming into the heatmap, the dendrograms would zoom, but display an incorrect portion of the dendrogram not actually corresponding to the selected heatmap region, as thoroughly documented with examples in Issue #778.
Solution:
matchesparameter to dendrogram axes in addition to the existingscaleanchorparametermatches="y11"to synchronize with heatmap y-axismatches="x11"to synchronize with heatmap x-axisTechnical details: The key difference is that
scaleanchoronly maintains the scale/aspect ratio between axes, whilematchesensures axes share the same coordinate system and zoom level. Both are needed for dendrogram zooming to work properly:scaleanchorensures proper visual alignment andmatchesis necessary for synchronized zooming.Example and screenshots
Example Clustergram:
Before fixes:

After fixes:
