Skip to contents

R-CMD-check pages-build-deployment

An R library for NMR-based metabolic profiling

metabom8 (pronounced metabo-mate) provides pipelines for 1D NMR data import, preprocessing, multivariate modeling (PCA, O-PLS), metabolite identification, and visualization — with core functions accelerated using C++ (Rcpp, Armadillo, Eigen) for improved computational performance.


🛠️ Features

  • Preprocessing and analysis of 1D NMR and MS spectral data
  • Unsupervised PCA and supervised OPLS-DA modeling
  • Orthogonal Partial Least Squares (OPLS) with automatic selection of the optimal number of predictive and orthogonal components
  • Robust statistical validation: k-fold and stratified Monte Carlo CV
  • Metabolite identification via STOCSY (Statistical Total Correlation Spectroscopy)
  • Custom plotting functions using ggplot2 and plotly
  • Native C++ acceleration via RcppArmadillo and RcppEigen

📦 Installation

install.packages("remotes")
remotes::install_github("tkimhofer/metabom8")

🚀 Quick Start

library(metabom8)
library(nmrdata)

# Load example data
data(bariatric, package = "nmrdata")

idx <- bariatric$an$Class %in% c("Pre-op", "RYGB")
X <- bariatric$X.pqn[idx, ]
Y <- bariatric$an$Class[idx]

# Fit an OPLS model using Monte Carlo Cross-Valdation
model <- opls(
  X = X,
  Y = Y,
  center = TRUE,
  scale = "UV",
  cv = list(method = "MC", k = 7, split=2/3)
)

# Plot scores and loadings
plotscores(model)
plotload(model)

⚡ Performance

Benchmarked against the ropls package under identical conditions using the bench package:

bench::mark(
  metabom8 = metabom8::opls(X, Y, ...),
  ropls    = ropls::opls(X, Y, predI = 1, orthoI = 1, ...),
  check = FALSE
)
Method Median Time Iter/sec Memory Use
metabom8 1.61 sec 0.621 2.81 GB
ropls 3.95 sec 0.253 1.61 GB

metabom8 provides a ~2.5× speed-up using C++ linear algebra (Eigen, Armadillo) when compared to widely used implementations [^1].

[^1]: Benchmark comparison uses the ropls package (Bioconductor), a widely used OPLS implementation (parameters: uv scaling, 7-fold CV, 1 predictive + 1 orthogonal component).

📘 Documentation

Comprehensive documentation and vignettes are available at:
🔗 https://tkimhofer.github.io/metabom8/


  • nmrdata: Example dataset for NMR spectral analysis (used for performance comparison)

If you find metabom8 useful, please consider giving it a ⭐ — it makes it easier for others to discover the project!


📝 License & Citation

MIT License © Torben Kimhofer
If metabom8 or any of its components contributes to your work, please ensure appropriate citation. See CITATION.cff for citation details.


🙋 Getting Help

  • Found a bug? Open an issue
  • Want to contribute? Fork the repo and submit a pull request
  • Code of Conduct: see CODE_OF_CONDUCT.md

Built with 💙 by @tkimhofer