Skip to content

Keep Sashimi junction counts visible when zoomed in (#1514) - #1874

Merged
jrobinso merged 1 commit into
mainfrom
sashimi-zoomed-junction-labels
Sep 16, 2026
Merged

jrobinso merged 1 commit into
mainfrom
sashimi-zoomed-junction-labels

Conversation

@jrobinso

Copy link
Copy Markdown
Contributor

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:

float midX = ((float) pixelJunctionStart + (float) pixelJunctionEnd) / 2;

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:

x(t) = start + (end - start) * t^2 * (3 - 2t)

which is monotonic, so arcParameterAtX bisects it, and arcY evaluates 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

  • Existing tests in the sashimi, renderer, track and alignment packages pass (130 tests, 19 skipped, 0 failures).
  • Checked visually by painting the plot offscreen with 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:
    • At 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.
    • The whole gene view (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

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>
@jrobinso
jrobinso merged commit dc545b8 into main Sep 16, 2026
2 checks passed
@jrobinso
jrobinso deleted the sashimi-zoomed-junction-labels branch September 16, 2026 21:25
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.

1 participant