- Introduced by
- Convergent development; foundational reviews by Liebal et al. (2020) and earlier multivariate metabolomics work by Trygg, Holmes, and Nicholson
- Year
- 2000s–2010s (rapid adoption 2015–present)
- Type
- Integrative analytical pipeline
- Family
- Bioinformatics / omics
What does it do?
Machine learning-assisted metabolomics analysis is an integrative bioinformatics pipeline that couples untargeted or targeted metabolite profiling, by mass spectrometry or NMR, with supervised and unsupervised machine learning (ML) algorithms to discover biomarkers, classify phenotypes, and model metabolic states.
Metabolomics datasets often have hundreds to thousands of correlated features and only tens to hundreds of samples, which makes classical univariate tests difficult to apply reliably. ML methods such as random forests, support vector machines, and neural networks are used to find multivariate and non-linear patterns in such data.
The intuition behind the method
A single biological sample yields a fingerprint of many small molecules. Metabolomics data usually contain far more features than samples, the features are correlated, and biological and technical noise is substantial. Under these conditions, testing one metabolite at a time is often unstable. ML methods can rank which metabolites separate a disease group from controls, predict a continuous trait such as drug response, or group samples into phenotypes, and they can accommodate non-linear relationships. The main difficulty is not running the algorithm but building a cross-validated pipeline that shows the discovered patterns are not overfitted to the particular samples or to instrument artefacts.
History
Multivariate analysis of metabolomics data was adopted in the early 2000s, with PCA and PLS-DA among the early tools. Earlier multivariate metabolomics work by Trygg, Holmes, and Nicholson preceded this development. As LC-MS became a major platform, dataset dimensionality grew, and rapid adoption of machine learning methods such as random forests, SVMs, and regularised regression has occurred since about 2015. Liebal et al. (2020) reviewed ML applications for mass spectrometry-based metabolomics, covering processing steps and biological interpretation.
When to use it
Use this pipeline when you have a high-dimensional metabolomics dataset and a defined biological question: biomarker discovery, phenotype classification, response prediction, or pathway activity estimation. It applies to both untargeted profiling and targeted panels. A common rule of thumb is more than about 100 features, at which point testing each metabolite separately becomes unstable; this is a heuristic, not a validated threshold. Sample size is the more binding constraint. With fewer than about 30 samples per class, overfitting risk is high, so strict nested cross-validation and permutation testing are needed and the results should be reported as exploratory. Do not apply supervised ML without a pre-specified outcome variable and validation plan; searching the data with ML and then reporting post-hoc p-values is a known route to irreproducible results.
Limitations and considerations
- Results depend heavily on preprocessing; errors in normalisation or batch correction carry through to the model and can dominate its output.
- Overfitting is a serious risk when the sample size is small relative to the feature count, which is common in metabolomics studies.
- Many high-performing models (gradient boosting, deep learning) are difficult to interpret directly, so mechanistic reading typically needs post-hoc tools such as SHAP.
- Feature annotation (linking MS peaks to known metabolites) is often incomplete; a strongly predictive feature may be unannotated or misannotated.
- Algorithm, hyperparameter, and validation choices vary between studies, which makes results difficult to compare and reproduce.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Handles the high dimensionality and multicollinearity of metabolomics feature matrices, where univariate tests on each metabolite become unstable.
- Can capture non-linear and interaction-driven patterns among metabolites that a linear model would miss.
- Produces ranked variable importance scores (for example random forest importance, PLS-DA VIP) that can guide the choice of metabolites for pathway analysis.
- Random forests are a common choice for noisy, mixed-quality data, but their behaviour with outlier samples and class imbalance depends on settings and should be checked on the dataset at hand.
- Applicable across LC-MS, GC-MS, and NMR platforms and across case-control, longitudinal, and multi-omics designs.
- When validated with nested cross-validation or an independent cohort, it can yield candidate biomarker panels with quantified predictive performance.
Applications
- Biomarker discovery for disease diagnosis and prognosis — identifying circulating metabolite signatures for cancer, diabetes, or cardiovascular disease.
- Drug response prediction — modelling how pre-treatment metabolite profiles predict therapeutic outcome or toxicity.
- Microbiome–metabolome interaction studies — linking gut microbial composition to host metabolic phenotypes.
- Food authenticity and quality control — classifying food origin, adulteration, or ripeness from metabolite fingerprints.
- Precision agriculture — profiling plant metabolomes to predict stress tolerance, yield, or nutritional quality.
- Multi-omics integration — combining metabolomics with genomics, transcriptomics, or proteomics layers in systems biology models.
- The areas above are illustrative examples rather than an exhaustive survey of the field.
How it works
How it works
Metabolite profiles are measured by LC-MS, GC-MS, or NMR. Raw spectra are converted to a feature matrix of peak intensities or areas (rows = samples, columns = metabolite features). Experimental design decisions made here, such as randomisation, quality-control (QC) injections, and pooled reference samples, affect all downstream steps and cannot be corrected afterwards.
The raw feature matrix is processed through peak alignment, missing-value imputation (for example k-NN or minimum-value substitution), normalisation (total ion count, probabilistic quotient, or median normalisation), and scaling (Pareto or unit-variance scaling). Drift between instrument runs is commonly corrected with QC-based methods such as LOESS-based batch correction. The aim is a matrix in which variance reflects biology rather than technical artefacts, although the choice and order of these steps should be justified for the dataset at hand.
Dimensionality is reduced before or within the ML step. Filter methods (univariate ANOVA, fold-change thresholds) remove low-variance or obviously non-significant features. Wrapper and embedded methods, such as LASSO regularisation, random forest variable importance, or recursive feature elimination, select a compact, informative subset. Retaining too many features risks overfitting; retaining too few risks missing relevant biology.
A supervised or unsupervised algorithm is fitted to the preprocessed, feature-selected matrix. Common supervised choices include partial least squares discriminant analysis (PLS-DA) for class separation, random forest and gradient boosting for classification or regression, and support vector machines. Unsupervised choices include PCA for exploratory visualisation and k-means or hierarchical clustering for phenotype discovery. Hyperparameters are tuned in an inner cross-validation loop nested inside an outer validation loop.
Performance is estimated by nested cross-validation (for example repeated 10-fold CV) or, when sample size permits, on an independent holdout set. Key metrics include AUC-ROC, accuracy, sensitivity and specificity for classification, and RMSE and R² for regression. Permutation tests provide a null distribution: the outcome labels are shuffled, the full pipeline is rerun, and an empirical p-value is computed as (k + 1) / (N + 1), where k is the number of permuted runs whose performance equals or exceeds the observed value and N is the total number of permutations. The smallest attainable p-value is 1 / (N + 1), so the number of permutations must be large enough to resolve the significance level of interest. For PLS-DA, the cross-validated Q² should be positive and reasonably close to R²Y; a Q² that is negative or well below R²Y indicates overfitting, and this comparison is the main check for it. Without permutation testing or independent validation, apparent performance is difficult to distinguish from chance, which limits how the results can be interpreted.
Variable importance scores (for example random forest mean decrease in impurity, PLS-DA VIP scores, or SHAP values) indicate which metabolites drive model predictions. Significant metabolites are mapped onto known metabolic pathways using resources such as KEGG, HMDB, or MetaboAnalyst to generate biological hypotheses. This step connects the statistical signal to a mechanistic interpretation, which still requires experimental confirmation.
Common pitfalls
- Data leakage: fitting scaling or feature selection on the whole dataset before splitting into training and test folds inflates performance estimates. These steps should be refitted inside each training fold.
- Neglected batch correction: uncorrected instrument drift can create groupings that the algorithm learns, producing high apparent accuracy that reflects technical artefacts rather than biology. Whether normalisation and batch correction must be refitted inside each fold is debated, so the chosen procedure should be stated and justified.
- Reporting accuracy without permutation testing: randomly permuting class labels and rerunning the full pipeline shows whether observed performance exceeds chance; without it, the result is hard to interpret.
- Treating importance as causation: a highly ranked metabolite contributes to model predictions but does not establish a causal role in the biological process; functional validation is needed.
- Overfitting in PLS-DA: PLS-DA is easily overfitted on small samples, so cross-validated Q² should be reported alongside R²Y, with permutation tests.
Frequently asked questions
How many samples do I need for a reliable ML-metabolomics study?
No universal threshold exists. As a rough working heuristic, about 30 to 50 samples per class is a common target for supervised classification. Below about 30 per class, nested cross-validation and permutation testing become essential and the results should be treated as exploratory. With fewer than 20 samples per class, the risk of overfitting is high whatever algorithm is used, and independent external validation on a separate cohort is strongly advisable before any clinical or translational claim.
Is PLS-DA a machine learning method?
PLS-DA is a supervised multivariate method that sits between classical chemometrics and machine learning. It learns a discriminant projection from labelled training data and predicts class membership, which is the same basic task as supervised ML. However, it is a linear model and less flexible than ensemble or deep learning methods. It remains a reasonable first-choice classifier when samples are limited, provided that cross-validation and permutation testing are applied rigorously.
What is the difference between untargeted and targeted metabolomics in this context?
Untargeted metabolomics measures all detectable metabolites at once (hundreds to thousands of features) without prior selection, which suits discovery. Targeted metabolomics measures a predefined set of metabolites with higher accuracy and reproducibility, which suits validation and clinical assays. ML methods are applied to both, but preprocessing differs: untargeted data require extensive annotation and filtering, while targeted data are often ready for direct modelling after standard QC.
Should I use SHAP values for interpretation?
SHAP (SHapley Additive exPlanations) values are recommended for non-linear or ensemble models (random forest, gradient boosting, neural network) because they decompose each prediction into per-feature contributions in a consistent, theoretically grounded way. Impurity-based random forest importance can favour features with many distinct values, so permutation-based or SHAP-based importance is commonly preferred for this reason. For linear models such as PLS-DA, VIP scores or regression coefficients are conventional and interpretable without SHAP.
Which tools or software are standard for this pipeline?
MetaboAnalyst (web-based, R back-end) is widely used for preprocessing, statistical analysis, and pathway mapping in metabolomics. For ML steps, Python libraries (scikit-learn, XGBoost, SHAP) and R packages (caret, mlr3, mixOmics) are common. XCMS and MZmine handle LC-MS peak detection and alignment. For multi-omics integration, MOFA+ and mixOmics DIABLO are established frameworks.
Related methods
Sources
Liebal, U. W., Phan, A. N. T., Sudhakar, M., Raman, K., & Blank, L. M. (2020). Machine learning applications for mass spectrometry-based metabolomics. Metabolites, 10(6), 243.
Open DOI referenceBylesjö, M., Rantalainen, M., Cloarec, O., Nicholson, J. K., Holmes, E., & Trygg, J. (2006). OPLS discriminant analysis: combining the strengths of PLS-DA and SIMCA classification. Journal of Chemometrics, 20(8-10), 341-351.
Open publication reference