fix(global-standards): Enable multiple precursors for the same reference peptide#180
fix(global-standards): Enable multiple precursors for the same reference peptide#180tonywu1999 merged 8 commits intodevelfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughRefactors global-standards normalization to a data-driven aggregation: joins input with peptide dictionary, assigns a new Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as "MSstatsNormalize"
participant NG as ".normalizeGlobalStandards"
participant Dict as "peptides_dict"
participant Data as "input data"
participant Agg as "Aggregation (mean_abundance)"
Caller->>NG: call with input, peptides_dict, standards
NG->>Data: merge with Dict to form input_with_peptides
NG->>Dict: lookup standards -> identify matches/missing
alt missing standards found
NG-->>Caller: throw error (list missing standards)
else all standards present
NG->>Agg: group by RUN & standard, compute mean_abundance
Agg-->>NG: mean_abundance table (wide -> long reshape)
NG-->>Caller: return normalized data (merged results)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
Failed to generate code suggestions for PR |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
R/utils_normalize.R (1)
236-240: Duplicate log messages in both branches.Both the single-fraction and multi-fraction cases emit identical messages. Compare with
.normalizeQuantile(lines 124-128), which correctly differentiates between them.📝 Proposed fix
if (data.table::uniqueN(input$FRACTION) == 1L) { msg = "Normalization : normalization with global standards protein - okay" } else { - msg = "Normalization : normalization with global standards protein - okay" + msg = "Normalization : normalization with global standards protein per fraction - okay" }
🧹 Nitpick comments (1)
R/utils_normalize.R (1)
197-203: Dead code:means_by_standardinitialization is overwritten.Line 197 initializes
means_by_standard = unique(input[, list(RUN)]), but this value is never used—it's completely replaced at lines 215-221 by the aggregation result. This leftover from the previous implementation should be removed.🧹 Remove dead code
proteins = as.character(unique(input$PROTEIN)) - means_by_standard = unique(input[, list(RUN)]) input_with_peptides <- merge(input, peptides_dict, by = "PEPTIDE", all.x = TRUE)
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
R/utils_normalize.R (1)
235-239: Duplicate log messages in conditional branches.Both branches produce the identical message, making the condition ineffective. If different messages were intended for single vs. multiple fractions, update accordingly.
🔧 Suggested fix (example differentiation)
if (data.table::uniqueN(input$FRACTION) == 1L) { msg = "Normalization : normalization with global standards protein - okay" } else { - msg = "Normalization : normalization with global standards protein - okay" + msg = "Normalization : normalization with global standards protein per fraction - okay" }
🧹 Nitpick comments (1)
R/utils_normalize.R (1)
196-196: Unused variableproteins.The variable
proteinsis assigned but never referenced in this function. Since the commit mentions "remove dead code," consider removing this line.🔧 Suggested fix
- proteins = as.character(unique(input$PROTEIN))
Motivation and Context
Was encountering an error at the line
If a reference peptide has multiple precursors, then this code will fail. I also noticed the for loop associated with this code is also heavily inefficient and can be vectorized
Changes
for loopfor aggregating data for reference peptidesTesting
Checklist Before Requesting a Review
Summary by CodeRabbit
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.