Repository navigation
[OSW,auto_iRT] Add priority peptides for sampling - #8373
timosachsenberg merged 7 commits into
Conversation
WalkthroughAdds priority-peptide support to automated iRT sampling: a new optional Changes
Sequence Diagram(s)sequenceDiagram
participant WF as OpenSwathWorkflow
participant Helper as OpenSwathHelper
participant Pool as Candidate Pool
WF->>WF: loadPriorityPeptideSequences(irtkit.tsv, cirtkit.tsv, custom?)
WF->>Helper: sampleExperiment(exp, bins, per_bin, ..., priority_peptides)
Helper->>Pool: partition -> priority_candidates + regular_candidates
rect rgb(220,245,220)
note over Helper: Phase 1 — Priority sampling
Helper->>Pool: sample priority per RT bin (dedupe by sequence)
Helper->>Helper: mark picked sequences
end
rect rgb(240,240,255)
note over Helper: Phase 2 — Fill remaining slots
Helper->>Pool: sample from regular (skip already picked)
end
Helper-->>WF: return sampled LightTargetedExperiment
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)src/openms/**/*.{cpp,h,hpp,cc,cxx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-08-05T12:43:11.681ZApplied to files:
🧬 Code graph analysis (1)src/openms/source/ANALYSIS/OPENSWATH/OpenSwathHelper.cpp (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (6)
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 |
…ingjc/OpenMS into feature/auto_irt_priority_irt_sampling
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 (2)
src/topp/OpenSwathWorkflow.cpp (1)
1092-1099: Nonlinear iRTtop_fractionconstant disagrees with the commentIn the nonlinear auto-iRT path you log:
- Comment (lines 1095–1098): “we set top fraction to 80% …”
- Actual call (lines 1100–1107):
OpenSwathHelper::sampleExperiment(..., /*top_fraction=*/0.7, priority_peptides);If the intent is indeed to use the top 80% of intense peptides,
top_fractionshould be0.8. If 70% is the new intended behavior, the explanatory comment (and any external docs that mention 80%) should be updated accordingly to avoid confusion.- 0.7, + 0.8,(or adjust the comment if 0.7 is desired).
Also applies to: 1100-1107
src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathHelper.h (1)
185-213: Add explicit<unordered_set>include to OpenSwathHelper.hVerification confirms the issue. OpenSwathHelper.h declares
std::unordered_set<std::string>on line 212 but does not include<unordered_set>. None of the currently included OpenMS headers provide this include transitively.Additionally, OpenSwathHelper.cpp includes this header at line 11 before including
<unordered_set>at line 13, which will cause a compilation error when the header tries to use the unordered_set type.Other OpenMS headers in the same codebase (QTClusterFinder.h, IDScoreGetterSetter.h, IDMergerAlgorithm.h, FalseDiscoveryRate.h) explicitly include
<unordered_set>when using it, establishing the correct pattern.Add the include as suggested:
#include <OpenMS/KERNEL/StandardTypes.h> #include <OpenMS/KERNEL/MSExperiment.h> #include <OpenMS/ANALYSIS/TARGETED/TargetedExperiment.h> #include <OpenMS/OPENSWATHALGO/DATAACCESS/TransitionExperiment.h> #include <OpenMS/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.h> #include <OpenMS/CONCEPT/LogStream.h> +#include <unordered_set>
🧹 Nitpick comments (3)
src/topp/OpenSwathWorkflow.cpp (2)
396-398: Priority iRT sampling parameter and wiring look good; consider two behavioral tweaksThe new
Calibration:tr_irt_priority_samplingoption and the associated validation and wiring into auto-iRT sampling are coherent overall (TSV-only, existence check, usage whenauto_irtis enabled, and loading vialoadPriorityPeptideSequences). Two points to consider:
Validation even when
auto_irtis disabled (lines 713–714, 788–804)
The priority file is validated unconditionally. This means a user can hit a fatal “must be TSV / does not exist” error even ifauto_irtisfalseand the file will never be used. To avoid surprising failures, you could gate the validation onauto_irt:
- // Validate priority iRT sampling file format if provided
- if (!priority_sampling_irt_tr_file.empty())
- // Validate priority iRT sampling file format if provided and used
- if (auto_irt && !priority_sampling_irt_tr_file.empty())
2. **TSV reader parameters for priority files (lines 1004–1051)** `loadPriorityPeptideSequences` is called with `TransitionTSVFile().getDefaults()` rather than the user-tuned `Library:` parameters used for the main `-tr` file. If users customize their TSV column mapping for the main library and expect the same layout for the priority TSV, this might be surprising. If you intend the priority TSV to share the same schema as the main library, consider reusing `tsv_reader_param` here instead of a fresh defaults object. If you intentionally want a fixed, canonical TSV layout for priority lists, it might be worth calling that out more explicitly in the parameter doc string. Also applies to: 713-714, 788-804, 1004-1051 --- `609-661`: **`loadPriorityPeptideSequences`: solid helper; optional refinements** The helper cleanly loads multiple priority TSV-like files, deduplicates by `compound.sequence`, and degrades gracefully on missing/failed files with WARN logs rather than hard failures. That’s a good fit for an optional priority feature. Two optional refinements you may want to consider: - **Decoy filtering**: If any of the input files can contain decoy compounds, you might want to mirror the main sampling logic and ignore decoys when building `priority_sequences` to avoid prioritizing decoy-only sequences by accident (e.g., by checking a decoy flag on transitions and cross-filtering compounds before insertion, if available for these files). - **Log loaded unique sequences per file**: Currently you log total compounds per file (line 647–648) and a global unique count (657–658). If you care about how many unique sequences actually contributed from each file (especially when there are duplicates across irtkit/cirtkit/custom), you could also log per-file unique sequence counts, but that’s purely diagnostic sugar. Overall, the function is clear and robust as-is. </blockquote></details> <details> <summary>src/openms/source/ANALYSIS/OPENSWATH/OpenSwathHelper.cpp (1)</summary><blockquote> `169-377`: **Priority-aware sampling logic looks consistent with intended behavior** The extended `sampleExperiment` implementation correctly integrates priority peptides: - Decoy filtering is preserved via `good_ids`. - Compounds are partitioned into `priority_candidates` vs regular `candidates` based on exact `cmp.sequence` membership in `priority_peptides`. - Intensity-based ranking and `top_fraction` are applied only to regular candidates, ensuring priority peptides are not trimmed away. - RT binning and `all_candidates` ensure the RT span is computed from everything that is eligible for sampling, with a sanity check requiring at least 3 candidates. - The two-phase per-bin sampling (priority-first, then regular to fill remaining per-bin quota) together with `picked_sequences` keeps the total selected peptides bounded by `bins * peptides_per_bin` and avoids reusing the same sequence across bins. One behavioral nuance worth keeping in mind: matching is done on the raw `LightCompound::sequence` string, so priority peptides must use exactly the same sequence representation (including any modification encoding and case) as the main library to be recognized. Otherwise, this looks well factored and in line with the described priority sampling design. </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: CodeRabbit UI **Review profile**: CHILL **Plan**: Pro <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between f870cf00913ff4adf8ad43daaf668066ab30b120 and b08edaaedbf792808a2021613c0305f66d22fcd6. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `CHANGELOG` (1 hunks) * `src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathHelper.h` (2 hunks) * `src/openms/source/ANALYSIS/OPENSWATH/OpenSwathHelper.cpp` (3 hunks) * `src/topp/OpenSwathWorkflow.cpp` (7 hunks) </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>📓 Path-based instructions (2)</summary> <details> <summary>src/openms/**/*.{cpp,h,hpp,cc,cxx}</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > `src/openms/**/*.{cpp,h,hpp,cc,cxx}`: Follow the existing C++ coding conventions in the codebase > Use the established naming patterns for classes, methods, and variables > Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification) > Follow the established error handling patterns > Utilize OpenMS logging mechanisms > Be mindful of memory usage when processing large datasets > Consider algorithmic complexity for data processing operations > Use appropriate OpenMS containers and algorithms Files: - `src/openms/source/ANALYSIS/OPENSWATH/OpenSwathHelper.cpp` - `src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathHelper.h` </details> <details> <summary>src/openms/include/OpenMS/**/*.h</summary> **📄 CodeRabbit inference engine (.github/copilot-instructions.md)** > Add Doxygen comments for new public methods and classes Files: - `src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathHelper.h` </details> </details><details> <summary>🧠 Learnings (2)</summary> <details> <summary>📚 Learning: 2025-08-05T12:43:11.681Z</summary>Learnt from: CR
Repo: OpenMS/OpenMS PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-05T12:43:11.681Z
Learning: Applies to src/openms/**/*.{cpp,h,hpp,cc,cxx} : Use OpenMS data structures (e.g., MSExperiment, FeatureMap, PeptideIdentification)**Applied to files:** - `src/openms/source/ANALYSIS/OPENSWATH/OpenSwathHelper.cpp` - `src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathHelper.h` </details> <details> <summary>📚 Learning: 2025-08-29T19:09:45.997Z</summary>Learnt from: jcharkow
Repo: OpenMS/OpenMS PR: 8188
File: src/topp/OpenSwathWorkflow.cpp:1118-1123
Timestamp: 2025-08-29T19:09:45.997Z
Learning: In OpenMS OpenSwathWorkflow, the use_ms1_ion_mobility parameter should be respected when applying estimated MS1 ion mobility extraction windows. The apply_window calls for MS1 ion mobility should check both pasef AND use_ms1_ion_mobility to avoid re-enabling disabled functionality.**Applied to files:** - `src/openms/include/OpenMS/ANALYSIS/OPENSWATH/OpenSwathHelper.h` </details> </details><details> <summary>🧬 Code graph analysis (2)</summary> <details> <summary>src/openms/source/ANALYSIS/OPENSWATH/OpenSwathHelper.cpp (2)</summary><blockquote> <details> <summary>src/openms/source/CONCEPT/Exception.cpp (1)</summary> * `IllegalArgument` (247-250) </details> <details> <summary>src/openms/include/OpenMS/MATH/MathFunctions.h (1)</summary> * `seed` (501-504) </details> </blockquote></details> <details> <summary>src/topp/OpenSwathWorkflow.cpp (1)</summary><blockquote> <details> <summary>src/openms/source/APPLICATIONS/OpenSwathBase.cpp (2)</summary> * `loadTransitionList` (211-246) * `loadTransitionList` (211-213) </details> </blockquote></details> </details> </details> <details> <summary>🔇 Additional comments (1)</summary><blockquote> <details> <summary>CHANGELOG (1)</summary><blockquote> `85-85`: **LGTM! Changelog entry is accurate and well-formatted.** The changelog entry appropriately summarizes the new priority peptide feature for iRT sampling. The description is clear, follows the established format, and correctly references PR #8373. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Description
This PR adds support for prioritizing specific peptide sequences during iRT peptide sampling in the OpenSwath workflow (when using
-auto_irt). Users can specify a custom transition TSV file containing priority peptides, which will be sampled first (alongside the share/OpenMS/CHEMISTRY irtkit and cirtkit peptides), ensuring a set of peptides that are typically conserved/more likely to be present are included in the iRT sampling for calibration.iRT Peptide Sampling Improvements
priority_peptidesparameter to thesampleExperimentfunction, allowing users to specify peptide sequences that should be prioritized during sampling. Priority peptides are sampled first, followed by regular candidates to fill the remaining quota. [1] [2] [3] [4] [5]Command-Line Interface & Configuration
tr_irt_priority_samplingto allow users to specify a custom TSV file containing priority peptides for iRT sampling. The workflow validates the existence and format of this file. [1] [2] [3]Integration with Built-In Kits
auto_irtis enabled, the workflow automatically loads built-in irtkit and cirtkit peptide sequences as priority peptides, and includes any user-specified custom priority file if provided.Supporting Functions
loadPriorityPeptideSequencesto load peptide sequences from one or more TSV files, used to aggregate all priority peptides for sampling.Workflow Updates
sampleExperimentin the main workflow to pass the newpriority_peptidesparameter for both linear and nonlinear iRT calibration steps. [1] [2]Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit