Skip to content

Quantify a design with a numbering gap, with a warning in the log and results.txt, instead of refusing it - #29

Draft
trishorts wants to merge 2 commits into
masterfrom
feat/biorep-gap-warning
Draft

trishorts wants to merge 2 commits into
masterfrom
feat/biorep-gap-warning

Conversation

@trishorts

@trishorts trishorts commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Project of origin: QuantProject (consumed by sdrf, PXReprise, aging)

Draft, waiting on smith-chem-wisc/mzLib#1426 and smith-chem-wisc/mzLib#1422. It stays a draft on this fork until smith-chem-wisc#1426 merges, and is opened on smith-chem-wisc/MetaMorpheus once an mzLib release carries both. That release's pin bump is then added to this PR. It is not here yet, so CI here builds against 1.0.594, where TestSdrfDesignKeepsStudyWideReplicatesAndSaysSo, TestSdrfDesignWritesAFractionGapAndBothSidesSaySo and TestSearchQuantifiesADesignWithABiorepGap are expected to fail. Every result below is from a local package of 1.0.594 plus smith-chem-wisc#1422 and smith-chem-wisc#1426 at 2af2d4f8a (9.9.1247).

What

A gap in an experimental design's numbering is now quantified with a warning instead of refused. This covers a condition's biological replicates, a biorep's fractions, a fraction's technical replicates, and, for TMT, a plex's fractions and technical replicates. The warning goes to the log and into results.txt. A duplicate (two files at one condition, biorep, fraction and techrep, or at one fraction and techrep of a plex) is still refused.

Before, a label-free design with any gap was refused (Condition "X" biorep N is missing!), and the search skipped quantification with one warning. The TMT design window refused fraction and techrep gaps. The TMT parser never checked them, so a run quantified them silently.

Numbers are never closed up:

  • A biorep number can name a subject across conditions. Control 1–3 and treated 4–6 is a common SDRF numbering, and replicate 4 of one condition can be replicate 4 of another (matched tissue, paired designs).
  • A gap can be a lost sample or file. Closing it up hides that.

One rule, here and in mzLib smith-chem-wisc#1426

smith-chem-wisc#1426 makes mzLib's SdrfLabelFreeDesign (--sdrfDesign) keep the SDRF's numbers. It refuses the same thing this PR refuses (a duplicate) and notes the same gaps in the same words:

mzLib smith-chem-wisc#1426, SDRF report this PR, run warning
biorep gap Condition 'FA': biological replicates 3, 4, kept as the SDRF numbers them. ... Condition "FA": biological replicates 3, 4, quantified as numbered; biological replicates 1, 2 are not in the design. ...
fraction gap Condition 'A' biorep 1: fractions 1, 3, kept as the SDRF numbers them. ... Condition "A" biorep 1: fractions 1, 3, quantified as numbered; fraction 2 is not in the design. ...
techrep gap Condition 'A' biorep 1 fraction 1: technical replicates 1, 3, kept as ... Condition "A" biorep 1 fraction 1: technical replicates 1, 3, quantified as numbered; ...
duplicate refused refused

TestSdrfDesignWritesAFractionGapAndBothSidesSaySo runs one fraction-gap SDRF through both sides and checks both messages. Each repository keeps its own quoting: mzLib quotes a condition with ', and MetaMorpheus's existing design messages use ".

Behaviour

in the design before now
numbers run 1..N quantified quantified (unchanged)
label-free: a gap in bioreps, fractions or techreps, or numbering not starting at 1 refused; the search skips quantification quantified as numbered, one warning per gap, in the log and results.txt
label-free: duplicate refused refused (unchanged)
TMT window: a gap in a plex's fractions or techreps refused on Save saved, gaps listed in the Save and Validate messages
TMT run: a gap quantified, nothing said quantified, one warning per gap, in the log and results.txt
TMT: no plex, a number below 1, duplicate in a plex refused by the window refused (unchanged)

Calibration and averaging (CalibrationTask, SpectralAveragingTask) copy the design under the new file names, carrying the numbers through unchanged. Before, a design with a gap was an error there too: they warned and wrote no new design, so the search after them would quantify without one (read from the code, not run). Now they write it.

Fractions carry meaning, and a gap keeps it. FlashLFQ's match-between-runs transfers only between fractions at most one apart (FlashLfqEngine.cs:832). Fractions numbered 1 and 3 therefore exchange no transfers, which is what the numbers say (read, not run).

Why this needs mzLib smith-chem-wisc#1422 in the same release

FlashLFQ's normalization and Bayesian step walked replicates 0..max. smith-chem-wisc#1422 makes them walk the numbers that exist. Measured against 1.0.594 (no smith-chem-wisc#1422):

smith-chem-wisc#1422's description lists the other failures: Sequence contains no elements in fraction normalization, and KeyNotFoundException in the Bayesian step (smith-chem-wisc#2886).

Tested

