Efficiently predicting high resolution mass spectra with graph neural networks

Michael Murphy, Stefanie Jegelka, Ernest Fraenkel, Tobias Kind, David Healey, Thomas Butler · DOI

Abstract

Identifying unknown small molecules in metabolomics and drug discovery relies heavily on tandem mass spectrometry (MS/MS). However, the vast majority of chemical space lacks experimental reference spectra, necessitating the use of computational spectrum prediction. Current methods often struggle with a trade-off between computational efficiency and high-resolution accuracy. We present GrAFF-MS (Graph neural network for Approximation via Fixed Formulas of Mass Spectra), a novel framework that redefines spectrum prediction as a classification problem over a fixed vocabulary of molecular formulas. By leveraging the sparsity of fragment formulas, GrAFF-MS achieves state-of-the-art accuracy while operating orders of magnitude faster than existing physics-based models.

Introduction

In tandem mass spectrometry, molecules are fragmented, and the resulting mass-to-charge ratios ($m/z$) create a "chemical fingerprint." Identifying a molecule involves matching its experimental fingerprint against a library. When a molecule is not in the library, researchers must predict its spectrum from its 2D chemical structure.

Historically, this has been approached in two ways: bond-breaking simulations (e.g., CFM-ID) and mass-binning methods (e.g., NEIMS). Bond-breaking methods are physically grounded but computationally expensive, scaling poorly with molecular size. Mass-binning methods are fast but lack the high-resolution precision ($10^{-6}$) required to distinguish between different elemental compositions. GrAFF-MS bridges this gap by utilizing a fixed vocabulary of molecular formulas to maintain high resolution without the overhead of combinatorial simulations.

Methodology

The Fixed Vocabulary Innovation

A key insight of this research is the discovery of formula sparsity. While hundreds of thousands of fragment formulas are theoretically possible, the authors found that a tiny subset—approximately 2% of the total observed formulas—explains 98% of the signal across the NIST-20 dataset. GrAFF-MS utilizes a fixed vocabulary of the 10,000 most frequent formulas (representing both product ions and neutral losses) to transform prediction into a multi-label classification task.

Model Architecture

GrAFF-MS employs a Graph Isomorphism Network (GIN) to encode molecular structures. To provide the model with better "positional" awareness of atoms within the graph, the encoder is enhanced with Laplacian eigenvectors (SignNet). The model also incorporates experimental covariates, such as collision energy and instrument type, to ensure predictions are contextually accurate. The final output is a probability distribution across the 10,000-formula vocabulary.

Peak-Marginal Cross Entropy

To account for the finite resolution of mass spectrometers—where multiple distinct formulas might contribute to a single observed peak—the authors developed a Peak-marginal cross entropy loss function. This allows the model to learn effectively from ambiguous ground-truth data by marginalizing over all formulas compatible with a specific observed mass.

Experimental Results

Accuracy and Generalization

GrAFF-MS was evaluated on the NIST-20 dataset (~300,000 spectra) and the CASMI-16 dataset for independent validation. It achieved a mean cosine similarity of 0.70 on NIST-20 and 0.79 on CASMI-16, significantly outperforming CFM-ID (0.52/0.75) and NEIMS (0.60/0.63). Notably, the model demonstrates high chemical intelligence, successfully distinguishing between structural isomers that differ only by subtle bond orientations.

Computational Efficiency

The GNN-based architecture scales linearly with molecular weight, a significant improvement over the quadratic or worse scaling of bond-breaking methods.

  • Speed: GrAFF-MS is 16x faster than CFM-ID on a CPU for large molecules.
  • Throughput: On a single GPU, GrAFF-MS can predict a spectrum in 2.8ms.
  • Scalability: Predicting a library of 2.2 million molecules (e.g., ChEMBL) takes only 2 hours on one GPU, compared to 4 days using 64 parallel CPUs with previous state-of-the-art tools.

Discussion and Future Work

While GrAFF-MS represents a significant leap in efficiency, performance still declines as molecular weight exceeds 500 Da. Additionally, the fixed vocabulary approach may encounter limitations when dealing with rare or exotic chemical structures not represented in the top 10,000 formulas. Future research may focus on self-supervised pretraining on larger unlabeled chemical datasets to further refine the model's understanding of complex fragmentation chemistry.

By transforming a physics-based simulation into an efficient machine learning classification problem, GrAFF-MS provides a scalable solution for high-resolution mass spectrometry prediction, moving the field closer to real-time identification of unknown metabolites.

Summary updated

BibTeX
@inproceedings{murphy2023efficiently,
  author = {Michael Murphy and Stefanie Jegelka and Ernest Fraenkel and Tobias Kind and David Healey and Thomas Butler},
  title = {{Efficiently predicting high resolution mass spectra with graph neural networks}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=81RIPI742h},
}
Figure