Local installation of MetaboAnalyst

MetaboAnalyst is a great tool for analysis of metabolomics data. Here are some tips how to install MetaboAnalyst locally on a linux workstation. Such installation could be tailored to meet individual requirements (default setting, fonts, etc.).
Starting point is a runnig installation of Ubuntu 18.04.3 LTS.

Setting up the environment

Update your system and install additional packages. Set the workstation to be visible only within the local network so security won’t be an issue.

# Add repository for R 3.6 in Ubuntu 18.04
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install software-properties-common wget unzip libnetcdf-dev graphviz libxml2-dev libcairo2-dev default-jdk r-base-dev libssl-dev
# lib-ssl is needed for R-serve download
sudo apt-get install r-cran-rserve

Setting up R

Install all R-packages via Bioconductor

# Run R as user
R
if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install()

BiocManager::install(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", "xcms", "CAMERA", "fgsea", "MSnbase", "BiocParallel", "metap", "reshape2", "scales"))

Update all installed packages, if needed, using parallel processes.

setRepositories()
options(Ncpus = 8)
install.packages( 
    lib  = lib <- .libPaths()[1],
    pkgs = as.data.frame(installed.packages(lib), stringsAsFactors=FALSE)$Package,
    type = 'source'
)

Setting Java

MetaboAnalyst works well with Java 8.

sudo apt update
sudo apt install openjdk-8-jdk openjdk-8-jre
java -version

If needed, select the appropriate one.

sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press  to keep the current choice[*], or type selection number:
# Set Java environment
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

Install GlassFish

Create a dedicated account for the GlassFish server.

#Add a new user called glassfish
sudo adduser --home /home/glassfish --system --shell /bin/bash glassfish
 
#add a new group for glassfish administration
sudo groupadd glassfishadm
 
#add your users that shall be Glassfish adminstrators
sudo usermod -a -G glassfishadm $myAdminUser
 
#in case you want to delete a group some time later (ignore warnings):
#delgroup glassfishadm

Get the latest GlassFish from Eclipse foundation. Or older one from Oracle.

cd /home/glassfish/
wget https://www.eclipse.org/downloads/download.php?file=/glassfish/glassfish-5.1.0.zip
# sudo wget http://download.oracle.com/glassfish/5.0.1/nightly/latest-glassfish.zip
unzip glassfish-5.1.0.zip -d /home/glassfish

Fix GUI deploy error (optional)

# update jar file
# jar uf jar-file input-file(s)
in console-common.jar!applications/uploadFrame.jsf

change <sun:form id="form"> to <sun:form id="form" enctype="multipart/form-data">

Set the GlassFish Service

sudo nano /etc/systemd/system/glassfish.service
[Unit]
Description = GlassFish Server v5.1 local MetaboAnalyst
After = syslog.target network.target

[Service]
ExecStart=/home/glassfish/glassfish5/bin/asadmin start-domain
ExecReload=/home/glassfish/glassfish5/bin/asadmin restart-domain
ExecStop=/home/glassfish/glassfish5/bin/asadmin stop-domain
Type = forking

[Install]
WantedBy = multi-user.target
# Reload services
sudo systemctl daemon-reload
# Start GlassFish
sudo systemctl start glassfish
# Get service status
sudo systemctl status glassfish
# Add to path
export PATH=/home/glassfish/glassfish5/bin:$PATH
# Secure GlassFish console and GUI, set password
asadmin change-admin-password
# Enable the feature
asadmin enable-secure-admin
# Restart Glassfish
sudo systemctl restart glassfish

Webserver address: http://<server-ip-address>:8080

GUI admin console address: http://<server-ip-address>:4848

Deploy MetaboAnalyst

cd /home/glassfish
# https://www.metaboanalyst.ca/MetaboAnalyst/faces/docs/Resources.xhtml
wget https://www.dropbox.com/s/9xo4yy3gzqsvyj9/MetaboAnalyst-4.93.war?dl=1
cd /home/glassfish/glassfish5/bin
asadmin deploy /home/glassfish/MetaboAnalyst-4.93.war
# or use web GUI
# Run R-serve as glassfish user
R CMD Rserve

MetaboAnalyst will be running at http://<server-ip-address>:8080/MetaboAnalyst-4.93/. Change the path using GUI if needed.

Final configuration

  • Rserve v1.7-3
  • R version 3.6.1 (2019-07-05) — „Action of the Toes“
  • Bioconductor version 3.9 (BiocManager 1.30.4)
  • openjdk version „1.8.0_222“
  • OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
  • OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
  • GlassFish 5.1, Ubuntu 18.04.3 LTS

List of sources