Keep Sashimi junction counts visible when zoomed in (#1514) - #1874
Merged
Merged
Conversation
The label sat at the mid point of the arc, which is off screen once both ends are, so zoomed in views showed no counts (#1514). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Junction depth labels disappeared from the Sashimi plot at high zoom. Addresses #1514.
Cause
The label is drawn at the mid point of the arc in pixel space:
Zoom in far enough and both ends of a junction are off screen — in the issue's example the view is a few bases wide — so the mid point is off screen too and the count is drawn outside the visible area. The arc itself still crosses the view, so you see the junction but not its depth.
Fix
When the mid point falls outside the track rectangle but part of the arc is visible, the label is placed at the mid point of the visible stretch, at the matching point on the curve. Behaviour is unchanged whenever the mid point is already on screen.
Two small helpers do the geometry. Both control points of the arc sit directly above its ends, so x depends only on them:
which is monotonic, so
arcParameterAtXbisects it, andarcYevaluates the curve there.arcY(0.5, ...)reproduces the peak height the renderer has always used, so nothing shifts in the common case.This applies to the circle and ellipse shape options as well, since they are positioned from the same point.
Testing
test/data/bam/sashimi-test/heart.bam(hg19, SLC25A3), before and after the change, by overlaying the previous version of the renderer on the classpath:chr12:98,989,700-98,990,000(300 bp, inside an intron, so every junction's mid point is off screen) three arcs cross the view. Before: no labels at all. After: 275, 135 and 7, each on the visible stretch of its arc.chr12:98,986,000-98,998,500) renders byte identically before and after, confirming the unchanged path.Worth noting: with several long junctions in view at high zoom, their visible mid points cluster near the centre of the window, so labels can sit close together. Staggering or dropping colliding labels would be a reasonable follow up if that proves noisy in practice.
🤖 Generated with Claude Code