Ratio-Invariant Scoring for Regioisomers in Tandem Mass Spectrometry

Tandem mass spectrometry (MS/MS) weighs a molecule, smashes it, and records the masses and intensities of the fragments. It is the standard way to identify small molecules in complex mixtures. Regioisomers are molecules with the same atoms attached at different positions on a ring. They have identical mass and mostly shared fragments, so they differ only in how intense a few fragment peaks are. Those relative intensities also drift with collision energy, ion transmission and instrument type. As a result, the same signal that tells two regioisomers apart is the one most corrupted by the instrument. Particle physicists faced the same structure of problem in tests of lepton universality, the prediction that electrons and muons couple identically to the weak force. They solved it by measuring ratios of two channels, so that shared, poorly known factors cancel. They then reported the channel-specific effects that do not cancel as an explicit systematic error budget.

We propose to carry that discipline into MS/MS. Isomer candidates would be scored only through log-ratios of fragment peaks chosen so that smooth instrument effects cancel to first order. The part that does not cancel would be measured and reported as a calibrated residual systematic uncertainty, rather than being absorbed silently into a neural score. The motivating application is synthesis. Radical cyclizations onto meta-substituted rings routinely give near 50:50 regioisomer mixtures (Photocatalytic generation of amidine carbon radicals), and chemists would benefit from reading regioisomer ratios from crude LC-MS/MS runs across instruments with honest error bars.

Core Claim

A large share of the drop in cross-instrument isomer ranking comes from multiplicative distortions that are shared and smooth in fragment mass. Fragment-pair log-ratios cancel these by construction. We claim a scorer restricted to such ratios will lose little accuracy within one instrument type and lose much less than standard encoders when moved from one instrument type to another (QTOF to Orbitrap or back). What survives is mostly fragment-specific dependence on collision energy. We expect that residual to be small and measurable, and to set the precision floor for regioisomer quantification.

The mechanism can be stated in one line. Suppose the measured intensity of fragment $k$ at mass $m_k$ is $y_k = A \, T(m_k) \, b_k$. Here $A$ is overall ion yield, $T$ is the instrument's transmission and detector response as a function of mass, and $b_k$ is the structure-dependent branching into that fragment. For two fragments within a mass window $\Delta$ of each other,

$$\log\frac{y_j}{y_k} = \log\frac{b_j}{b_k} + O\!\left(\Delta \cdot \frac{d\log T}{dm}\right),$$

so $A$ cancels exactly and $T$ cancels to first order. This is the same bookkeeping as the pion measurement $R_{e/\mu}$ in Improved Measurement of the π→eν Branching Ratio. That paper cancels the decay constant and the quark-mixing matrix element by taking a ratio. It still carries a systematic error of ±0.0019 against a statistical error of ±0.0023, coming from lepton-specific detector effects. The analogue in our setting is fragment-specific collision-energy dependence, which the ratio does not remove. We plan to measure that term directly rather than assume it away.

Relation to Prior Work

The machine-learning structure-elucidation line supplies the task and the hardest failure mode. DiffMS and MADGEN generate molecular graphs with diffusion from spectral embeddings. FlowMS does the same with formula-constrained flow matching. GEMS searches over same-formula isomers by local bond edits and scores candidates with a forward spectrum predictor. All of these name positional isomers as the dominant failure. None separates instrument nuisance from structural signal. GEMS also reports that cosine similarity to simulated spectra is a poor ranker because decoys share major peaks. We read that as evidence that the discriminating information sits in relative intensities of a few peaks. Our scorer is a candidate re-ranker that could sit on top of any of these generators; it does not compete with them as a generator.

Two audits constrain our design. MassSpecGym in the Wild found evaluation flaws in 17 of 26 papers, including leakage through auxiliary tools, SMILES typography shortcuts, popularity bias, and a MIST masking bug that inflated Tanimoto similarity from 0.37 to 0.52. We therefore use their data-safe splits and include a spectrum-blind popularity control. Small molecule retrieval from tandem mass spectrometry: what are we optimizing for? shows that listwise contrastive losses beat fingerprint-reconstruction losses on equal-formula retrieval. So our scorer is trained with that listwise loss, and the only change is its input representation.

The synthesis literature provides the application regime. The photocatalytic amidine-radical work documents the near-degenerate ortho cyclization barriers that yield regioisomer mixtures. The Petasis interception of the α-iminol rearrangement ( Intercepting an avoided α-iminol rearrangement with a Petasis reaction for the synthesis of 2,3-diaryl substituted indoles) shows how a single catalyst omission diverts products to constitutional isomers (2,2-diaryl indolin-3-ones). Both assess selectivity by isolation and NMR, and neither quantifies crude isomer ratios spectrometrically.

We are not claiming that peak-intensity ratios are new in analytical chemistry. Targeted assays commonly use ion-ratio checks, although the file contains no paper we can cite for this. Our contribution has three parts: restricting a learned open-candidate scorer to transmission-cancelling ratios, testing that choice directly under instrument shift, and reporting the non-cancelling residual as a calibrated systematic uncertainty.

Research Program

The first component is a nuisance study on MassSpecGym ( MassSpecGym: A benchmark for the discovery and identification of molecules). The benchmark has 231,000 spectra from 29,000 structures, with instrument and collision-energy metadata. We will take molecules measured on both QTOF and Orbitrap and fit the factorized model above per molecule. This estimates how much cross-instrument intensity variance is explained by a global scale plus a smooth mass-dependent transmission curve, and how much remains fragment-specific. If the smooth part explains little, the core claim fails early and cheaply.

