Feat peptide weighting - #222
Conversation
|
Warning Review limit reached
Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds optional peptide feature weighting to protein-turnover QC controls, preprocessing, dose-response fitting, visualization, downloads, and generated analysis scripts. It also registers the new dependency import and updates related tests and module documentation. ChangesProtein turnover feature weighting
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant QC as QC controls
participant Ratios as turnover_ratios_display
participant Prepare as turnover preparation
participant Fit as doseResponseFit
participant Plot as visualizeResponseProtein
QC->>Ratios: Enable feature weighting
Ratios->>Ratios: calculatePeptideWeights(ratios)
Ratios->>Prepare: Provide weighted ratios
Prepare->>Fit: Supply prepared weights
Prepare->>Plot: Supply prepared weights
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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
🧹 Nitpick comments (3)
R/module-qc-ui.R (2)
109-111: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
paste0for multi-line strings to avoid whitespace artifacts.Using a backslash
\to continue a string on the next line preserves all of the leading indentation from the following line within the string literal itself. While HTML will visually collapse these spaces into one, it's safer and cleaner to usepaste0to prevent unintended large gaps in the raw text content.♻️ Proposed refactor
- div("What features to use in \ - summarization. All features or a subset of \ - features can be used.", class = "icon-tooltip")), + div(paste0("What features to use in ", + "summarization. All features or a subset of ", + "features can be used."), class = "icon-tooltip")),🤖 Prompt for 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. In `@R/module-qc-ui.R` around lines 109 - 111, Update the multi-line tooltip string in the div call to use paste0 with separate string fragments instead of backslash continuation, preserving the same displayed text without indentation whitespace artifacts.
126-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
paste0for multi-line strings to avoid whitespace artifacts.Similar to the previous tooltip, escaping newlines here silently pulls the indentation into the string literal.
♻️ Proposed refactor
- div("Compute per-peptide quality weights (coverage, \ - intensity, monotonicity, validity) and add them as \ - extra columns to the Turnover Ratios table.", - class = "icon-tooltip")), + div(paste0("Compute per-peptide quality weights (coverage, ", + "intensity, monotonicity, validity) and add them as ", + "extra columns to the Turnover Ratios table."), + class = "icon-tooltip")),🤖 Prompt for 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. In `@R/module-qc-ui.R` around lines 126 - 129, Update the multi-line tooltip string in the div call to use paste0, preserving the displayed wording while preventing indentation and newline whitespace from being included in the literal.R/statmodel-server-download-code.R (1)
67-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove unreachable dead code.
The early return at line 18 (
if (isTRUE(app_template == TEMPLATES$protein_turnover)) return(codes)) completely handles the protein-turnover case. This makes theifblock at line 67 unreachable. You can safely remove it and retain only the content of theelseblock to simplify the function.♻️ Proposed refactor
- if (app_template == TEMPLATES$protein_turnover) { - codes = paste(codes, "visualizeResponseProtein(\n", - " data = prepared_data,\n", - " protein_name = \"Enter protein name here\",\n", - " drug_name = \"time\",\n", - " ratio_response = FALSE,\n", - " show_ic50 = TRUE,\n", - " add_ci = FALSE,\n", - " transform_dose = FALSE,\n", - " n_samples = 1000,\n", - " increasing = ", increasing, ",\n", - " precalculated_ratios = TRUE,\n", - " color_by = \"BaseSequence\",\n", - " target_response = 0.5\n)\n", sep = "") - } else { - codes = paste(codes, "visualizeResponseProtein(\n", - " data = prepared_data,\n", - " protein_name = \"Enter protein name here\",\n", - " drug_name = \"Enter drug name here\",\n", - " ratio_response = ", ratio_response, ",\n", - " show_ic50 = TRUE,\n", - " add_ci = TRUE,\n", - " transform_dose = ", transform_dose, ",\n", - " n_samples = 1000,\n", - " increasing = ", increasing, "\n)\n", sep = "") - } + codes = paste(codes, "visualizeResponseProtein(\n", + " data = prepared_data,\n", + " protein_name = \"Enter protein name here\",\n", + " drug_name = \"Enter drug name here\",\n", + " ratio_response = ", ratio_response, ",\n", + " show_ic50 = TRUE,\n", + " add_ci = TRUE,\n", + " transform_dose = ", transform_dose, ",\n", + " n_samples = 1000,\n", + " increasing = ", increasing, "\n)\n", sep = "")🤖 Prompt for 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. In `@R/statmodel-server-download-code.R` around lines 67 - 92, Remove the unreachable app_template == TEMPLATES$protein_turnover branch from the code-generation logic, including its specialized visualizeResponseProtein construction. Retain the existing else-branch content as the sole path for this section, preserving its current parameters and formatting.
🤖 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-download-code.R`:
- Line 194: Update the samples_per_condition check in the generated
condition-sampling logic to call any() with na.rm = TRUE, ensuring unused factor
levels producing NA do not cause a runtime error while preserving the existing >
1 condition.
- Around line 223-239: Update the generated-data subsetting in the turnover
preparation block, using keep_cols and prepared_data, to intersect the requested
columns with colnames(prepared_data) before selecting them. Preserve the
weighting-dependent column list while excluding conditionally absent columns
such as BaseSequence, preventing undefined-column errors for protein-level
turnover data.
---
Nitpick comments:
In `@R/module-qc-ui.R`:
- Around line 109-111: Update the multi-line tooltip string in the div call to
use paste0 with separate string fragments instead of backslash continuation,
preserving the same displayed text without indentation whitespace artifacts.
- Around line 126-129: Update the multi-line tooltip string in the div call to
use paste0, preserving the displayed wording while preventing indentation and
newline whitespace from being included in the literal.
In `@R/statmodel-server-download-code.R`:
- Around line 67-92: Remove the unreachable app_template ==
TEMPLATES$protein_turnover branch from the code-generation logic, including its
specialized visualizeResponseProtein construction. Retain the existing
else-branch content as the sole path for this section, preserving its current
parameters and formatting.
🪄 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: 26c41d70-8d3f-4f98-bd97-9fb0683a4b49
📒 Files selected for processing (14)
NAMESPACER/MSstatsShiny.RR/constants.RR/module-qc-ui.RR/module-statmodel-server.RR/qc-server-sidebar.RR/qc-server-turnover.RR/statmodel-server-comparisons.RR/statmodel-server-download-code.RR/statmodel-server-visualization.Rman/get_download_plot_filename.Rdman/loadpageServer.Rdtests/testthat/test-module-turnover.Rtests/testthat/test-qc-server-rendering.R
💤 Files with no reviewable changes (1)
- man/get_download_plot_filename.Rd
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Motivation and Context
Protein turnover analyses need optional peptide-level quality weighting while preserving existing unweighted workflows. This change adds feature-weighting controls, propagates weights through turnover preprocessing and dose-response fitting, and includes weighting in visualizations, downloads, and generated analysis scripts.
Changes
calculatePeptideWeightsas anMSstatsResponseimport.1to synthetic zero-dose rows.get_download_plot_filenamedocumentation page.Tests