Skip to content

[FEATURE,API,TEST] Make fraction combination a choice: fractions:aggregate - #9876

Merged
timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:feature/fraction-aggregate
Aug 6, 2026
Merged

timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:feature/fraction-aggregate

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Step 4 of #9864. Steps 1-3 are #9867, #9868 and #9869, all merged.

The change

How the fractions of a fraction group are combined into that group's assay values was fixed at "sum". It becomes a choice, fractions:aggregate:

  • sum (default) reproduces every earlier version, and is what MaxQuant and Proteome Discoverer do. Fractions are the parts of one separated sample, and for label-free data — where the reported value is an absolute intensity — keeping one fraction of a peptide split evenly across two reports half its material.
  • best keeps a single fraction per peptide and fraction group and discards the rest. That is the de-duplication MSstats and FlashLFQ perform so a feature enters a downstream model once, rather than an aggregation.

A bare max is deliberately not offered: nobody uses one. MSstatsTMT keeps the fraction with the highest mean across channels; FlashLFQ the highest-intensity one. mean/median over fractions are also not offered — fractions are a partition, not repeated measurements, so their mean is sum/n with n varying by detection.

The selection rule

Ranked by the number of labels with a positive abundance, then by the total of those, an exact tie keeping the lowest fraction number. This is the rule getBestCharge_() already applies to charge states in the same class.

Prevalence has to come first. IsobaricChannelExtractor stores a reporter it could not find — or one below min_reporter_intensity — as an explicit 0.0, so ranking on cell count rather than on measurements would put a fraction that detected nothing level with one that detected everything.

Why the choice is per fraction group and never per label

The fraction is chosen once for the whole group and all of its labels are taken from it. A per-channel argmax — which is what a naive call into the existing per-channel structure gives you — could take channel 126 from fraction 3 and 127 from fraction 7, mixing two physical aliquots and destroying the reporter-ion ratio profile, which is the entire quantity of interest in TMT. For label-free there is one channel and it degenerates harmlessly.

Every label observed in any fraction stays a cell of the group's assays under both settings, seeded at 0.0. Otherwise a label seen only in a discarded fraction would vanish from the assay, and downstream code reads an absent cell as "no peptide ever reached it" rather than "not detected".

Scope

Per-(file, channel) quantities are untouched — -file_and_channel_level_output, the QPX pg per-run intensities, the mzTab per-run columns. Such a cell is one fraction, so there is nothing to select there. Under best they therefore describe the data more completely than the assay values do; that is deliberate and documented next to the two consequences already recorded for that granularity.

Refactor

quantifyPeptides() collapsed the fraction axis in two duplicated loops, one per branch of the charge flag. They are now one path that regroups the raw observations onto (fraction_group, fraction, label) — the axis the old code discarded on the spot — and hands that to collapseFractions_(). The charge flag composes on top by filtering the regroup loop, so the charge is selected first and the fraction is chosen among what survives.

Breaking

best_charge_and_fraction is renamed to best_charge. It selects a charge; it never selected a fraction, and combining fractions is now its own parameter. There is no alias, so an INI file or command line using the old name fails as an unknown parameter rather than silently reverting to the default.

Reference churn

None at the default. fractions:aggregate reaches the # Parameters (relevant only): header only when it is not sum and the design has more than one fraction, so no existing reference moves. The only churn is the renamed flag in four header lines.

One occurrence of the old name survives, in src/tests/class_tests/openms/data/BSA.consensusXML. That is a class-test input recording a past run's parameters as inert UserParam strings; rewriting it would misrepresent the fixture. No TOPP reference or TOPPAS pipeline carries the name.

Tests

Four class-test sections and one TOPP test.

The channel-coherence section provably catches its bug. Replacing the per-fraction choice with a per-channel max — the exact defect it exists to guard — turns it red on precisely the right assertions:

- line 688: TEST_REAL_SIMILAR(a[0],500.0): got 900, expected 500
- line 714: TEST_REAL_SIMILAR(d[2],0.0):   got 700, expected 0

900 instead of 500 is the mixed aliquot (ratio 500:400 becomes 900:400); 700 instead of 0 is the discarded fraction leaking back through a label it alone carried.

The other sections cover both tie-breaks, the preserved label, the untouched file/channel level, and the order in which best_charge and fractions:aggregate compose — that one built so the two orderings give different answers (900 against 300), since the obvious fixture cannot tell them apart.

