Skip to content

feat(PIPECHO): cap SVM training-set size (max_training_points) - #9669

Merged
timosachsenberg merged 3 commits into
developfrom
pip-echo/max-training-points
Jun 26, 2026
Merged

timosachsenberg merged 3 commits into
developfrom
pip-echo/max-training-points

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

PIP-ECHO's transfer-FDR SVM trains on every candidate transfer per
cross-validation fold, with no upper bound. The training set is ~2/3 of all
acceptors, fed to a LIBSVM grid search (super-linear in point count) across
3 folds × 10 rounds = 30 fits. On runs with many features per run the acceptor
count is large and this grid search dominates runtime (the reaching max number of iterations spam, driven by the large C grid on noisy data). There was no
mechanism to bound it.

Change

Add PipEcho:max_training_points (default 50000, 0 = unlimited). When a
fold's training set exceeds the cap, round() takes a deterministic
stratified subsample
of the training set only:

  • all decoys are kept (scarce; they define the FDR null),
  • all labelled positives (targets above the cutoff) are kept,
  • any remaining budget is filled with a score-spread (uniform-stride) sample
    of the below-cutoff targets, so the predictor scaling stays representative.

No RNG is used, so results remain reproducible. The cutoff/labels are computed on
the full set first, and prediction and the q-values still run over every
transfer
— so the cap only changes the fitted boundary, never the set of
scored transfers, and the FDR estimate stays unbiased.

Plumbing mirrors the existing min_decoys parameter
(PipEchoAlgorithm → Impl → TransferFDRModel).

Result (PXD016921 single-cell, fdr=0.01, sequential same-machine)

This set yields 5072 training points/fold; capping to 2000 triggers the subsample
on every fold.

run training/fold total wall Blank pep single-cell pep 100-cell pep
max_training_points=0 (uncapped) 5072 13:49 63 5604 11874
max_training_points=2000 2000 12:21 63 5604 11874

Every leakage/sensitivity number is identical (consensus files differ by
227 bytes — different SVM model, same accepted transfers) while wall time dropped
~87 s. Since FFID/alignment/quant are identical between the two runs, that delta
is entirely the SVM step; it grows super-linearly with features per run.

Tests

  • PipEchoAlgorithm_test: parameter-contract assertion (exists, default 50000) —
    runs in normal CI.
  • PipEchoAlgorithm_realistic_test (slow, OPENMS_RUN_SLOW_TESTS=1): an
    FDR-control + sensitivity + determinism check under a small cap (forces the
    subsample path on synthetic ground-truth data). Passes.

Note

