Repository navigation
perf(dataProcessPlots): Flat-layer QC boxplots for PDF and no print()… - #225
Rudhik1904 wants to merge 4 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 41 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughQC plots use separate rendering paths for Plotly and non-Plotly output. Plot helpers suppress direct printing in Plotly mode, and QC device closure is also skipped in that mode. ChangesPlot Rendering
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The reviewed rendering changes are mergeable; no actionable risk was identified. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 3 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
🧪 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. A rabbit plots with whiskers neat Comment |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| } | ||
|
|
||
|
|
||
| #' Boxplot statistics for the QC plot, matching ggplot2::stat_boxplot |
There was a problem hiding this comment.
Can you simplify the documentation across the PR around the adjustment to QC plots? At the moment, I still need to read the code to understand what you did at a high level. Jargon like grob tree and few vectorized layers make it hard to understand.
From my understanding, you're basically computing some basic quantile metrics, rather than every little quantile, and then passing those metrics to be plotted. Please correct me if I'm wrong / did not elaborate enough.
|
Did you test this on the dataset with file_path HPC code to reproduce: |
I did use a subset of the test file (quant_data_combined_cpu) mentioned in https://github.com/orgs/Vitek-Lab/projects/9/views/1?sliceBy%5Bvalue%5D=Rudhik1904&pane=issue&itemId=221133751 There is prob stilll more room for improvement. but this was giving me decent result, so want to commit at least that. |
Motivation and Context
dataProcessPlots()slows down as the number of MS runs grows, mainly in QCPlot. We profiled it on synthetic data (12–768 runs) and on a real 270-run, 4,715-protein experiment, and found two causes:geom_boxplotbuilds a separate grob tree for every box insideggplot_gtable(), at about 5 ms per box, with one box per run in every plot. The cost depends on the number of boxes, not the number of data points: on real data, a protein with 1,058× more rows was only 20% slower in this step. With 270 runs and 4,715 proteins, QCPlot alone was projected at about 2.5 hours.isPlotly = TRUE) renders every plot twice. Each plot wasprint()ed onto a graphics device and then rebuilt from scratch byggplotly(). With no device open, R creates a strayRplots.pdfin the working directory. For QCPlot this wasted rendering was most of the runtime. Separately,.plotQCcalleddev.off()even in plotly mode, which closed the user's open graphics device.Solution:
print()and guard.plotQC'sdev.off().ggplotly()does not pay the per-box cost, so plotly mode keepsgeom_boxplotunchanged, along with its native plotly box traces and tooltips.Results on a real dataset (20-protein subset, 270 runs, median of 3):
Changes
R/dataProcessPlots.Rprint()calls inif (!isPlotly): two in.plotProfile, two in.plotQCand one in.plotCondition. In plotly mode the plots are no longer rendered to a device, and noRplots.pdfis created..plotQC'sdev.off()guard fromaddress != FALSEtoaddress != FALSE & !isPlotly, matching.plotProfileand.plotCondition. Plotly mode no longer closes the user's graphics device, and does not error once no device is opened..plotQCpassesisPlotlyto.makeQCPlot.R/utils_dataprocess_plots.R.makeQCPlottakes a newisPlotlyargument (defaultFALSE):isPlotly = TRUE: unchangedgeom_boxplot.isPlotly = FALSE: the boxplots are drawn as four vectorized layers: whiskers (geom_segment), boxes (geom_rect, filled byLABEL), medians (geom_segment) and outliers (geom_point).#333333, line width 0.5 (1 for the median), box width 0.75, outlier shape 1 / size 1.5, and the same x-axis range (0.4 to n + 0.6) and tick labels as the discrete axis..qcBoxStats()computes per-run, per-label box statistics with data.table, using the same rules asggplot2::stat_boxplot:scale_y_continuous(limits)does;man/devtools::document():dot-makeQCPlot.RddocumentsisPlotly, anddot-qcBoxStats.Rdis new.Housekeeping
Rplots.pdfthat had been committed by accident.Verified on real data (the "All proteins" plot plus the smallest, median and largest protein): identical box statistics (difference 0), identical outlier counts (up to 75,143), the same axis range and labels, and visually identical images.
Testing
Added to
inst/tinytest/test_dataProcessPlots.R:isPlotly = TRUE, ProfilePlot, QCPlot and ConditionPlot open no graphics device and write noRplots.pdfisPlotly = TRUEand a savingaddressleaves the user's open device open.qcBoxStats()matchesstat_boxplot(vialayer_data()) onSRMRawDataoutput: box positions, all five statistics, and outliers.makeQCPlot(isPlotly = TRUE)contains aGeomBoxplotlayer;isPlotly = FALSEdoes not.qcBoxStats()(ignoring the y-limits, quantile type 6, whiskers at 2 × IQR) fails at least two of them.R CMD check(--no-manual --ignore-vignettes): 1 ERROR, 3 WARNINGs, 5 NOTEs, identical to the parent commita100dcf. No warning or note mentions the changed code.The single test failure, which is also the check's one ERROR, is the existing stale snapshot in
test_dataProcess.R:71-74("dataProcess FeatureLevelData for SRMRawData should be identical to previously saved output"). It fails identically without this change.Checklist Before Requesting a Review
dataProcessPlots()'s arguments and outputs are unchanged)