Skip to content

MetGenX

Summary

MetGenX generates candidate metabolite structures directly from MS2 spectra for de novo metabolite annotation in untargeted metabolomics. Rather than encoding a query spectrum and generating structure "from scratch" (the conventional spectrum-to-structure formulation used by tools like Spec2Mol), MetGenX first retrieves structurally similar metabolites via spectral similarity search and uses them as generation templates — reframing the task as structure-to-structure generation. This structure-informed design achieved top-1 accuracy of 55.9% on 1,388 independent NIST test spectra and 68.5% on 1,681 spectra from real biological samples, outperforming existing in silico annotation tools, and it identified two metabolites absent from major human metabolome databases in mouse liver tissue.[1]

Architecture

Three sequential modules:

  1. Template search: the query MS2 spectrum is embedded into a 512-dimensional vector (Word2Vec-based textualization/embedding/pooling, chosen for speed and comparable retrieval quality to alternatives) and matched via cosine similarity against a reference spectral database to retrieve structurally similar template compounds.
  2. Template encoding: each retrieved template is encoded into a 3,898-dimensional feature vector — 3,878 bits of structural fingerprint, 10 bits of molecular formula, 10 bits of formula differences between template and query.
  3. Structure generation: concatenated template feature vectors feed an encoder that produces a latent structural representation, decoded by a 6-layer transformer decoder into a SMILES string. Two generation modes are supported: database-restricted (candidates matched against a user-defined background database by molecular formula, then guided by the generative model — higher accuracy when the target chemical space is known) and database-free (autoregressive generation conditioned on a specified molecular formula, enabling discovery of structures absent from any database). A LightGBM re-ranking model, trained on twelve features (spectral/structural similarity distributions, model score, candidate rank, molecular complexity, NP score, SMILES length), reorders generated candidates by structural plausibility relative to templates.

Training

A two-step pretrain/fine-tune scheme bridges structure-to-structure and spectrum-to-structure generation:

  1. Pretraining on 2.17 million compounds (0.52M metabolites/natural products from COCONUT, HMDB, NIST20, GNPS, plus 1.76M additional biologically relevant PubChem structures) for the structure-to-structure task, converging after 33 epochs.
  2. Fine-tuning on the NIST spectral database (23,213 compounds; 19,541 train / 2,172 validation / 1,500 test spectra) for the spectrum-to-structure task, with the epoch-4 checkpoint selected by early stopping.

Ablations confirmed structure pretraining and template search both substantially improve generation accuracy; re-ranking feature importance showed structural-similarity-derived features dominate ranking performance.

Performance

  • NIST independent test set (1,500 spectra; none seen during training): 92.5% of query spectra (1,388/1,500) retrieved at least one template. In database-restricted mode, top-1/top-3 accuracy rose from 48.9%/71.8% before re-ranking to 55.9%/76.1% after re-ranking. In database-free mode, top-1/top-3 accuracy reached 21.7%/35.0%, with 75.0% of top-3 candidates showing high structural similarity to the true target even when not an exact match.
  • Real biological samples (five sample types — cells, brain, liver, plasma, urine; 1,720 level-1-annotated spectra, NIST used as the full reference database): 97.7% (1,681/1,720) retrieved at least one template; database-restricted mode reached top-1/top-3 accuracy of 68.5%/89.2% (64.9%/85.3% when counted per unique metabolite). Top-3 accuracy varied by adduct (90.5% [M+H]⁺, 76.8% [M-H₂O+H]⁺, 60.0% [M+Na]⁺) and was notably strong for lipids, attributed to their structural regularity and template availability.
  • Template quality drives accuracy: more retrieved templates and higher template-target structural similarity both improved generation accuracy in both modes; maximum structural similarity above ~0.71 (Youden's J-optimal threshold) markedly increased correct-generation probability, while maximum spectral similarity alone was not predictive.
  • Novel metabolite discovery: applied to mouse liver untargeted metabolomics data, MetGenX identified two previously uncharacterized metabolites absent from major human metabolome databases.

Limitations

Because the re-ranking model is template-dependent, MetGenX's ability to fully explore chemical scaffolds with no structural precedent in the reference database may be constrained. Collision-energy mismatch between the reference and experimental spectra also affects template retrieval quality; matching reference NCE settings (e.g., NCE30) to experimental conditions improved both coverage and accuracy.

Availability

Source code: github.com/ZhuMetLab/MetGenX (CC BY-NC-ND 4.0). Model weights and databases: Zenodo.

See Also

  • MetDNA3 — a network-propagation metabolite annotation tool from the same group, addressing known/knowable metabolites rather than de novo structure generation.
  • DeepMet — a chemical language model that anticipates undiscovered metabolite structures independent of any query spectrum, complementary to MetGenX's spectrum-guided generation.

Citations

[1] Wang, H., Zhang, H., & Zhu, Z.-J. (2026). Structure-informed deep generation enables de novo metabolite annotation in untargeted metabolomics. Nature Communications, 17, 5426.