fix: support ggplot2 v4.0.0 for ComplexHeatmap plots#205
Conversation
Agent-Logs-Url: https://github.com/CCBR/MOSuite/sessions/1de03834-a603-4a38-a1a3-ce94ecbdf07c Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #205 +/- ##
==========================================
+ Coverage 79.58% 79.63% +0.04%
==========================================
Files 22 22
Lines 3375 3398 +23
==========================================
+ Hits 2686 2706 +20
- Misses 689 692 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kelly-sovacool
left a comment
There was a problem hiding this comment.
- The ggplot2 version pin should be removed from the DESCRIPTION file:
Line 32 in 9977c74
- The CI workflows can be changed back to use
r-lib/actions/setup-r-dependenciesinstead ofCCBR/actions/install-r-pak:MOSuite/.github/workflows/R-CMD-check.yaml
Lines 35 to 41 in 9977c74
…ctions, add caption support for ComplexHeatmap Agent-Logs-Url: https://github.com/CCBR/MOSuite/sessions/89b38b5a-99e6-49bd-b699-4b0f32c262da Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Done in commit
|
kelly-sovacool
left a comment
There was a problem hiding this comment.
Add or update the tests to ensure the code changes are covered
…tmap handling Agent-Logs-Url: https://github.com/CCBR/MOSuite/sessions/94a2813b-8364-44ec-b39b-3603a8d1fa80 Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CCBR/MOSuite/sessions/94a2813b-8364-44ec-b39b-3603a8d1fa80 Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Added tests in commit
|
kelly-sovacool
left a comment
There was a problem hiding this comment.
Can anything be done to improve the tests in test-plots.R so they do more than merely check that the code ran without error?
…e assertions Agent-Logs-Url: https://github.com/CCBR/MOSuite/sessions/5a97fa80-deb1-4e4b-92eb-fc16e1d7e547 Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
Updated in commit |
unreliable behavior on different platforms
no longer need install-r-pak since we can use the latest ggplot2 here
…BR/MOSuite into copilot/support-ggplot2-v4-0-0
…BR/MOSuite into copilot/support-ggplot2-v4-0-0
There was a problem hiding this comment.
Pull request overview
This PR updates MOSuite plotting to handle ComplexHeatmap correlation heatmaps with ggplot2 4.x while removing the prior ggplot2 version cap.
Changes:
- Adds caption handling and explicit
ComplexHeatmap::draw()support inprint_or_save_plot(). - Updates filter, normalization, and batch-correction workflows to pass heatmap captions without adding ggplot layers to ComplexHeatmap objects.
- Removes ggplot2 version pins and updates tests, CI setup, metadata, Dockerfiles, and NEWS.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
R/plots.R |
Adds caption support and ComplexHeatmap-specific print/save handling. |
R/filter.R |
Updates filtered-count correlation heatmap caption handling. |
R/normalize.R |
Updates normalized-count correlation heatmap caption handling. |
R/batch-correction.R |
Updates batch-corrected correlation heatmap caption handling. |
tests/testthat/test-plots.R |
Adds print/save coverage for ggplot and ComplexHeatmap captions. |
tests/testthat/test-plot_volcano_enhanced.R |
Skips one snapshot test on CI. |
DESCRIPTION |
Bumps package version and removes ggplot2 upper bound. |
codemeta.json |
Syncs package version metadata. |
CITATION.cff |
Syncs package version and ggplot2 dependency metadata. |
NEWS.md |
Adds changelog entry for ggplot2 4.x heatmap support. |
man/print_or_save_plot.Rd |
Updates generated documentation for the new caption parameter. |
docker/Dockerfile |
Removes ggplot2 upper bound in the full image. |
docker/Dockerfile_minimal |
Removes ggplot2 upper bound and adjusts minimal image validation. |
.github/workflows/R-CMD-check.yaml |
Switches R setup/dependency installation back to r-lib actions. |
.github/workflows/test-coverage.yaml |
Switches coverage workflow dependency setup back to r-lib actions. |
.github/workflows/pkgdown.yaml |
Switches pkgdown workflow dependency setup back to r-lib actions. |
.github/workflows/auto-format.yml |
Switches formatting workflow dependency setup back to r-lib actions. |
.github/package-versions.txt |
Removes the ggplot2 3.5.2 pin. |
Files not reviewed (1)
- man/print_or_save_plot.Rd: Language not supported
…vice Agent-Logs-Url: https://github.com/CCBR/MOSuite/sessions/cc29b772-a646-4961-a763-0ed9267586bb Co-authored-by: kelly-sovacool <17768269+kelly-sovacool@users.noreply.github.com>
| @@ -9,6 +9,9 @@ | |||
| #' @param plot_obj plot object (e.g. ggplot, ComplexHeatmap...) | |||
| #' @param filename name of the output file. will be joined with the `plots_dir` option. | |||
| #' @param graphics_device Default: `grDevice::png()`. Only used if the plot is not a ggplot. | |||
There was a problem hiding this comment.
Fixed in aa22a8e: updated grDevice::png() to grDevices::png() in R/plots.R roxygen text and regenerated man/print_or_save_plot.Rd accordingly.
ggplot2 v4.0.0 breaks correlation heatmap rendering in
filter_counts(),normalize_counts(), andbatch_correct_counts(), causingError in plot.window(): ! need finite 'xlim' values.Root causes & fixes
Invalid
+ ggplot2::labs()on ComplexHeatmap objects (filter.R,normalize.R,batch-correction.R):plot_corr_heatmap()returns aComplexHeatmap::Heatmap, not a ggplot. ComplexHeatmap's+operator concatenates heatmaps; addingggplot2::labs()to it produces a corrupted object in ggplot2 4.0.0. These are replaced with a newcaptionparameter onprint_or_save_plot().base::plot()used for ComplexHeatmap inprint_or_save_plot()(plots.R):base::plot()(andprint()) dispatch incorrectly forHeatmap/HeatmapListobjects under ggplot2 4.0.0. Added explicit branches to useComplexHeatmap::draw()instead.Caption support for ComplexHeatmap (
plots.R): Added acaptionparameter toprint_or_save_plot(). ForComplexHeatmap/HeatmapListobjects, the caption is rendered at the bottom of the graphics device usinggrid::grid.text(). For ggplot objects,ggplot2::labs(caption = caption)is used as before. Callers infilter.R,normalize.R, andbatch-correction.Rpass the appropriate caption string.Removed ggplot2 version pin (
DESCRIPTION,.github/package-versions.txt): Theggplot2 (< 4.0.0)constraint is removed fromDESCRIPTIONand theany::ggplot2@3.5.2pin is removed from.github/package-versions.txt.Restored standard CI actions (
.github/workflows/R-CMD-check.yaml): Reverted the R-CMD-check and lint jobs fromCCBR/actions/install-r-pak@mainback tor-lib/actions/setup-r@v2+r-lib/actions/setup-r-dependencies@v2.Tests
New and updated tests in
tests/testthat/test-plots.Rcover:ComplexHeatmapto disk viaprint_or_save_plot()without errorComplexHeatmapwith a caption viaprint_or_save_plot()print_or_save_plot()ComplexHeatmapwith a caption usingwithr::with_png()for safe graphics device cleanup