New:

  • TestBiorepGapIsAWarningNotAnError:
    • bioreps 1, 2, 4 → no error, exactly one warning, naming 3;
    • control 1, 2 / treated 3, 4 → one warning, for treated;
    • 1..N → none;
    • a fraction gap and a techrep gap → warnings naming the biorep and fraction;
    • a duplicate → still refused.
  • TestSearchQuantifiesADesignWithABiorepGap: a search with normalization on, A = 2, 3 and B = 4, 5.
    • Quantification is not skipped.
    • Both warnings are in the log and in results.txt.
    • The protein table's columns are Intensity_A_2, _A_3, _B_4, _B_5.
    • The four normalized peptide intensities agree within 1%.
  • TestSearchQuantifiesFractionAndTechrepGapsAsNumbered: the same five files numbered with fraction and techrep gaps (1, 3), and without them. Both are quantified with normalization on, the gaps are warned about in the log and results.txt, and every file's normalized intensity is identical in the two.
  • TmtDesignErrorsAreTheWindowRules and TmtDesignGapsAreWarningsNotErrors:
    • the window's refusals hold: no plex, below 1, duplicate in a plex;
    • two plexes may each have (1, 1);
    • gaps give exactly the expected warnings, each plex judged on its own numbers.
  • TmtFractionGap_IsQuantifiedAsNumberedAndWarned: two files of one plex as fractions 1, 3 and as 1, 2. The gap is warned about in the log and results.txt, and the peptide and protein quantification tables are identical.
  • TestSdrfDesignWritesAFractionGapAndBothSidesSaySo: see above.

Changed:

  • TestExperimentalDesignErrors: its non-consecutive biorep, fraction and techrep cases now expect no error and one warning each. Its duplicate, missing-file and non-integer cases are unchanged.
  • TestSdrfDesignRenumbersStudyWideReplicatesAndSaysSo is now TestSdrfDesignKeepsStudyWideReplicatesAndSaysSo: treated 3, 4 is written as 3, 4, read back with no error, and the pre-run check exits 0 and prints the warning.
  • TestSdrfDesignRefusesAFractionGapAndWritesNothing is now TestSdrfDesignRefusesADuplicateAndWritesNothing. A fraction gap is no longer refused, so the refusal it pins is now the one that is left.
  • GlycoTestWithBadExperimentalDesignFile: its bad design was a techrep gap, which is now valid. It is now a duplicate, so the test still checks that a bad design skips quantification and the search runs.

Falsified: each of ten mutations turned tests red, on the final code, and the restored source passed again (116 passed, 0 failed):

  • biorep refusal put back (4 red);
  • fraction-gap refusal put back (4);
  • label-free duplicate not refused (3);
  • no label-free warnings at all (6);
  • no search-task warning (2);
  • no command-line warning (2);
  • no results.txt line (2);
  • no TMT warning at search (1);
  • TMT duplicate not refused (1);
  • no TMT gap warnings (2).

Not covered: the glyco task's warning lines and both GUI windows' messages have no test (Test.csproj does not reference GUI).

Against master's code: with smith-chem-wisc#1426 and smith-chem-wisc#1422, master's TestSdrfDesignRenumbersStudyWideReplicatesAndSaysSo fails (it expects renumbered 3 -> 1, 4 -> 2). That is why smith-chem-wisc#1426 is labelled Breaks Integration Tests.

Full Test project against 9.9.1247: 2918 passed, 0 failed, 1 skipped (fd4742c15).

Not in this PR

🤖 Generated with Claude Code

trishorts and others added 2 commits October 7, 2026 13:07
…ing it

A condition whose biological replicates are not numbered 1..N (a lost
sample, or study-wide numbering such as control 1-2 / treated 3-4) was
refused as "biorep N is missing!", and the search skipped quantification.
mzLib smith-chem-wisc#1426 keeps the SDRF's numbers as written, so --sdrfDesign now
writes such designs.

GetErrorsInExperimentalDesign now checks fractions and techreps within
each biorep present; the new GetWarningsInExperimentalDesign names a
condition's missing biorep numbers. The search and glyco tasks, the CLI
design check and the GUI design window report it. The --sdrfDesign help
text no longer says replicates are renumbered.

Needs the mzLib release carrying smith-chem-wisc#1422 (normalization and the Bayesian
step walk the bioreps that exist) and smith-chem-wisc#1426; the pin bump follows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sults.txt, and give the TMT window's rules to EngineLayer

Label-free: GetErrorsInExperimentalDesign now refuses only a duplicate (two
files at one condition, biorep, fraction and techrep); a gap in fractions
or techreps is a warning, like a gap in bioreps.

TMT (smith-chem-wisc#2793): the TMT design window's ValidateDesign rules move into
TmtExperimentalDesign.GetErrorsInDesign / GetWarningsInDesign, so a test
reaches them; a gap in a plex's fractions or techreps is a warning there
and, for the first time, at search time.

Every gap warning is written with Warn and into results.txt
(AddTaskSummaryText), in the search, glyco and TMT paths, and is worded as
mzLib's SdrfLabelFreeDesign notes the same gap (smith-chem-wisc#1426):
"Condition "A" biorep 1: fractions 1, 3, quantified as numbered; fraction 2
is not in the design."

GlycoTestWithBadExperimentalDesignFile's bad design is now a duplicate,
since its techrep gap is valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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