Repository navigation
feat: protein-level FDR (picked-protein) in PeptideSearchEngineFI - #9123
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdded a protein-level FDR parameter ( Changes
Sequence Diagram(s)sequenceDiagram
participant Search as SearchEngine
participant Index as PeptideIndexing
participant Infer as BasicProteinInferenceAlgorithm
participant FDR as FalseDiscoveryRate
participant Filter as IDFilter
Search->>Search: run PSM search (optional PSM-level FDR)
alt pooled/aggregate mode
Search->>Index: re-index pooled PSMs vs aggregate proteins (with decoy string)
end
Search->>Infer: run protein inference (single or aggregate)
Infer->>FDR: applyPickedProteinFDR(protein list, "DECOY_", true)
FDR->>Filter: filter protein hits by score
Filter->>Search: return filtered proteins
Search->>Search: remove decoys/empty/unreferenced from PSMs & proteins
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 1169-1194: Aggregate protein FDR fails because pooled
mfres.aggregate.peptide_ids already had decoy PSMs removed by the per-file
search() FDR workflow, so PeptideIndexing against ctx.db can't map PSMs to decoy
proteins; to fix, when fdr_protein_ > 0.0 and using the multi-file aggregate
path, preserve decoy PSMs for pooling by disabling per-file PSM decoy removal
(adjust the per-file search() call to skip its IDFilter/PSM-level filtering) or
alternatively change the pooling to collect raw PSMs before any
IDFilter::filterHitsByScore is run, then run PeptideIndexing and
FalseDiscoveryRate::applyPickedProteinFDR on
mfres.aggregate.peptide_ids/protein_ids as shown (refer to search(),
IDFilter::filterHitsByScore, mfres.aggregate.peptide_ids, PeptideIndexing,
ctx.db, and FalseDiscoveryRate::applyPickedProteinFDR).
- Around line 895-908: The protein-level picked-protein FDR is being run after
decoys were removed, which breaks applyPickedProteinFDR; move the decoy-removal
steps (removeDecoyHits and removeUnreferencedProteins) so that
applyPickedProteinFDR(protein_ids[0], "DECOY_", true) runs while decoy proteins
still exist, then call IDFilter::filterHitsByScore(protein_ids, fdr_protein_)
and only afterwards remove decoys/unreferenced proteins and clean up PSMs
(ensure peptide_ids are synchronized by removing PSMs that reference removed
proteins or call removeUnreferencedProteins on peptide_ids), and drop the no-op
IDFilter::removeEmptyIdentifications(peptide_ids) here if it's redundant.
🪄 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: 1da6fd58-4476-4bba-9bd5-2b0f6cf9ccf9
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.hsrc/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp
5a4ac56 to
fdffe51
Compare
fdffe51 to
6caf057
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp (1)
1197-1207: Consider checkingPeptideIndexing::run()return value for robustness.The return value of
indexer.run()is ignored here, whereas the single-file path (line 862) checks and handles errors. While failures during aggregate re-indexing are unlikely (the same database was used successfully for per-file searches), checking the return value would maintain consistency and catch unexpected edge cases.♻️ Proposed fix to check return value
param_pi.setValue("missing_decoy_action", "silent"); indexer.setParameters(param_pi); - indexer.run(ctx.db, mfres.aggregate.protein_ids, mfres.aggregate.peptide_ids); + PeptideIndexing::ExitCodes indexer_exit = indexer.run(ctx.db, mfres.aggregate.protein_ids, mfres.aggregate.peptide_ids); + if (indexer_exit != PeptideIndexing::ExitCodes::EXECUTION_OK && + indexer_exit != PeptideIndexing::ExitCodes::PEPTIDE_IDS_EMPTY) + { + OPENMS_LOG_WARN << "[PDBS-FI] Aggregate PeptideIndexing returned non-OK exit code: " + << static_cast<int>(indexer_exit) << std::endl; + } // Protein inference: aggregate best PSM score per peptide per protein.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around lines 1197 - 1207, The call to PeptideIndexing::run on the pooled results ignores its return value; update the code around the indexer.run(ctx.db, mfres.aggregate.protein_ids, mfres.aggregate.peptide_ids) invocation to capture and check the boolean return (as done for the single-file path), and on failure log an error via the same logger/context and handle the error (e.g., return/throw or set appropriate error state) so aggregate re-indexing failures are detected and handled consistently with the per-file path using the PeptideIndexing indexer instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 940-953: The protein-FDR branch silently skips when decoys are
disabled; add the same warning used in the PSM-level FDR check so users know
protein FDR is being ignored. Specifically, where fdr_protein_ is checked (the
block using BasicProteinInferenceAlgorithm,
FalseDiscoveryRate::applyPickedProteinFDR and IDFilter calls), add a conditional
warning when fdr_protein_ > 0.0 && !decoys_ that logs a clear message (e.g.
"FDR:protein set but decoys disabled — skipping protein-level FDR") using the
same logging mechanism as the PSM-level check so behavior is consistent. Ensure
this check references fdr_protein_ and decoys_ and is placed before running
BasicProteinInferenceAlgorithm or applying applyPickedProteinFDR.
- Around line 1185-1227: The code skips aggregate protein FDR when decoys are
disabled but doesn't warn the user; add a warning when fdr_protein_ > 0.0 and
decoys_ is false in the multi-file branch. Concretely, next to the existing
condition that starts with if (fdr_protein_ > 0.0 && decoys_ &&
!mfres.aggregate.protein_ids.empty()) add an else-if or separate check for
(fdr_protein_ > 0.0 && !decoys_) and emit a user-visible warning (e.g. via
OPENMS_LOG_WARN) stating that protein FDR is requested but decoys are disabled
so FDR will be skipped for mfres.aggregate (reference symbols: fdr_protein_,
decoys_, mfres.aggregate, OPENMS_LOG_WARN). Ensure message matches the
single-file path warning style.
---
Nitpick comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 1197-1207: The call to PeptideIndexing::run on the pooled results
ignores its return value; update the code around the indexer.run(ctx.db,
mfres.aggregate.protein_ids, mfres.aggregate.peptide_ids) invocation to capture
and check the boolean return (as done for the single-file path), and on failure
log an error via the same logger/context and handle the error (e.g.,
return/throw or set appropriate error state) so aggregate re-indexing failures
are detected and handled consistently with the per-file path using the
PeptideIndexing indexer instance.
🪄 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: a5a95211-8aec-4a63-a4ba-5445ce06fd40
📒 Files selected for processing (2)
src/openms/include/OpenMS/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.hsrc/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp
There was a problem hiding this comment.
♻️ Duplicate comments (2)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp (2)
940-953:⚠️ Potential issue | 🟡 MinorAdd warning when protein FDR is set but decoys are disabled.
The PSM-level FDR block (lines 899-902) logs a warning when
FDR:PSMis set without decoys. For consistency and user awareness, the protein FDR block should also warn whenFDR:proteinis silently skipped.🛡️ Proposed fix to add the missing warning
IDFilter::removeDecoyHits(peptide_ids); IDFilter::removeEmptyIdentifications(peptide_ids); IDFilter::removeUnreferencedProteins(protein_ids, peptide_ids); } + else if (fdr_protein_ > 0.0 && !decoys_) + { + OPENMS_LOG_WARN << "FDR:protein is set but decoys are disabled. Skipping protein FDR filtering." << endl; + } // patch file-specific metadata🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around lines 940 - 953, The protein-FDR block silently skips when decoys are disabled; add a warning similar to the PSM-level case: detect when fdr_protein_ > 0.0 and !decoys_ and log a warning before the existing block. Modify the function containing the shown snippet (referencing variables fdr_protein_ and decoys_) to emit a processLogger.warn or LOG_WARN message indicating "FDR:protein set but decoys disabled; protein-level FDR will be skipped" (or similar) to match the PSM warning pattern, leaving the existing BasicProteinInferenceAlgorithm, fdr.applyPickedProteinFDR, and IDFilter calls unchanged when decoys_ is true.
1185-1231:⚠️ Potential issue | 🟡 MinorAdd warning when protein FDR is set but decoys are disabled in multi-file path.
Similar to the single-file path, users should be warned when
FDR:proteinis silently skipped due to disabled decoys.🛡️ Proposed fix to add the missing warning
OPENMS_LOG_INFO << "[PDBS-FI] Aggregate protein inference + FDR: " << mfres.aggregate.protein_ids[0].getHits().size() << " proteins at " << fdr_protein_ * 100 << "% FDR" << std::endl; } + else if (fdr_protein_ > 0.0 && !decoys_) + { + OPENMS_LOG_WARN << "FDR:protein is set but decoys are disabled. Skipping aggregate protein FDR filtering." << endl; + } // Aggregate modification analysis on the pooled PSM set.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp` around lines 1185 - 1231, The multi-file branch doesn't warn when fdr_protein_>0.0 but decoys_ is false; add a warning like in the single-file path: detect the case (fdr_protein_ > 0.0 && !decoys_) and emit OPENMS_LOG_WARN with a clear message that protein FDR will be skipped for aggregated results because decoys are disabled (reference variables/symbols: fdr_protein_, decoys_, mfres.aggregate.protein_ids), placed alongside the existing multi-file logic before any re-indexing/inferring so users see the warning early.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cpp`:
- Around line 940-953: The protein-FDR block silently skips when decoys are
disabled; add a warning similar to the PSM-level case: detect when fdr_protein_
> 0.0 and !decoys_ and log a warning before the existing block. Modify the
function containing the shown snippet (referencing variables fdr_protein_ and
decoys_) to emit a processLogger.warn or LOG_WARN message indicating
"FDR:protein set but decoys disabled; protein-level FDR will be skipped" (or
similar) to match the PSM warning pattern, leaving the existing
BasicProteinInferenceAlgorithm, fdr.applyPickedProteinFDR, and IDFilter calls
unchanged when decoys_ is true.
- Around line 1185-1231: The multi-file branch doesn't warn when
fdr_protein_>0.0 but decoys_ is false; add a warning like in the single-file
path: detect the case (fdr_protein_ > 0.0 && !decoys_) and emit OPENMS_LOG_WARN
with a clear message that protein FDR will be skipped for aggregated results
because decoys are disabled (reference variables/symbols: fdr_protein_, decoys_,
mfres.aggregate.protein_ids), placed alongside the existing multi-file logic
before any re-indexing/inferring so users see the warning early.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 46c8f3af-47af-4204-9861-6f1ece424b35
📒 Files selected for processing (2)
src/openms/source/ANALYSIS/ID/PeptideSearchEngineFIAlgorithm.cppsrc/topp/PeptideDataBaseSearchFI.cpp
✅ Files skipped from review due to trivial changes (1)
- src/topp/PeptideDataBaseSearchFI.cpp
There was a problem hiding this comment.
This is exactly where layer ordered heaps would be very helpful as you will be dealing with potentially millions of IDs. See #8904
There was a problem hiding this comment.
true but not the bottleneck
There was a problem hiding this comment.
have you tried several millions psms yet? I agree, probably not, but while the TSG will stay constant and the scoring is super fast, the sorting overhead will grow and grow.
Add FDR:protein parameter for protein-level FDR using BasicProteinInferenceAlgorithm (score aggregation) followed by picked-protein FDR (Savitski et al. 2015). Design: protein FDR is NOT applied per-file in the core search() method. Instead, it runs at the appropriate scope: - Single-file path (file-based search()): BPIA + picked-protein FDR runs after PSM-level FDR but before decoy removal, so both target and decoy proteins receive aggregated scores. - Multi-file path: per-file searches produce PSM-filtered results with decoys retained. The aggregate path synchronizes PSM identifiers, re-indexes pooled PSMs, runs BPIA on the full cross-file PSM set, then applies picked-protein FDR. This ensures protein inference sees all evidence across files (matching the ProteomicsLFQ pattern) rather than running conservatively per-file. Addresses item #14 from #9108. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…requirement - Add comment explaining why PeptideIndexing re-runs in multi-file aggregate path (aggregate protein_ids may not cover proteins found only in other files) - Add TOPP tool doc note: external decoy databases are not supported, provide target-only FASTA and use -Search:decoys Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add advanced parameter 'decoy_prefix' (default "DECOY_") used everywhere instead of hardcoded prefix. When decoy generation is disabled but the FASTA contains proteins matching the prefix, FDR can still be applied. This supports databases pre-processed with DecoyDatabase or external tools using a custom decoy prefix. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add -percolator_executable parameter (advanced, optional). When set,
each per-file result is rescored with Percolator via PercolatorAdapter
before writing output, replacing HyperScore with Percolator q-values.
Follows the OpenNuXL pattern: writes temp idXML, calls
runExternalProcess_("PercolatorAdapter", ...), loads rescored results.
Safeguards:
- Empty executable (default) = skip rescoring entirely
- Minimum 100 PSMs required per file (SVM needs training data)
- Decoy check: skips rescoring if no decoy proteins found in results
- Graceful fallback: if Percolator fails, keeps original HyperScore
- Temp files cleaned up after use
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
When both -percolator_executable and FDR:protein are set, the built-in protein FDR (which runs on raw HyperScores) is now deferred. Instead, protein inference (BPIA) + picked-protein FDR runs in the TOPP tool AFTER Percolator rescoring, so protein scores are derived from Percolator q-values — the correct scores for downstream analysis. Flow with Percolator: search (PSM FDR only, protein FDR deferred) → per-file Percolator rescoring (HyperScore → q-values) → pool rescored PSMs across files → protein inference (BPIA on q-values) + picked-protein FDR → write output Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Use `decoys_ || has_decoys_in_db` consistently in both single-file
and multi-file paths. Previously single-file checked only external
decoys (missed internal), multi-file checked only internal (missed
external).
- Add in-class initializer for fdr_protein_{0.0} to prevent UB if
updateMembers_() is not called before use.
- Also add initializer for fdr_psm_{0.0} for consistency.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
5acd6d6 to
588a2fa
Compare
… aggregate Replace the PeptideIndexing re-run in the multi-file aggregate path with IDMergerAlgorithm, which is the canonical OpenMS pattern for cross-file protein inference (mirrors ConsensusMapMergerAlgorithm::mergeAllIDRuns in ProteomicsLFQ). IDMergerAlgorithm deduplicates ProteinHits by accession (union) and remaps all PeptideIdentification identifiers to the merged run. No PeptideIndexing re-run needed since per-file searches already linked peptides to proteins. Addresses review feedback from @jpfeuffer. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The aggregate protein inference + FDR was computed inside the algorithm but never written to output — each per-file output kept its original per-file protein list. Now when protein FDR is applied on the aggregate, the filtered protein list is copied back to each per-file result before writing output, so all output files reflect the cross-file protein inference result. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
@jpfeuffer Thanks for the review feedback — addressed both points:
Question: Is this the correct approach for multi-file output? Specifically:
Or should per-file outputs only contain the subset of aggregate proteins that have supporting PSMs in that specific file? (i.e., filter the aggregate protein list per-file using |
|
We can do it in any way. I often just create one huge protein run and map the peptides to it (like you did before) and you annotate with the id_file metavalue from which file_origin in the list of file_origins the ID came from. And delete all the single run protein runs (with their IDs). But you could also keep them if you think you have a need to see which PROTEIN came from where. Although this is obviously inferable from the peptides mapping to it. |
|
I wouldnt write a per-file idXML. Do you want that? |
|
Here we do everything in the tool. But for some applications we want to defer these steps to a later part: if we merge everything, can we still easily do IDMapping, percolator , inference , protein fdr filtering outside of the tool in a later workflow step? |
|
And you want the same output for both modes? |
|
Hmm IDMapping would probably not be very efficient though. But the information is still there. |
|
the major issue I see is that it needs adaption of proteomicslfq and other workflows |
|
Those would use the multifile one without inference, no? |
|
Note there will be a difference between protein FDR on quantified proteins only vs FDR on identified proteins. |
|
@jpfeuffer maybe you can assist here. |
Add -out_merged parameter to write a single merged idXML containing all PSMs pooled across input files with cross-file protein inference (BPIA) and optional picked-protein FDR. Per-file outputs (-out) are no longer overwritten with aggregate protein lists — they retain run-level info. The merged output uses IDMergerAlgorithm (accession dedup + identifier remap) to combine per-file results, then runs BPIA + optional FDR on the merged set. This cleanly separates: -out: per-file PSMs + per-file proteins (run-level) -out_merged: pooled PSMs + inferred proteins (study-level) Also removes the redundant aggregate protein FDR from the algorithm's multi-file path — protein inference on the aggregate is now exclusively handled by the TOPP tool via -out_merged, matching the ProteomicsLFQ pattern where protein inference is a top-level operation. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add missing changelog entries for commits merged after the last sync: - #9127: Fix LinearResampler right_index bounds clamping (intensity spike bug) - #9126: CometAdapter Bruker .d DDA-PASEF input support - #9121: PeptideDataBaseSearchFI runtime search diagnostics and tolerance estimation - #9122: PeptideDataBaseSearchFI automatic mass accuracy calibration (two-pass search) - #9123: PeptideDataBaseSearchFI protein-level FDR (picked-protein) - #9129: OpenSwathWorkflow Bruker DIA MS2 frame aggregation, denoising, and streaming Co-authored-by: Copilot <[email protected]>
Add missing changelog entries for commits merged after the last sync: - #9127: Fix LinearResampler right_index bounds clamping (intensity spike bug) - #9126: CometAdapter Bruker .d DDA-PASEF input support - #9121: PeptideDataBaseSearchFI runtime search diagnostics and tolerance estimation - #9122: PeptideDataBaseSearchFI automatic mass accuracy calibration (two-pass search) - #9123: PeptideDataBaseSearchFI protein-level FDR (picked-protein) - #9129: OpenSwathWorkflow Bruker DIA MS2 frame aggregation, denoising, and streaming Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
FDR:proteinparameter for picked-protein FDR (Savitski et al. 2015) via existingFalseDiscoveryRate::applyPickedProteinFDR()FDR:protein = 0.0), opt-in with e.g.FDR:protein 0.01Usage
Addresses item #14 from #9108.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation