R package for MetaboAnalyst
Switch branches/tags
Nothing to show
Clone or download
jsychong Merge pull request #18 from jotsetung/master
Update xcms/MetaboAnalystR vignette to use the new functions
Latest commit 5a90bef Aug 6, 2018


MetaboAnalystR: An R package for comprehensive analysis of metabolomics data


MetaboAnalystR contains the R functions and libraries underlying the popular MetaboAnalyst web server, including > 500 functions for metabolomic data analysis, visualization, and functional interpretation. The package is synchronized with the MetaboAnalyst web server. After installing and loading the package, users will be able to reproduce the same results from their local computers using the corresponding R command history downloaded from MetaboAnalyst, thereby achieving maximum flexibility and reproducibility.

Updates - 02/05/2018

We present a new update to MetaboAnalystR (In conjuction with the release of MetaboAnalyst Version 4.0) to enable comprehensive metabolomic data analysis, interpretation, and integration with other omics data. Three new modules have been added: 1) a module for pathway prediction from high-resolution mass spectral data using the mummichog algorithm; 2) a Biomarker Meta-Analysis module for robust biomarker identification through the combination of multiple metabolomic datasets; and 3) a Network Explorer module for integrative analysis of metabolomics, metagenomics, and/or transcriptomics data.

Getting Started

Step 1. Install package dependencies

To use MetaboAnalystR, first install all package dependencies. Ensure that you are able to download packages from bioconductor. To install package dependencies, enter the R function (metanr_packages) and then use the function. A printed message will appear informing you whether or not any R packages were installed. Note that we suggest you install the XCMS R package if you will be processing raw data, but is not necessary for the majority of MetaboAnalystR utilities.

Function to download packages:

metanr_packages <- function(){

  metr_pkgs <- c("Rserve", "ellipse", "scatterplot3d", "Cairo", "randomForest", "caTools", "e1071", "som", "impute", "pcaMethods", "RJSONIO", "ROCR", "globaltest", "GlobalAncova", "Rgraphviz", "preprocessCore", "genefilter", "pheatmap", "SSPA", "sva", "Rcpp", "pROC", "data.table", "limma", "car", "fitdistrplus", "lars", "Hmisc", "magrittr", "methods", "xtable", "pls", "caret", "lattice", "igraph", "gplots", "KEGGgraph", "reshape", "RColorBrewer", "tibble", "siggenes", "plotly")
  list_installed <- installed.packages()
  new_pkgs <- subset(metr_pkgs, !(metr_pkgs %in% list_installed[, "Package"]))
    biocLite(new_pkgs, dependencies = TRUE, ask = FALSE)
    print(c(new_pkgs, " packages added..."))
    print("No new packages added...")

Usage of function:


Step 2. Install the package

MetaboAnalystR is freely available from GitHub. The package documentation, including the vignettes for each module and user manual is available within the downloaded R package file. If all package dependencies were installed, you will be able to install the MetaboAnalylstR package. There are three options, A) using the R package devtools, B) cloning the github, C) manually downloading the .tar.gz file.

Option A) Install the package directly from github using the devtools package. Open R and enter:

Due to issues with Latex, some users may find that they are only able to install MetaboAnalystR without any documentation (i.e. vignettes).

# Step 1: Install devtools

# Step 2: Install MetaboAnalystR without documentation

# Step 2: Install MetaboAnalystR with documentation
devtools::install_github("xia-lab/MetaboAnalystR", build_vignettes=TRUE)

Option B) Clone Github and install locally

The * must be replaced by what is actually downloaded and built.

git clone https://github.com/xia-lab/MetaboAnalystR.git
R CMD build metaboanalystr
R CMD INSTALL MetaboAnalystR_*.tar.gz

Option C) Manual download of MetaboAnalyst.tar.gz and install locally

Manually download the .tar.gz file from here. The * must be replaced by what is actually downloaded and built.

cd ~/Downloads
R CMD INSTALL MetaboAnalystR_*.tar.gz

Case Studies

To demonstrate the functionality, flexibility, and scalability of the MetaboAnalystR package, three use-cases using two sets of metabolomics data is available here. In this folder you will find detailed discussions and comparisons with the MetaboAnalyst web-platform.


For detailed tutorials on how to use MetaboAnalystR, please refer to the R package vignettes. These vignettes include detailed step-by-step workflows with example data for each of the main MetaboAnalyt modules (11), as well as an example that demonstrates the ease of using XCMS and MetaboAnalystR for a holisitic metabolomic data analysis.

Within R:


Within a web-browser:



MetaboAnalystR has been developed by the XiaLab at McGill University.

The R package has been published!

If you use the R package, please cite us:

Within R:


Bugs or feature requests

To inform us of any bugs or requests, please open a new issue or send an email to #jasmine.chong@mail.mcgill.ca.

MetaboAnalystR History & Updates

07-03-2018 - Addition of XCMS to MetaboAnalystR tutorial

06-25-2018 - Publication of MetaboAnalystR in Bioinformatics

06-13-2018 - Addition of case studies + unit-testing + 3D visualization with plotly

05-25-2018 - Version Update: 1.0.1 - update underlying R code w. changes to MetaboAnalyst 4.09

04-20-2018 - Submission to CRAN

04-16-2018 - Testing with R Version 3.4.4

04-10-2018 - Updated underlying R code w. changes to MetaboAnalyst 4.0

03-23-2018 - Added 2 more package dependencies

02-23-2018 - Minor bug fixes based on user feedback (MetaboAnalystR_1.0.0.6.tar.gz)

02-05-2018 - Update MetaboAnalystR with 3 new modules in conjunction with the release of MetaboAnalyst Version 4