Repository navigation
Download the global heatmap as a PNG or SVG - #193
Merged
Merged
Conversation
A user who downloads the painted diagram for reports asked how to download the heatmap too: the only way was a screenshot, which keeps what fits on the screen, not a heatmap a few hundred rows tall or all its omics at once. The panel's Download button had sat commented out for years over a download() that threw "Not implemented". The button is now live, labelled like the diagram's, and offers a high-resolution PNG (3x, scaled down only past what a canvas can hold) or an editable SVG. Highcharts' exporter could not do this - one chart per omic, headings and colour scales drawn in HTML around them, row labels and stars drawn in HTML over them - so the figure is rebuilt in the browser as one standalone SVG: each chart's own SVG verbatim, the HTML around it re-written as SVG text, stars and gradients, omics laid side by side, on white in either theme. Row labels and condition names are written out in full where the panel truncates them, and a key explains the stars the figure uses. The button's tooltip is closed when the menu opens: it is interactive and opened exactly over the PNG item, taking its click. Verified in Chrome on a five-omic job (light and dark, with and without Force order) and on the three-group tutorial data with per-contrast stars; both files download, and an oversized PNG is refused with a pointer to the SVG. Docs: the Heatmaps page said there was no download; it, the diagram page, the FAQ table and the three-group tutorial now describe it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l characters An independent review of the export found four defects, each reproduced and fixed: - The row-under-the-pointer outline was exported. Nothing hides it when the pointer leaves, so hovering a row on the way to Download framed that row in every omic of the figure. The live outline is tagged before the clone and dropped from it. - A tall heatmap came out below screen size without a word: the 16,000 px side cap pushed a ~600-row figure to 0.88x and a very tall one to 0.26x (9px labels at 2px), still saved as a success. The side cap is now Chrome's real ~32,000 px, and a figure that does not fit at 1x is refused before the spinner with a pointer to the SVG. - With Force order an omic's charts stack in one column, and the full condition names of an upper chart ran under the next chart's white background. Only a chart with nothing stacked under it gets full names. - A C0 control character in a name (a vertical tab, a DOS end-of-file) is legal in a TSV and illegal in XML 1.0, and made the SVG unparseable; they are stripped from everything the export writes. A throw while drawing the PNG now reaches the caller, instead of leaving its spinner up, and that failure no longer claims the heatmap is too large. Verified in Chrome on the three-group job with Force order: no outline in the file while it stays on the page, short names on the stacked chart and full ones on the bottom charts, the refusal message before any spinner. 28 tests, each new one mutation-checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Member
Author
Review recordAutomated review.
Independent review (a separate agent over 11cc7bc). Four defects, all fixed in 4798341, each with a test that was mutation-checked, and each verified in Chrome:
Gate is green on 4798341. Merging with the owner's go-ahead. |
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.
Why
A user who downloads the painted diagram for their reports asked how to download the heatmap as well. The only way was a screenshot, which keeps whatever fits on the screen: not a heatmap a few hundred rows tall, and never all the omics at once. The Global heatmap panel's Download button had been sitting commented out over a
download()that threw"Not implemented".What
PA_Step3Views.js, shared heatmap helpers):paCollectHeatmapFigurereads each chart's own SVG verbatim and re-writes the surrounding HTML (omic headings, colour ramps, zero ticks, separators, row labels, relevance and per-cell stars) as SVG.paHeatmapFigureSVGserialises that description (pure, unit-tested under node).paRasteriseSVGdraws it on a canvas for the PNG.useHTML.Verified in Chrome (local server, this branch)
TrtA_vs_Ctrl-style column names.~/Downloadsaspaintomics_heatmap_<pathway>_<jobID>.png/.svg.Known and unchanged: with Force order, a secondary omic carrying several rows per gene (miRNA) is squeezed into the reference omic's row height and its labels overlap. That happens on screen already, and the export reproduces it faithfully.
Tests
test_heatmap_figure_export.py(21 tests): static guards on the button, menu, tooltip and teardown; node-run checks that the SVG is well-formed, escaped, translated into its margin, embeds the chart verbatim, uses no web font, carries real gradients, sizes for the title and key, has safe file names and capped PNG scales.test_heatmap_axis_and_labels,test_heatmap_colour_and_column_spaceandtest_versioned_assets_are_bumpedpass; ESLint, ruff, the vulture gate (two decorated test classes added to the baseline, as for the other heatmap suites) andmkdocs build --strictare clean.🤖 Generated with Claude Code