Add QQ plot to the statistical-analysis page#216
Conversation
|
Warning Review limit reached
More reviews will be available in 41 minutes and 3 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds QQ plot as a new group-comparison visualization type. A ChangesQQ Plot visualization feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@R/statmodel-server-visualization.R`:
- Around line 23-26: The QQ plot choice is being unconditionally included for
all flows through the updateSelectInput call at line 25, but PTM flows do not
support QQ plotting and this creates a broken user path. Add a conditional check
before the updateSelectInput call to filter out QQ from the choices when
loadpage_input()$BIO equals "PTM". Additionally, update the
default_template_plot_type_choices() function (lines 162-172) to accept a
parameter indicating the BIO type (or check loadpage_input()$BIO internally) and
exclude QQ from the returned choices when the BIO type is "PTM", ensuring that
both the initial choices and the updated choices remain consistent with this
rule.
- Around line 320-327: The pdf() device opened at the start of the QQ download
branch is not guaranteed to be closed if MSstats::groupComparisonQCPlots()
throws an error, which can leak graphics devices and break subsequent plot
generation. Wrap the pdf() call and the MSstats::groupComparisonQCPlots() call
in a tryCatch or try-finally construct to ensure dev.off() is always executed
regardless of whether an exception is thrown by the groupComparisonQCPlots
function.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: eade200f-2a8a-4eea-a299-d1391e054903
📒 Files selected for processing (7)
R/constants.RR/module-statmodel-server.RR/statmodel-server-download-code.RR/statmodel-server-visualization.RR/statmodel-ui-options-visualization.Rtests/testthat/test-module-statmodel-server.Rtests/testthat/test-statmodel-ui-options-visualization.R
Motivation and Context
The pull request adds QQ (Quantile-Quantile) plot visualization support to the statistical-analysis module, enabling users to assess the normality of data distributions in group comparison analyses. This enhancement expands the visualization options available on the statistical-analysis page alongside existing plot types like Volcano plots, Heatmaps, Comparison plots, and Response Curves.
Changes
Constants and Configuration
plot_type_qq_plot = "QQPlots"toCONSTANTS_STATMODELinR/constants.Rto map the plot type identifier to the MSstats function parameterplot_type_response_curveconstant commentCore Visualization Logic
statmodelServer()inR/module-statmodel-server.Rto:default_template_plot_type_choices()helper for determining available plot type options instead of hardcoded valuesMSstats::groupComparisonQCPlotswith proper error handling viatryCatch, modal spinner display during computation, and spinner cleanup in finally blockrenderPlotlyand fallback generic plot rendering for other typesUI Components and Options
create_qq_plot_options(ns)function inR/statmodel-ui-options-visualization.Rto render QQ plot-specific UI options (protein selection viauiOutput)create_plot_type_selector()to include "QQ Plot" option in the plot type dropdown mapped to the QQPlots constantR/statmodel-server-visualization.Rto recognizeqq_plotplot type and render its optionsDownload and Export Functionality
default_template_plot_type_choices(n_comparisons = 0)helper function inR/statmodel-server-visualization.Rto dynamically determine available plot types:n_comparisons >= 2get_download_plot_filename()to generateQQPlot-<date>.zipfilenames for QQ plot exportscreate_download_plot_handler()inR/statmodel-server-visualization.Rto:Ex_QQPlot.pdfviaMSstats::groupComparisonQCPlots(type="QQPlots")for the selected proteinwhich.Comparisonparameter based on plot type (uses "all" for heatmap)generate_analysis_code()inR/statmodel-server-download-code.Rto generate reproducible R code for QQ plot creation viaMSstats::groupComparisonQCPlots()when non-PTM template is selectedUnit Tests
New tests in
tests/testthat/test-module-statmodel-server.R:get_download_plot_filename()returns QQ plot-specific filenames (starting withQQPlot-and ending with.zip)default_template_plot_type_choices()for:n_comparisons < 2and inclusion whenn_comparisons >= 2CONSTANTS_STATMODEL$plot_type_qq_plotwith value "QQPlots"n_comparisonsparameter is omitted (treats as 0)Updated tests in
tests/testthat/test-statmodel-ui-options-visualization.R:create_qq_plot_options()UI output containing expected namespace for protein selection controlcreate_plot_type_selector()tests to verify "QQ Plot" option presence in rendered selector UICoding Guidelines Compliance
The implementation adheres to the established codebase patterns and best practices:
NAMESPACE_STATMODELfor UI element IDs andCONSTANTS_STATMODELfor constant valuestryCatchwith user-visible error notifications for robustness@noRdroxygen tags for internal helper functionscreate_*_plot_options()functions and download/export handlers