Repository navigation
Make FeatureLinker consensus output order reproducible - #9748
jonasscheid wants to merge 3 commits into
Conversation
|
@jonasscheid The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-07-16 08:41:57.220228381 +0000
+++ AUTHORS.new 2026-07-16 08:42:02.596002073 +0000
@@ -63,6 +63,7 @@
- Johannes Veit
- Johannes von Kleist
- Johan Teleman
+ - jonasscheid
- Joshua Charkow
- Juliane Schmachtenberg
- Julianus Pfeuffer |
| out.sortByQuality(); | ||
| out.sortByMaps(); | ||
| out.sortBySize(); | ||
| // Final sort by position makes the output order reproducible across runs. | ||
| // The sorts above tie on many consensus features (e.g. all singletons share size/quality), | ||
| // leaving their relative order to be decided by the grouping order, which depends on the | ||
| // input features' (randomly assigned) unique ids and is therefore not deterministic. Sorting | ||
| // by (RT, m/z) last makes position the primary, unique-id-independent key. | ||
| out.sortByPosition(); |
There was a problem hiding this comment.
is the old code even doing the right thing? e.g. should this be one sort with a comparator? or is everything some kind of stable sort?
There was a problem hiding this comment.
Is everything a stable sort? Yes — I checked all seven ConsensusMap::sortBy* methods; every one is std::stable_sort.
Was the old code doing the right thing? Half. Because they're all stable, the quality → maps → size chain does compose into a well-defined order (chained stable sorts = one lexicographic sort, last-applied = most significant). So it wasn't broken in the compose sense. Its real defect was narrower: (size, maps, quality) isn't a total order — masses of features tie (every singleton shares size 1 and quality), and those ties fell through to the grouping order, which rides on the random unique ids. That's the non-reproducibility.
cae5123 to
5047c81
Compare
FeatureGroupingAlgorithm::postprocess_ ordered the consensus features with a chain of stable sorts (quality, maps, size). These keys tie on many consensus features (e.g. all singletons share size and quality), so tied features kept the grouping order, which depends on the input features' randomly assigned unique ids and is not reproducible across runs. Replace the chain with a single stable_sort whose comparator makes position (RT, m/z) the primary, unique-id independent key; size/maps/quality only break exact-position ties. Ordering is equivalent to the previous chain followed by a sortByPosition().
…tput Reorders the consensus features in the KD/QT/WNet FeatureLinker test reference files to match the new position-sorted output order. Values are unchanged (pure reordering); verified against the built tools (all TOPP_FeatureLinker tests pass).
5047c81 to
9733b14
Compare
) (#10660) * Sort consensus map by position after grouping for reproducible output FeatureGroupingAlgorithm::postprocess_ ordered the consensus features with a chain of stable sorts (quality, maps, size). These keys tie on many consensus features (e.g. all singletons share size and quality), so tied features kept the grouping order, which depends on the input features' randomly assigned unique ids and is not reproducible across runs. Replace the chain with a single stable_sort whose comparator makes position (RT, m/z) the primary, unique-id independent key; size/maps/quality only break exact-position ties. Ordering is equivalent to the previous chain followed by a sortByPosition(). * [TEST] Update references for the position-sorted consensus output FeatureGroupingAlgorithm now sorts the consensus features by position, so the FeatureLinkerUnlabeledQT/KD, ProteomicsLFQ and MS1LabeledWorkflow references list the same consensus features in a new order. Checked for each file: the set of consensus features (and of mzTab rows) is unchanged, only the order differs. Machine paths in the regenerated files are kept as they were. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01N27gUPMwAazeK8SAKECuCa --------- Co-authored-by: jonasscheid <[email protected]> Co-authored-by: Claude <[email protected]>
…enMS#9748) (OpenMS#10660) * Sort consensus map by position after grouping for reproducible output FeatureGroupingAlgorithm::postprocess_ ordered the consensus features with a chain of stable sorts (quality, maps, size). These keys tie on many consensus features (e.g. all singletons share size and quality), so tied features kept the grouping order, which depends on the input features' randomly assigned unique ids and is not reproducible across runs. Replace the chain with a single stable_sort whose comparator makes position (RT, m/z) the primary, unique-id independent key; size/maps/quality only break exact-position ties. Ordering is equivalent to the previous chain followed by a sortByPosition(). * [TEST] Update references for the position-sorted consensus output FeatureGroupingAlgorithm now sorts the consensus features by position, so the FeatureLinkerUnlabeledQT/KD, ProteomicsLFQ and MS1LabeledWorkflow references list the same consensus features in a new order. Checked for each file: the set of consensus features (and of mzTab rows) is unchanged, only the order differs. Machine paths in the regenerated files are kept as they were. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01N27gUPMwAazeK8SAKECuCa --------- Co-authored-by: jonasscheid <[email protected]> Co-authored-by: Claude <[email protected]>
|
Closing as superseded by #10660, which landed the same change in Generated by Claude Code |
What:
FeatureLinkerUnlabeled{KD,QT,…}can output the consensus features in a different order on every run for the same input — identical features, just shuffled rows. That makes the consensusXML (and anything derived from it, e.g. exported tables) non-reproducible.Why: after grouping,
FeatureGroupingAlgorithm::postprocess_sorts the result by quality → maps → size. Many consensus features tie on all three (e.g. every singleton shares size 1 and the same quality), and for those ties the order falls back to the grouping order — which depends on the features' unique ids. Those ids are seeded from time/PID, so they differ every run. (OpenMS' own tests don't catch this because-testmode fixes the seed.)Fix: sort by position (RT, m/z) first, so the order follows the data instead of random ids; size/maps/quality only break exact-position ties. Implemented as a single
stable_sortwith a composite comparator.Regenerated the affected KD/QT/WNet test references (pure reorder — values unchanged).