Skip to content

Flip feature text on juicebox y-axis tracks - #2118

Merged
turner merged 2 commits into
masterfrom
issue-2117-y-axis-track
Oct 15, 2026
Merged

turner merged 2 commits into
masterfrom
issue-2117-y-axis-track

Conversation

@turner

@turner turner commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2117

Summary

juicebox transposes y-axis tiles, which mirrors any text baked into them. The sequence track already pre-flips its letters for this. The feature track now does the same for feature names and amino-acid letters, flipping each about its own center so it stays on its feature.

 renderFeature(feature, ..., options)
   renderAminoAcidSequence(..., sequenceInterval, options.axis)
     renderAminoAcidLetter
+      if axis === 'y': flip about the codon's center
       fillText(letter)
   renderFeatureLabel(..., options)
+    if options.axis === 'y': flip about the label's center
     fillText(name)

Evidence

New test/testRenderFeature.js drives renderFeature with a fake 2D context that tracks the transform and records each drawn glyph's anchor and horizontal scale.

feature at pixels 100-300, axis 'y'  →  label scaleX -1, anchored at 200 (center)
ATG TAA at 10 px/bp,       axis 'y'  →  "M" scaleX -1 at 18, "*" scaleX -1 at 48 (flipped about codon centers 15, 45)
no axis                              →  scaleX 1, unchanged
  • Before: label is mirrored about its center on a y-axis track failed with expected 1 to equal -1, and amino acids are mirrored about their centers on a y-axis track failed with expected [ 'M', 1, 12 ] to deeply equal [ 'M', -1, 18 ].
    After: 4/4 pass, and the full suite passes (319).

Checked by eye in juicebox, with its igv dependency pointed at this branch: y-track text renders correctly.

Merge Danger

Door: two-way

A revert restores the old rendering.

Blast Radius: juicebox-only

The new code runs only when options.axis === 'y', which only juicebox sets. igv.js itself never passes axis, so its rendering and SVG export are unchanged. The flip uses only translate and scale, which canvas2svg supports.

🤖 Generated with Claude Code

turner and others added 2 commits October 15, 2026 13:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turner
turner merged commit b5d6480 into master Oct 15, 2026
2 checks passed
@turner
turner deleted the issue-2117-y-axis-track branch October 15, 2026 18:06
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.

Feature names are mirrored on juicebox y-axis tracks

1 participant