The second component is the scorer. Each spectrum is converted to a set of log-ratios between fragment pairs within a window $\Delta$, tagged with both fragment masses and the collision energy. A permutation-invariant set encoder, of the same size as the baseline encoder, scores each same-formula candidate. It is trained with the listwise contrastive loss from the retrieval paper on the data-safe v1.5 split. The window $\Delta$ is the one real design knob. Small windows cancel transmission better but discard more pairs, and we will sweep it.

The third component is a residual systematic budget. Following the physics practice of treating what the ratio fails to cancel as its own error term, we fit a per-ratio variance model as a function of collision-energy mismatch and $\Delta$ on held-out paired spectra. We then propagate that variance to candidate scores and to mixture-fraction estimates, producing intervals whose coverage can be checked.

The fourth component is a regioisomer-mixture validation. We will prepare gravimetric mixtures of commercially available ring-positional isomer pairs at known fractions, from 50:50 to 95:5, and measure each on one QTOF and one Orbitrap across a collision-energy sweep. The fraction is estimated by fitting observed ratios as a mixture of the two pure-isomer ratio signatures.

Baselines

The naive reference points are two spectrum-blind controls. The first is formula-filtered random ranking, which MassSpecGym in the Wild reports lifts Hit@1 from 0.43% to 12.98%. The second is ranking by PubChem popularity, which the same audit shows outperforms several published networks. Any method that does not clear both on the equal-formula task, and specifically on our positional-isomer subset, has learned nothing about fragmentation.

The strongest existing retrieval systems are MIST and the best listwise contrastive model. MassSpecGym reports Hit@1 of 14.6% for MIST on retrieval. The loss-function study reports Hit@1 of 13.62% for its best contrastive model on the equal-formula task, against 6.48% for IoU-trained models. We will retrain the contrastive model ourselves on the identical v1.5 data-safe split, with its bug-corrected encoder, the same parameter count, the same number of training steps and the same hyperparameter search budget. It is the right competitor because it already optimizes the correct objective for isomer discrimination and differs from our scorer only in how the spectrum enters. Beating it means one of two things. In-distribution, the ratio scorer matches it within noise. Under the instrument-shift split, it keeps a clearly larger fraction of its in-distribution Hit@1, with the gap exceeding seed-to-seed variation over at least five seeds.

For forward-simulator scoring we include cosine similarity against FraGNNet predictions; MassSpecGym reports simulation cosine similarity of 0.52. We also include GEMS-style scoring by the learned stop probability, where code permits. On regioisomer candidates GEMS reports 30.48% NIST top-1 as a generator. We will not compare against that figure directly, because it is a different task. Instead we test whether re-ranking GEMS's final candidate pool with our scorer changes accuracy on the CASMI out-of-distribution set.

The key ablation isolates the ingredient. We keep our exact set encoder and loss but feed it normalized raw intensities with instrument and collision-energy metadata, and train with random smooth transmission-curve augmentation. If this matches the ratio scorer under shift, the cancellation adds nothing that augmentation cannot supply.

Why not just…?

Why not just condition the encoder on instrument and collision energy and augment with random transmission curves? This is the most serious threat. A flexible model given the metadata could learn to undo smooth distortions. It is therefore our central ablation, not a side comparison. Hard-wired cancellation should have an advantage only when the test instrument's transmission curve lies outside the augmentation family, or when training covers few instrument-energy combinations. We will test both by restricting the training set to one instrument. If the augmented model wins or ties there too, we will present the ratio scorer as an interpretable baseline plus the residual-budget method. The budget does not depend on which scorer wins.

Why not just use cosine similarity against a forward simulator? Cosine similarity on normalized spectra already cancels global scale, so its failures are informative. GEMS reports that it is a poor ranker because decoy isomers share major peaks. MassSpecGym shows the simulator itself reaches only 0.52 cosine similarity. Cosine similarity is dominated by the largest shared peaks, while regioisomer information lives in the ratios of minor diagnostic peaks. We include it as a baseline to show this on the positional subset.

Why not just take NMR of the crude reaction mixture to get regioisomer ratios? For a single well-behaved reaction, NMR is often the better tool, and we say so. The case for MS/MS is throughput, trace components, overlapping signals in complex crudes, and labs that run only LC-MS. The mixture experiment will report whether our intervals are tight enough, for example within a few percentage points of the true fraction, to be useful where NMR is impractical. If they are not, the synthesis application should be dropped.

Why not just collect more replicate scans? Replicates shrink random error but reproduce the instrument's transmission bias exactly. This is the precision-floor argument documented across the precision experiments in the file, from PIENU to MAGIC ( Performance of the MAGIC stereo system obtained with Crab Nebula data). The mixture study measures it directly. We compare the error of the fraction estimate from many scans on the wrong instrument's calibration with that of the ratio estimate.

Decisive Checks

The first check is the variance decomposition. If a global scale plus a smooth transmission curve explains less than roughly half of the cross-instrument log-intensity variance on paired molecules, the premise is wrong and we stop.

The second is the shift experiment. We train on QTOF and test on Orbitrap, and the reverse, on the equal-formula task and on a positional-isomer subset. The subset is built from candidate pairs that differ only by substituent position on a ring. We report Hit@1, retention relative to in-distribution Hit@1, and the popularity and random controls. For generative-model context we note that FlowMS reports 9.15% top-1 on NPLIB1, but we will not use that as a comparison for retrieval.

The third is the $\Delta$ sweep. Robustness under shift should improve as $\Delta$ shrinks, until too few pairs remain. That shape is the direct signature of first-order cancellation, and its absence would mean gains come from something else.

The fourth is interval calibration on the gravimetric mixtures. We report absolute error in estimated regioisomer fraction per instrument and per collision energy. We also check whether the propagated residual-systematic intervals achieve their nominal coverage. Well-calibrated coverage, not just point accuracy, would show that the physics habit of budgeting what the ratio fails to cancel transfers to molecular analysis.