Restore y-axes for non-default plotting directions and fix the linear fixture padding - #191
Merged
Conversation
db616d9 added a guard to add.axes(): if (plotting.direction != 'down') { message('Non-vertical plotting direction detected; skipping (nSNV) x-axis rendering.'); yaxis.position <- 'none'; } Its stated goal was to drop the nSNV axis on horizontal fish plots, but it had three problems: * The comment and message say "x-axis" while the body sets yaxis.position, which removes the Y-axes. The x-axis is controlled separately by draw.xaxis on the line above. * It fired for every plotting.direction other than 'down', not just horizontal ones. * `plotting.direction != 'down'` compares numeric against character, so R coerced 30 to "30" and numeric angles tripped it as well. Measured on a tree with two length columns, axis count went from 2 to 0 for 'up', 'left', 'right', 30 and 45, leaving only 'down' with any y-axis at all. plotting.direction is a 3.0.0 feature, so this removed the scale from every non-default orientation. It also broke test-linear.R's 30-degree case with a subscript-out-of-bounds error, because the comparison walks a grob list whose length had changed. Replace it with the narrow behaviour that was intended: when a fish plot is drawn horizontally, demote yaxis.position from 'both' to 'left' so only the second (nSNV) scale is dropped. Add is.horizontal.direction() to classify named and numeric directions without string coercion, and thread add.polygons through from make.clone.tree.grobs so the suppression is scoped to fish plots rather than to orientation alone. test-axis-plotting-direction.R covers all six directions, the numeric-vs-named equivalence, the horizontal fish plot keeping its first y-axis, and a non-fish horizontal tree keeping both. Note: fish.data.Rda has no length columns, so it cannot exercise the nSNV suppression; the test builds a tree that has both CP and two length columns.
test-linear.R built its plot with horizontal.padding = -1. That squeezed the plot area until the gene annotations collapsed into unreadable coloured specks and the axis tick labels crowded over the polygon -- the "test plots are not right" symptom in issue #186. The fixture was the only place a negative horizontal padding was exercised, so nothing else caught it. Sweeping the parameter shows -1 and 0 both crush the annotations, 1 and 2 render them cleanly outside the polygon, and 3 pushes the axis titles off the edge. Use 1, which keeps the pre-#190 layout (PGA left, SNV right, ticks outside the plot) while leaving space between the polygon and the axes. The gene labels TP53/CDKN2A/CSMD1/FHIT/TERT/MYC and NOTCH1/SOX2/TP63/PIK3CA/EGFR are legible again. Regenerate the snapshots. Comparing every stored grob against its predecessor with compare.trees confirms only two changed: linear.example (this padding change) and fish.example (the CCF axis is now flush with the polygon rather than overhanging it, which is what "make axes flush against polygon" in #190 set out to do). The other nine are unchanged, so the regeneration accepted nothing silently. Two fixes to update-snapshots.R were needed to run it at all: * pkg.root used dirname(sys.frame(1)$ofile), which only resolves under source(). Invoked the documented way -- Rscript tests/update-snapshots.R -- sys.frame(1) raised "not that many frames on the stack" and the script died before loading the package. Resolve the path from --file= first, fall back to sys.frames()[[1]]$ofile, then getwd(). * Swap devtools::load_all for pkgload::load_all. devtools is not in Suggests and merely re-exports load_all from pkgload.
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.
main is currently red.
devtools::test()on9acc0c4gives 310 pass / 2 fail / 1 error. This gets it to 337 pass / 0 fail / 0 error.Why it broke
Commit
db616d9(PR #190) added a guard toadd.axes():Three problems:
yaxis.position, removing the y-axes. The x-axis is controlled separately bydraw.xaxison the line above.plotting.directionother than'down', not just horizontal ones.plotting.direction != 'down'compares numeric against character, so R coerces30to"30"and numeric angles trip it too.Measured on a tree with two length columns:
downup/left/right30/45plotting.directionis a 3.0.0 feature, so every non-default orientation lost its scale. It also broketest-linear.R's 30-degree case with a subscript-out-of-bounds error, becausecompare.treeswalks a grob list whose length had changed.This was not caught because the
R CMD checkworkflow has beendisabled_inactivitysince 2026-04-06, and PR #190 was opened 2026-05-18. It was never checked by CI.mergeable: cleanonly ever meant "no merge conflict".What this PR does
e628e4areplaces the guard with the narrow behaviour that was intended. Addsis.horizontal.direction()to classify named and numeric directions without string coercion, threadsadd.polygonsthrough frommake.clone.tree.grobsso suppression is scoped to fish plots rather than orientation alone, and demotesyaxis.positionfrom'both'to'left'so only the second (nSNV) scale is dropped.test-axis-plotting-direction.Rcovers all six directions, numeric-vs-named equivalence, a horizontal fish plot keeping its first y-axis, and a non-fish horizontal tree keeping both. Notefish.data.Rdahas no length columns (get.y.axis.positionreturns'none'), so it cannot exercise the nSNV suppression — the test builds a tree with bothCPand two length columns.aac2e67fixes the linear fixture. It usedhorizontal.padding = -1, which squeezed the plot until the gene annotations collapsed into unreadable specks and the tick labels crowded over the polygon — the "test plots are not right" symptom in #186. Sweeping the parameter:-1and0crush the annotations,1and2render them cleanly,3pushes the axis titles off the edge. Uses1, keeping the pre-#190 layout (PGA left, SNV right, ticks outside) with space between polygon and axes.TP53/CDKN2A/CSMD1/FHIT/TERT/MYCandNOTCH1/SOX2/TP63/PIK3CA/EGFRare legible again.Snapshots regenerated. Comparing every stored grob against its predecessor with
compare.treesconfirms only two changed semantically:linear.example(this padding change) andfish.example(the CCF axis is now flush with the polygon instead of overhanging, which is what "make axes flush against polygon" in #190 set out to do). The other nine are unchanged, so the regeneration accepted nothing silently.Two fixes to
update-snapshots.Rwere needed to run it at all:pkg.rootuseddirname(sys.frame(1)$ofile), which only resolves undersource(). Invoked the documented way —Rscript tests/update-snapshots.R—sys.frame(1)raisednot that many frames on the stackand the script died before loading the package. Now resolves--file=first, falling back tosys.frames()[[1]]$ofile, thengetwd().devtools::load_all→pkgload::load_all.devtoolsis not inSuggestsand only re-exportsload_allfrompkgload.Verification
Run in a container built from
ghcr.io/uclahs-cds/boutroslabplottinggeneral:7.1.0plus testthat/pkgload/covr/knitr/rmarkdown/withr, sinceR CMD checkis still disabled.Not addressed here
Pre-existing, reproduces on pre-#190
ab3359f, out of scope:plotting.direction = 'left'produces two grobs both namedaxis.left.plotting.direction = 'up'silently loses its left y-axis with aNo y-axis ticks to drawwarning.CPx-axis label still overlaps its0.53%tick — part of the Disproportionate y-axis2 to y-axis2 label spacing #183 cluster.Suggest re-enabling the
R CMD checkworkflow once this merges, so its first run lands green.Refs #186