TOPP ProteinQuantifier_29 pairs against _26, the same command line at the default. I verified the 650→600 drop by hand against the per-fraction peptide table rather than from the tool: AAAAAK and CCCCCK live in one fraction each and do not move; PEPTIDEK, seen at 100/10 and 50/5 with equal label prevalence, keeps fraction 1 on the higher total.

Full local ctest, -E "BrukerTims|PASEF": 2808 tests, 9 failures, all pre-existing environmental — 6 CometAdapter version-string, PercolatorAdapter numerics, Doxygen_Warning_test HAVE_DOT, ThermoRawFile_test .NET. Doxygen ran as part of all with no warnings on the changed files, and TOPPWRITEINI_ProteinQuantifier passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

Summary by CodeRabbit

  • New Features

    • Added configurable fraction aggregation with sum and best modes.
    • Added independent charge selection through the best_charge option.
    • Improved detailed peptide and protein quantification across fractions, files, and channels.
  • Bug Fixes

    • Improved handling of undetected values, output alignment, and complete peptide-table results.
    • Added deterministic best-fraction selection for tied results.
  • Documentation

    • Updated parameter names and output descriptions to reflect the new quantification options.

@jpfeuffer

Copy link
Copy Markdown
Contributor

makes sense.

…egate

How the fractions of a fraction group are combined into that group's assay
values was fixed at "sum". It is now 'fractions:aggregate':

- sum (default) reproduces every earlier version, and is what MaxQuant and
  Proteome Discoverer do. Fractions are the parts of one separated sample, and
  for label-free data, where the reported value is an absolute intensity,
  keeping one fraction of a peptide split evenly across two reports half its
  material.
- best keeps a single fraction per peptide and fraction group and discards the
  rest -- the de-duplication MSstats and FlashLFQ perform so a feature enters a
  downstream model once.

The fraction is ranked by the number of labels with a positive abundance, then
by the total of those, an exact tie keeping the lowest fraction number. That is
the rule getBestCharge_() already applies to charges. Prevalence has to come
first because IsobaricChannelExtractor stores a reporter it could not find as an
explicit 0.0, so counting cells rather than measurements would rank a fraction
that detected nothing level with one that detected everything.

The choice is made once for the whole fraction group and never per label:
taking channel 126 from one fraction and 127 from another would mix physical
aliquots and destroy the reporter ratios that isobaric quantification consists
of. Every label observed in any fraction stays a cell of the group's assays
under both settings, so a label seen only in a discarded fraction reports 0.0
("not detected") instead of disappearing and being read downstream as a cell no
peptide ever reached.

quantifyPeptides() previously collapsed the fraction axis in two duplicated
loops, one per branch of best_charge. They are now one path that regroups the
raw observations onto (fraction group, fraction, label) and hands that to
collapseFractions_(). best_charge composes on top by filtering the regroup loop,
so the charge is selected first and the fraction is chosen among what survives.

Per-(file, channel) quantities are untouched: such a cell is one fraction by
definition. Under 'best' they therefore describe the data more completely than
the assay values do, which is now documented alongside the two consequences
already recorded for that granularity.

best_charge_and_fraction is renamed to best_charge. It selects a charge; it
never selected a fraction, and combining fractions is now its own parameter.
There is no alias, so an INI file or command line using the old name fails as an
unknown parameter rather than silently reverting to the default.

Nothing in-tree changes at the default. 'fractions:aggregate' reaches the
"# Parameters (relevant only):" header only when it is not 'sum' and the design
has more than one fraction, so no existing reference moves; the only reference
churn is the renamed flag in four header lines.

Four class-test sections cover the selection rule, both tie-breaks, the
preserved label, the untouched file/channel level, and the order in which
best_charge and fractions:aggregate compose. TOPP test 29 pairs against 26 --
the same command line at the default -- where PEPTIDEK, seen in both fractions
with equal label prevalence, keeps the higher-total fraction and the protein
falls from 650.0/65.0 to 600.0/60.0.

Part of OpenMS#9864.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@timosachsenberg
timosachsenberg force-pushed the feature/fraction-aggregate branch from e0b179a to 61dfdc5 Compare August 6, 2026 10:52
@timosachsenberg timosachsenberg changed the title [FEATURE,API,TEST] Make fraction combination a choice: fractions:aggregate (depends on #9869) [FEATURE,API,TEST] Make fraction combination a choice: fractions:aggregate Aug 6, 2026
@timosachsenberg
timosachsenberg marked this pull request as ready for review August 6, 2026 10:56
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4d45e35-f93b-4789-8bd4-ca392d071d0d

📥 Commits

Reviewing files that changed from the base of the PR and between 61dfdc5 and 29dd63e.

📒 Files selected for processing (1)
  • CHANGELOG
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG

📝 Walkthrough

Walkthrough

Quantification now separates best_charge from fraction aggregation. Fractions support sum and best modes. Peptide, protein, detailed-output, TOPP, and regression-test handling were updated accordingly.

Changes

Quantification aggregation

Layer / File(s) Summary
Fraction aggregation contracts
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h, src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
The quantifier adds fractions:aggregate with sum and best modes. Best-fraction selection uses positive-label prevalence, total abundance, and lowest-fraction tie-breaking.
Peptide and protein aggregation flow
src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
Peptide aggregation selects charges independently, preserves fraction-level observations, collapses fractions, and applies best_charge during detailed protein quantification.
Output integration and validation
src/topp/ProteinQuantifier.cpp, src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp, src/tests/topp/*, CHANGELOG
Output metadata, peptide tables, TOPP tests, class tests, fixtures, and changelog entries use best_charge and cover fraction aggregation behavior.

Sequence Diagram(s)

sequenceDiagram
  participant ProteinQuantifier
  participant PeptideAndProteinQuant
  participant QuantificationTests
  ProteinQuantifier->>PeptideAndProteinQuant: pass best_charge and fractions:aggregate
  PeptideAndProteinQuant->>PeptideAndProteinQuant: select charges and aggregate fractions
  PeptideAndProteinQuant-->>ProteinQuantifier: return peptide and protein quantities
  QuantificationTests->>ProteinQuantifier: execute TOPP and regression cases
  ProteinQuantifier-->>QuantificationTests: produce updated output tables
Loading

Possibly related PRs

  • OpenMS/OpenMS#9843: Modifies fraction-group abundance preservation in PeptideAndProteinQuant.
  • OpenMS/OpenMS#9847: Modifies charge selection and fraction-level quantification in PeptideAndProteinQuant.
  • OpenMS/OpenMS#9851: Updates detection and abundance aggregation for positive values.

Poem

I gather fractions, neat and bright,
Sum their signals into light.
Or choose the best with ties made fair,
While charges find their proper pair.
— A quantifying rabbit 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding the configurable fractions:aggregate choice, with relevant feature, API, and test scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests

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

🤖 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 `@CHANGELOG`:
- Line 62: Update the changelog entry for best_charge to use current assay
terminology: replace “Sample-level” with “assay-level” when describing reported
quantities, or explicitly clarify that “sample” refers only to the internal
charge-selection rule.
🪄 Autofix

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 Plus

Run ID: e4842661-c74d-47a5-8267-c970da160641

📥 Commits

Reviewing files that changed from the base of the PR and between b51d520 and 61dfdc5.

📒 Files selected for processing (11)
  • CHANGELOG
  • src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h
  • src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
  • src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProteinQuantifier_17_output.txt
  • src/tests/topp/ProteinQuantifier_28_output.txt
  • src/tests/topp/ProteinQuantifier_29_output.txt
  • src/tests/topp/ProteinQuantifier_2_output1.txt
  • src/tests/topp/ProteinQuantifier_2_output2.txt
  • src/topp/ProteinQuantifier.cpp

Comment thread CHANGELOG Resolved
The OpenMS#9796 entry was written before the sample grain was removed and still
described the rule in terms of samples. It is not only stale terminology: the
shipped code ranks charges by countQuantifiedAssays_(), i.e. by the number of
distinct (fraction group, label) assays with a positive abundance, so "distinct
samples with positive signal" states the wrong quantity.

Raised by CodeRabbit on OpenMS#9876.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
@timosachsenberg
timosachsenberg merged commit d788717 into OpenMS:develop Aug 6, 2026
10 checks passed
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 6, 2026
…ow counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that OpenMS#9869/OpenMS#9874/OpenMS#9876 touched - so it
now VERIFIES rather than assumes OpenMS#9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of OpenMS#9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx
timosachsenberg added a commit that referenced this pull request Aug 6, 2026
…es 1-2) (#9879)

* [TEST] QPX: pin values against text references, not just schema and row counts

Phase 0.1 gave the QPX views a schema check and a row-count floor. Those catch a
table that collapsed or lost a column; they say nothing about what is IN it.

ParquetDiff gains 'out_tsv', which writes a table out as text sorted by primary
key, and four references are pinned against that with FuzzyDiff: the pg view of
ProteinQuantifier_19 (48 rows) and _18 (3 rows), and the pg (20 rows) and psm
(4 rows) views of IsobaricWorkflow.

Text rather than committed Parquet is the whole point. A binary reference can
only ever be regenerated wholesale, which is exactly the operation that hides
unrelated drift; a text reference is reviewable in a pull request and patchable
line by line, and it puts QPX on the same footing as every other reference in the
suite rather than inventing a second kind of artefact.

The dump reuses the comparator's own canonical key encoding, so it cannot
disagree with the comparison about what a primary key is, and it escapes tabs and
newlines inside values so one row is always one line. Rows therefore come out in
length-prefixed key order - 'TMT126' before 'TMT127C' before 'TMT131' - which
looks unsorted but is deterministic and byte-comparable, which is what a
reference needs. A file with no derivable key still dumps, in file order, with a
warning saying so, because a reference built from it would be sensitive to how
the producer ordered its rows.

Comparison uses the shared relative tolerance with the absolute one set to ZERO.
FuzzyDiff.ini's absdiff of 0.01 exists for "zero vs. epsilon" on unbounded
quantities; the QPX views carry q-values and posterior error probabilities living
in [0,1], where it deletes the assertion outright - in one fixture 68 of 104 PEPs
are <= 0.01, so every one of them would compare equal to every other. Verified,
not argued: perturbing a PEP by 0.005 turns the psm reference red, and that is a
change the shared absdiff would have absorbed silently.

Both references were shown to fail on purpose - a 5% intensity change and the
q-value change above - and restored afterwards.

Fixtures were chosen by float-path length, not table size. ProteinQuantifier
reads a committed consensusXML and does no mzML parsing, feature finding,
alignment or normalization; IsobaricWorkflow adds only reporter extraction; both
keys are float-free. ProteinQuantifier_19's 48 rows are 4 fraction groups x 6 TMT
labels x 2 anchors with 12-entry grouped_runs lists - the design melting,
fraction-group keying and label assignment that #9869/#9874/#9876 touched - so it
now VERIFIES rather than assumes #9876's claim that nothing changes at the
default 'fractions:aggregate'.

The feature view and both ProteomicsLFQ producers are deliberately NOT pinned.
The feature key contains a float32 'rt' matched with zero tolerance, and
ProteomicsLFQ picks its median-normalization reference map by feature count, so
one extra feature on one platform shifts every intensity by a finite factor.
Those wait for the normalization fix that will move them anyway.

Part of #9864 Phase 0.1.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

* [FIX,TEST] Address review: escape the backslash, and make the row-floor test mean what it says

Three findings from CodeRabbit on #9879, all valid.

1. dumpToTsv could forge an escape. A tab is rendered as the two characters '\'
   't' to keep one row on one line - but a value that ALREADY contained a
   backslash followed by 't' rendered to those same two characters. Two
   genuinely different tables therefore produced identical text and the
   reference comparison accepted them as equal, which is the exact failure a
   value reference exists to rule out. The backslash is now escaped first and
   unconditionally.

   Verified in both directions rather than assumed: two tables differing only in
   'literal backslash-t' versus 'a real tab' now render as X\\tY and X\tY, and
   with the fix reverted the new regression section fails on
   TEST_NOT_EQUAL(text_a, text_b) because both collapse to [X\tY]. The section
   also asserts that neither dump contains a raw tab, which would split a row.

   None of the four committed references contains a backslash, so none of them
   moves - checked, and all 51 QPX/ParquetDiff tests still pass against the
   unchanged files.

2. TOPP_ParquetDiff_8 passed for the wrong reason. It exists to show the row
   floor applies to the SECOND input, and it did fail - but its two fixtures have
   disjoint primary keys, so it would have failed on the key mismatch even if
   'min_rows' never looked at 'in2' at all. 'schema_only' now removes every other
   failure cause, leaving the floor as the only thing that can go red.

3. The documented canonical key order was backwards, in both the CHANGELOG and
   the CMake comment. Length-prefixing puts the six-character 'TMT126' and
   'TMT131' ahead of the seven-character 'TMT127C', not 'TMT127C' before
   'TMT131'.

Full local ctest unchanged at 2826 tests, 9 pre-existing environmental failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

---------

Co-authored-by: Claude Opus 5 (1M context) <[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.

2 participants