Multi-scale Sinusoidal Embeddings Enable Learning on High Resolution Mass Spectrometry Data

Gennady Voronov, Rose Lightheart, Joe Davison, Christoph A. Krettler, David Healey, Thomas Butler · DOI

Abstract

Tandem Mass Spectrometry (MS2) is a cornerstone of metabolomics, yet standard machine learning approaches often sacrifice high-resolution data through discretization or "binning." We present a novel SpectrumEncoder architecture that employs multi-scale sinusoidal embeddings to treat mass-to-charge ratios ($m/z$) as continuous variables. By capturing sub-millidalton precision, our model leverages "fractional mass" signals to achieve state-of-the-art accuracy in spectral library searches and chemical property prediction. The sinusoidal approach demonstrates superior generalization to novel chemistry, outperforming traditional tokenization methods by 11% in $R^2$ for property prediction on unseen molecular structures.

The Challenge of High-Resolution MS2 Data

Modern mass spectrometry instruments offer "parts per million" (ppm) resolution, providing precise measurements of molecular fragments. However, most existing machine learning models round these $m/z$ values to the nearest 0.1 Dalton. This "binning" process results in significant information loss, particularly regarding the "fractional mass"—the decimal portion of a mass value that serves as a signature for a molecule's specific atomic composition.

Furthermore, binning introduces edge effects where nearly identical masses are separated into different tokens, and it makes it difficult for models to learn chemical relationships (such as the loss of a water molecule) without vast amounts of training data. To address these issues, researchers at Enveda Biosciences developed a method to represent MS2 data without discarding its inherent precision.

The SpectrumEncoder Architecture

The core innovation of this work is the Multi-scale Sinusoidal Embedding. Rather than tokenizing $m/z$ values, the model uses a series of sine and cosine functions to encode them. These embeddings utilize log-spaced wavelengths ranging from $10^{-2.5}$ Daltons to $10^{3.3}$ Daltons, allowing the model to capture everything from sub-millidalton precision to the full mass of large molecules.

The SpectrumEncoder architecture integrates m/z and intensity data into peak embeddings, which are then processed by a permutation-invariant Transformer to produce a comprehensive spectrum embedding.

As shown in the architecture above, the model treats mass spectra as unordered sets of peaks. A Transformer encoder, which is naturally permutation-invariant, processes these peaks. The "precursor" ion (the original molecule) is treated as a special starting point for the embedding process, ensuring the model maintains context for the fragments it analyzes.

Results and Latent Space Analysis

The model was trained on a massive dataset of over 1.2 million labeled MS2 spectra. In spectral library search benchmarks, the sinusoidal model achieved a state-of-the-art accuracy of 0.937, significantly outperforming established methods like Spec2Vec (0.903) and MS2Deepscore (0.852).

Beyond simple identification, the model successfully predicted 10 different chemical properties (such as LogP and aromatic ring counts) with an average $R^2$ of 80% for novel compounds. A key finding was that performance significantly degraded when using lower-precision floats (float16), confirming that the model is actively harvesting signal from high-resolution data that was previously considered noise.

UMAP visualization of the latent space generated by double-precision sinusoidal embeddings, showing a highly structured organization based on chemical properties.

Visualizing the latent space via UMAP reveals that the high-precision sinusoidal embeddings create a highly structured environment. Unlike binned models that produce disorganized clusters, this approach organizes fragments by their fractional mass, effectively "learning" fundamental chemistry directly from the numerical data.

Conclusion and Future Directions

By treating mass-to-charge ratios as continuous values, multi-scale sinusoidal embeddings allow Transformer models to reason about chemistry with unprecedented precision. While the current model focuses on small molecules (< 1,000 Daltons), future work aims to scale these embeddings for proteomics and integrate additional experimental metadata, such as collision energy, to further refine identification accuracy. This approach marks a shift away from NLP-inspired tokenization toward a more physically grounded representation of scientific data.

Summary updated

BibTeX
@misc{voronov2022multi,
  author = {Gennady Voronov and Rose Lightheart and Joe Davison and Christoph A. Krettler and David Healey and Thomas Butler},
  title = {{Multi-scale Sinusoidal Embeddings Enable Learning on High Resolution Mass Spectrometry Data}},
  year = {2022},
  eprint = {2207.02980},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2207.02980},
}
Figure