Default is 50000 (bounds pathological large runs; leaves typical runs unchanged —
e.g. this dataset's 5072/fold is untouched at the default). Happy to change the
default or set it to 0 if you'd prefer current behaviour preserved until a
value is chosen.

🤖 Generated with Claude Code

https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

Summary by CodeRabbit

  • New Features

    • Added max_training_points advanced setting to cap transfer-FDR SVM training points per cross-validation fold in PipEcho (default: 50000; 0 = unlimited).
    • When capped, training uses a deterministic stratified subsample, while predictions and FDR/q-value computation continue using all transfers.
  • Tests

    • Extended realistic PipEcho tests with a regression covering the cap behavior, quality bounds, and deterministic consensus results on repeat runs.
    • Updated parameter-default coverage to assert the new setting’s default value.

The transfer-FDR SVM trained on every candidate transfer per fold with no upper
bound, so the LIBSVM grid search (super-linear in point count, x30 fits)
dominated runtime on feature-rich runs.

Add PipEcho:max_training_points (default 50000, 0 = unlimited): a deterministic
stratified subsample of the TRAINING set only. All decoys and labelled positives
are kept; the remaining budget is filled with a score-spread (uniform-stride)
sample, so no RNG is used and results stay reproducible. Prediction and the
q-values still run over every transfer, so the FDR estimate is unbiased.

On the PXD016921 single-cell set (5072 training points/fold) capping to 2000
gave byte-equivalent FDR/leakage (Blank 63 peptides, single-cell 5604) while
cutting total wall time 13:49 -> 12:21; the win grows super-linearly with scale.

Tests: parameter-contract assertion in PipEchoAlgorithm_test; an FDR-control +
sensitivity + determinism check under a small cap in the (slow) realistic test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

PipEcho now exposes max_training_points, threads it through Impl into TransferFDRModel, caps per-fold training data during model fitting, and adds tests for the default value and deterministic capped-training behavior.

Changes

PipEcho training-point cap

Layer / File(s) Summary
Parameter surface
src/openms/source/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.cpp, src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Impl.h, src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.h
Adds max_training_points to the algorithm parameters and to the Impl/TransferFDRModel interfaces, with 0 meaning unlimited.
Model wiring
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Impl.cpp, src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp
Reads max_training_points in Impl, forwards it to TransferFDRModel, and stores it in the model constructor state.
Training subsampling
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp
Adds deterministic subsampling in round(), replaces oversized training folds with the capped sample after cutoff calculation, and updates fold logging with full and capped sizes.
Validation coverage
src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp, src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp
Checks the new default parameter value and exercises the capped-training path with deterministic consensus and FDR/q-value assertions.

Sequence Diagram(s)

sequenceDiagram
  participant PipEchoAlgorithm
  participant Impl
  participant TransferFDRModel
  PipEchoAlgorithm->>Impl: provide max_training_points parameter
  Impl->>TransferFDRModel: construct with min_decoys and max_training_points
  TransferFDRModel->>TransferFDRModel: round() caps training data when enabled
Loading

Poem

(\_/)
I hopped through folds with careful glee,
Kept decoys, targets, and q-values free.
A tiny cap on training light,
Still left the consensus map just right.
Thump-thump — my whiskers approve tonight.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: capping the SVM training-set size via max_training_points.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pip-echo/max-training-points

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp (1)

440-444: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use \n instead of std::endl in this new log statement.

As per coding guidelines, avoid std::endl and use \n instead for performance reasons.

♻️ Proposed change
-                    << " acceptors (cutoff value " << cutoff << ")" << std::endl;
+                    << " acceptors (cutoff value " << cutoff << ")\n";
🤖 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 `@src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp` around
lines 440 - 444, The new OPENMS_LOG_INFO statement in TransferFDRModel should
use a newline character instead of std::endl. Update the log output in the
acceptor group progress message to end with \n rather than flushing the stream,
keeping the existing message text and symbols like groups, training, and cutoff
unchanged.

Source: Coding guidelines

src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp (1)

104-104: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer TEST_TRUE for the boolean existence check.

p.exists(...) returns a bool, so this is a boolean assertion.

♻️ Proposed change
-  TEST_EQUAL(p.exists("max_training_points"), true)
+  TEST_TRUE(p.exists("max_training_points"))

As per coding guidelines: "Prefer TEST_TRUE(expr) and TEST_FALSE(expr) over TEST_EQUAL(expr, true) and TEST_EQUAL(expr, false) for boolean assertions".

🤖 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 `@src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp` at line 104,
The boolean existence check in the PipEchoAlgorithm test uses TEST_EQUAL with
true, but this should be a boolean assertion. Update the assertion around
p.exists("max_training_points") to use TEST_TRUE instead, following the existing
testing guideline and keeping the check in the same test case.

Source: Coding guidelines

src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp (1)

545-568: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer TEST_TRUE/TEST_FALSE for the boolean assertions.

Lines 545, 547, 548, 550, and 568 assert boolean expressions via TEST_EQUAL(expr, true).

♻️ Proposed change
-      TEST_EQUAL(realized <= std::max(3.0 * 0.05, 0.05 + 0.05), true)
+      TEST_TRUE(realized <= std::max(3.0 * 0.05, 0.05 + 0.05))
       // The cap must not collapse the method to "drop everything".
-      TEST_EQUAL(s.n_transfers > 0, true)
-      TEST_EQUAL(s.n_correct > 0, true)
+      TEST_TRUE(s.n_transfers > 0)
+      TEST_TRUE(s.n_correct > 0)
       // The q-value filter still respects its own cutoff.
-      TEST_EQUAL(s.all_q_within_cutoff, true)
+      TEST_TRUE(s.all_q_within_cutoff)

and

-      TEST_EQUAL(same, true)
+      TEST_TRUE(same)

As per coding guidelines: "Prefer TEST_TRUE(expr) and TEST_FALSE(expr) over TEST_EQUAL(expr, true) and TEST_EQUAL(expr, false) for boolean assertions".

🤖 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 `@src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp`
around lines 545 - 568, The boolean assertions in the
PipEchoAlgorithm_realistic_test case use TEST_EQUAL(..., true) for expressions
like realized <= ..., s.n_transfers > 0, s.n_correct > 0, s.all_q_within_cutoff,
and same; replace these with the appropriate TEST_TRUE assertions in the
existing test block so the checks follow the project’s boolean assertion style
guideline.

Source: Coding guidelines

🤖 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 `@src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp`:
- Around line 387-412: The current cap allocation in the subsampling lambda
inside TransferFDRModel::subsample_training is decoy-first and can leave too few
labelled positives, causing predictors_t::train to fail and internal_run() to
fall back to MBR scores. Change the budgeting so positives get a reserved
minimum share before filling with decoys/rest, and keep the stride-based
sampling behavior in append_stride while ensuring both classes remain
sufficiently represented. Use the existing symbols subample_training,
append_stride, and predictors_t::train to locate and adjust the logic.

---

Nitpick comments:
In `@src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp`:
- Around line 440-444: The new OPENMS_LOG_INFO statement in TransferFDRModel
should use a newline character instead of std::endl. Update the log output in
the acceptor group progress message to end with \n rather than flushing the
stream, keeping the existing message text and symbols like groups, training, and
cutoff unchanged.

In `@src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp`:
- Around line 545-568: The boolean assertions in the
PipEchoAlgorithm_realistic_test case use TEST_EQUAL(..., true) for expressions
like realized <= ..., s.n_transfers > 0, s.n_correct > 0, s.all_q_within_cutoff,
and same; replace these with the appropriate TEST_TRUE assertions in the
existing test block so the checks follow the project’s boolean assertion style
guideline.

In `@src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp`:
- Line 104: The boolean existence check in the PipEchoAlgorithm test uses
TEST_EQUAL with true, but this should be a boolean assertion. Update the
assertion around p.exists("max_training_points") to use TEST_TRUE instead,
following the existing testing guideline and keeping the check in the same test
case.
🪄 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: 348b6519-7ebf-4729-895a-322442073308

📥 Commits

Reviewing files that changed from the base of the PR and between 1b23de1 and 57b021c.

📒 Files selected for processing (7)
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Impl.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Impl.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.cpp
  • src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp
  • src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp

timosachsenberg and others added 2 commits June 26, 2026 11:02
…ning

Review follow-up (#9669): the per-fold training subsample filled the cap
decoys-first, so a small max_training_points relative to the decoy count could
leave too few labelled positives (below the >4 floor in predictors_t::train),
fail the round, and silently fall back to MBR scores -- the opposite of the
intended speed-up. Unreachable at the default 50000 but reachable for small
advanced values.

Split the cap between decoys and positives in proportion to their sizes when the
labelled set does not fit, so neither class is starved; the below-cutoff 'rest'
still fills any remainder. The common case (whole labelled set fits) is
unchanged. Verified the realistic FDR-control test still passes under a small cap
(now 62 decoys + 426 positives kept of a 500 budget).

Also switch the new boolean test assertions to TEST_TRUE per the coding guideline.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
Codex review of #9669: the proportional decoy/positive split could starve the
MINORITY class -- e.g. 13 decoys vs 166k positives at cap 50000 allocates ~3
decoys, below predictors_t::train's >4 floor, disabling the SVM on large
decoy-sparse (but FDR-estimable) runs. That is the inverse of the earlier
decoys-first concern.

Keep the minority class whole (it almost always fits) and give the remaining
budget to the majority; split the cap evenly only when both classes individually
exceed half of it. Both classes stay viable for any reasonable cap.

Also correct the parameter help text, which still claimed both labelled classes
are always kept whole.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp (1)

460-464: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use \n instead of std::endl in this modified log statement.

The updated OPENMS_LOG_INFO ends with std::endl, which forces a flush. As per coding guidelines (Avoid std::endl and use \n instead for performance reasons), prefer \n.

♻️ Proposed change
                     << groups[i].size() << " acceptors, training on "
                     << training.size() << " of " << full_training_size
-                    << " acceptors (cutoff value " << cutoff << ")" << std::endl;
+                    << " acceptors (cutoff value " << cutoff << ")\n";
🤖 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 `@src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp` around
lines 460 - 464, The updated OPENMS_LOG_INFO statement in TransferFDRModel
should avoid forcing a flush with std::endl and use a newline terminator
instead. Update the logging line in the PIP-ECHO acceptor group message to end
with \n, keeping the rest of the message unchanged, so the logging behavior
matches the project guideline and the code path remains in the same
TransferFDRModel logic.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp`:
- Around line 460-464: The updated OPENMS_LOG_INFO statement in TransferFDRModel
should avoid forcing a flush with std::endl and use a newline terminator
instead. Update the logging line in the PIP-ECHO acceptor group message to end
with \n, keeping the rest of the message unchanged, so the logging behavior
matches the project guideline and the code path remains in the same
TransferFDRModel logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8c661232-ef9e-4b58-8b66-8b64676e466b

📥 Commits

Reviewing files that changed from the base of the PR and between 139beea and ca8a82d.

📒 Files selected for processing (2)
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openms/source/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.cpp

@timosachsenberg
timosachsenberg merged commit 7fa141e into develop Jun 26, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the pip-echo/max-training-points branch June 26, 2026 11:22
timosachsenberg added a commit that referenced this pull request Jun 27, 2026
Documents four PRs that landed on 2026-06-26 after the last CHANGELOG
update (#9667):

- #9668: fix platform-dependent float formatting in scientific notation
- #9669: feat(PIPECHO) cap SVM training-set size (max_training_points)
- #9670: fix SimpleSVM constant-predictor crashes in predict()/setup()
- #9672: perf PeptideAndProteinQuant O(1) sample-ID lookup (fixes IsobaricWorkflow hang)

GitHub Actions version bump (#9673) carries no CHANGELOG entry per the
PR author's own checklist.


Claude-Session: https://claude.ai/code/session_01JxivySW6RCM1tKbU8H6bfj

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant