Skip to content

[BREAKING,TEST] ProteomicsLFQ: stop normalizing; export raw intensities (#9864) - #9880

Merged
timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:lfq-no-normalization
Aug 7, 2026
Merged

timosachsenberg merged 2 commits into
OpenMS:developfrom
timosachsenberg:lfq-no-normalization

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Implements the decision recorded in #9864 (comment) (§A4, §D5, item 1.4 of §G).

The problem

ProteomicsLFQ applied a median scaling to each fraction's consensus map — unless -out_msstats or -out_triqler was requested:

https://github.com/OpenMS/OpenMS/blob/develop/src/topp/ProteomicsLFQ.cpp#L1425-L1428

Traced end to end, that is a reproducibility defect rather than a stylistic question:

  • the normalized feature handles are what ConsensusMapArrowExport writes into quantms.feature.parquet (ConsensusMapArrowExport.cpp:1162 writes fh->getIntensity(), and NM_SCALE rewrites exactly that at ConsensusMapNormalizerAlgorithmMedian.cpp:134), and what PeptideAndProteinQuant::readQuantData aggregates into the protein groups;
  • normalizeMaps records nothing — it only calls setIntensity, leaving no DataProcessing entry and no meta value — and grep -n normaliz src/openms/source/FORMAT/ArrowSchemaRegistry.cpp returns zero hits, so the QPX schema has no field for it either.

The same tool, the same input and the same -out_qpx directory produce normalized or raw intensities depending on whether -out_msstats was also passed — and the file records neither which, nor that any transform occurred.

Why the gate existed has never been documented (§D5).

Why deletion rather than "remove the gate"

Normalizing per fraction and then summing across fractions (PeptideAndProteinQuant.cpp:380) is only ratio-preserving when the reference is the same sample in every fraction. The reference is medians[index_of_largest_map], and index_of_largest_map degenerates to 0 in the LFQ linking path (§A3), i.e. the lowest fraction group present in that fraction — a different sample per fraction under a non-rectangular design.

Measured on this branch, before vs. after, via ParquetDiff -out_tsv:

producer design rows/keys intensity ratio (median / max)
TOPP_ProteomicsLFQ_qpx BSA_design_onetable_nonconsec.tsv (non-rectangular) unchanged 5.30 / 12.02
TOPP_ProteomicsLFQ_qpx_seeds BSA_design.tsv (rectangular) unchanged 1.32 / 2.15

Row counts and primary keys are identical in all four tables; the psm view does not move at all. So this changes values only — nothing appears or disappears.

No comparable tool picks a reference run per fraction. MSstats' default equalizeMedians and DIA-NN's cross-run normalization target a global median with no reference run at all; MaxQuant's delayed normalization and FlashLFQ fit the per-fraction coefficients jointly with the fraction summation, precisely because per-fraction normalization followed by summation is not well defined. Reimplementing MaxLFQ here is out of scope, so the tool stops normalizing and the choice moves to the consumer.

The capability is not lost

Three existing routes, none of them new:

  • ConsensusMapNormalizer on -out_cxml — median, quantile, robust regression or thresholded scaling;
  • ProteinQuantification:consensus:normalize, already a registered user-visible ProteomicsLFQ parameter, which normalizes at the (fraction group, label) assay level;
  • the downstream tool, since MSstats, Triqler and comparable consumers normalize by design.

The tool documentation now names all three in place of the paragraph describing the removed behaviour.

Test changes

TOPP_ProteomicsLFQ_qpx_flags (new) runs the same input twice, differing only in -out_msstats/-out_triqler, and requires the QPX feature and pg tables and the mzTab to be equal. Exact comparison on purpose — the two runs perform the same computation, so any tolerance would be tolerance for a transform that is not supposed to exist.

Verified to fail for its stated reason, not merely to fail: with the normalization call restored and everything else untouched, all three comparisons go red; with it removed, all three pass.

ConsensusMapNormalizerAlgorithmMedian_test.cpp — this class had no coverage at all; its two non-trivial sections were // TODO stubs naming normalizeMaps(ConsensusMap&) and computeNormalizationFactors(...), neither of which exists. It now pins:

  • the per-map medians, and that the returned reference is the argmax of ColumnHeader::size rather than of the handles actually present (all three maps hold three handles; only the stored sizes differ), including the >-tie going to the lowest index;
  • the degenerate reference of §A3: with all sizes at their 0 initializer the reference collapses to map 0 even though map 2 holds the most handles. This PR removes its only live caller — ConsensusMapNormalizer's consensusXML input restores size on read — so the section keeps the defect visible while it is latent;
  • the silent bail-out to all-1.0 medians when any map has no passing feature, and that it is a no-op rather than an error;
  • that NM_SHIFT scans for the largest median itself and so is unaffected by the size-derived reference;
  • passesFilters_ with and without an accession filter.

Probed the same way: flipping the §A3 expectation makes the section fail.

Reference churn is one file. ProteomicsLFQ_in_feat_multi_out.mzTab, 10 abundance lines. Patched line by line rather than regenerated — the 10 lines that move are disjoint from the 29 where the reference already differs from the output in whitelisted fields, so no unrelated drift is swept in. The other 12 of 19 ProteomicsLFQ producers were already un-normalized: 10 request -out_msstats/-out_triqler, and _4/_6 use spectral counting, which never reaches quantifyFraction_.

Full local suite: 2813 tests, 8 failures, all in the known environmental baseline (6 CometAdapter_*_out1 version-string, PercolatorAdapter_1_subprocess_out numerics, Doxygen_Warning_test HAVE_DOT). doxygen-error.log holds only the two pre-existing HAVE_DOT warnings.

Notes for review

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

Summary by CodeRabbit

  • Behavior Changes

    • ProteomicsLFQ outputs are now unnormalized by default.
    • Median normalization must be requested explicitly through supported tools, parameters, or downstream workflows.
    • QPX output structure remains unchanged, while abundance values may differ.
  • Documentation

    • Updated ProteomicsLFQ guidance to clarify normalization options and output behavior.
  • Tests

    • Expanded normalization coverage for scaling, shifting, filtering, and edge cases.
    • Added regression checks confirming optional MSstats and Triqler exports do not change other output values.

@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: c1d3084f-0015-4652-a1b4-43fca764eaf7

📥 Commits

Reviewing files that changed from the base of the PR and between 26aebf5 and 3475311.

📒 Files selected for processing (2)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
🚧 Files skipped from review as they are similar to previous changes (2)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt

📝 Walkthrough

Walkthrough

ProteomicsLFQ no longer applies implicit per-fraction median normalization. Documentation and the changelog describe explicit alternatives. Regression tests verify stable QPX and mzTab outputs when auxiliary exports are requested. Median normalizer tests cover core operations and edge cases.

Changes

ProteomicsLFQ normalization

Layer / File(s) Summary
Remove implicit normalization
src/topp/ProteomicsLFQ.cpp, CHANGELOG
ProteomicsLFQ no longer applies median scaling during fraction quantification. Documentation and the changelog describe unnormalized outputs and explicit normalization routes.
Validate auxiliary exports
src/tests/topp/CMakeLists.txt, src/tests/topp/ProteomicsLFQ_in_feat_multi_out.mzTab
Regression coverage compares QPX and mzTab outputs with and without MSstats and Triqler exports. Updated abundance references reflect the new unnormalized values.
Expand median normalizer coverage
src/tests/class_tests/openms/source/ConsensusMapNormalizerAlgorithmMedian_test.cpp
Tests cover median calculation, reference selection, scale and shift normalization, filtering, edge cases, and object deletion.

Possibly related PRs

Poem

A rabbit checks each fraction’s flow,
No hidden median scales it so.
QPX and mzTab stay aligned,
Edge cases face tests well-defined.
Explicit tools now guide the show.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% 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 states that ProteomicsLFQ now exports raw intensities without implicit normalization.
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.

🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/ConsensusMapNormalizerAlgorithmMedian_test.cpp (1)

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

Mark the pinned defect so a future fix updates this test.

This block asserts the current defective reference selection as expected behavior. If someone repairs computeMedians to use the actual handle counts, this section fails without an obvious pointer to the intent. Add a TODO marker next to the assertion so the tracker link is visible at the failure site.

♻️ Proposed change
     vector<double> medians;
+    // TODO(issue `#9864`): update this expectation when the reference selection is fixed.
     TEST_EQUAL(ConsensusMapNormalizerAlgorithmMedian::computeMedians(map, medians, "", ""), 0)
🤖 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/ConsensusMapNormalizerAlgorithmMedian_test.cpp`
around lines 128 - 144, Add a TODO marker with the relevant OpenMS issue
reference next to the computeMedians assertion in the degenerate-reference test
block, clearly indicating that the expectation must be updated when reference
selection uses actual handle counts.
🤖 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/tests/class_tests/openms/source/ConsensusMapNormalizerAlgorithmMedian_test.cpp`:
- Around line 128-144: Add a TODO marker with the relevant OpenMS issue
reference next to the computeMedians assertion in the degenerate-reference test
block, clearly indicating that the expectation must be updated when reference
selection uses actual handle counts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 871e555a-c869-4e76-8cbb-012c81bd1cf1

📥 Commits

Reviewing files that changed from the base of the PR and between 6ceeceb and ce836fa.

📒 Files selected for processing (5)
  • CHANGELOG
  • src/tests/class_tests/openms/source/ConsensusMapNormalizerAlgorithmMedian_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProteomicsLFQ_in_feat_multi_out.mzTab
  • src/topp/ProteomicsLFQ.cpp

…es (OpenMS#9864)

A median scaling ran over each fraction's consensus map unless -out_msstats or
-out_triqler was requested. The same input written to the same -out_qpx
directory therefore held normalized or raw intensities depending on whether an
unrelated output file had also been asked for, and nothing recorded which:
normalizeMaps() only calls setIntensity(), and the QPX schema has no field for
a normalization.

The gate is removed by deleting the normalization, not by normalizing
unconditionally. Per-fraction normalization followed by the cross-fraction sum
in PeptideAndProteinQuant is only ratio-preserving when the reference is the
same sample in every fraction, which the map-index-0 reference does not
guarantee for a non-rectangular design: on BSA_design_onetable_nonconsec.tsv
the scaling moved feature intensities by a median factor of 5.3 and a maximum
of 12.0 (rectangular BSA_design.tsv: 1.3 and 2.1). No comparable tool
normalizes per fraction against a per-fraction reference run - MSstats and
DIA-NN target a global median with no reference run, MaxQuant and FlashLFQ fit
the fraction coefficients jointly with the fraction summation.

Normalizing becomes an explicit step: ConsensusMapNormalizer on -out_cxml, the
existing ProteinQuantification:consensus:normalize parameter, or the downstream
tool's own normalization.

Row counts and primary keys of the QPX views are unchanged; only values move.
ProteomicsLFQ_in_feat_multi_out.mzTab is the only shipped reference that
changes, in 10 abundance lines.

New TOPP_ProteomicsLFQ_qpx_flags runs the same input twice, differing only in
-out_msstats/-out_triqler, and requires the QPX feature and pg tables and the
mzTab to be equal. Verified to fail for its stated reason: with the
normalization call restored, all three comparisons go red.

ConsensusMapNormalizerAlgorithmMedian had no test coverage at all - its two
stub sections named signatures that no longer exist. It now has a class test
pinning the per-map medians, the ColumnHeader::size-derived reference, the
degenerate all-sizes-zero case (OpenMS#9864 A3, now latent since ProteomicsLFQ was
its only live caller), the silent bail-out to all-1.0 medians, and that
NM_SHIFT derives its own reference.

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

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@timosachsenberg
timosachsenberg merged commit 0f0a87d into OpenMS:develop Aug 7, 2026
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Aug 7, 2026
OpenMS#9880 (ProteomicsLFQ stops normalizing, exports raw intensities) landed on
develop and changes the same lines as this branch. Two conflicts, both in
files the two changes share:

CHANGELOG -- both sides append bullets to the ProteomicsLFQ section. Kept
both, develop's BREAKING entry first.

ProteomicsLFQ_in_feat_multi_out.mzTab -- neither side's reference is correct
after the merge. This branch's version has the deduplicated PSM rows and the
q-values that follow from them; develop's still has the 18 duplicates but
carries the raw, un-normalized intensities. Regenerated by running the merged
tool, then verified to be exactly the composition of the two rather than
accepted on the strength of the test going green:

  vs this branch's reference: the only fields that move are abundances (PEP
  col 19, PRT cols 13/17), and every one of them moves by the identical
  factor 1.583596 -- the fraction-2 median scaling OpenMS#9880 removed. No q-value
  and no row-set change.

  vs develop's reference: 18 fewer PSM rows (62 -> 44) and 36 q-value changes
  across the 18 shared PEP rows, and zero abundance differences.

So the new reference is this branch's rows and q-values with develop's raw
intensities, which is what the merged code should produce. The four
whitelisted MTD lines (software[1..2], ms_run[1..2]-location) are kept in the
reference's own form instead of the local build's version string and paths.

src/topp/ProteomicsLFQ.cpp and src/tests/topp/CMakeLists.txt auto-merged;
checked that OpenMS#9880's normalization removal and its five qpx_flags tests
survive alongside this branch's -in_feat dedup and -out_feat tests.

Local: TOPP_ProteomicsLFQ_{in_feat,out_feat}* 11/11, and 221/221 over
QPX/Arrow/ParquetDiff/ProteomicsLFQ/ProteinQuantifier/IsobaricWorkflow/
MzTab/ConsensusMapNormalizer.

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 11, 2026
Audited PRs merged since the last CHANGELOG update (#9881): most of
them (#9879, #9880, #9882, #9884, #9886, #9892, #9896, #9898, #9900,
#9901, #9888) already carried their own CHANGELOG entries. Only the
Docker library-stage fix (#9891) was missing one.


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

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