Metabolite enrichment analysis and their associated enriched pathways.
MetENP is a R package that enables detection of significant metabolites from metabolite information (names or names and concentration along with metadata information) and provides
- Enrichment score of metabolite class,
- Maps to pathway of the species of choice,
- Calculate enrichment score of pathways,
- Plots the pathways and shows the metabolite increase or decrease
- Gets gene info, reaction info, enzyme info
For more info, check out the vignette. Contact: biosonal@gmail.com; kschoudhary@eng.ucsd.edu, Mano Maurya (mano@sdsc.edu) or Sumana Srinivasan (susrinivasan@eng.ucsd.edu).
A BioRxiv preprint on MetENP is available at: https://www.biorxiv.org/content/10.1101/2020.11.20.391912v1 (DOI: https://doi.org/10.1101/2020.11.20.391912). Please follow the details at the GitHub page (this page) to ensure you use the latest version.
Download the MetENP R package: On linux/unix command prompt (or download a zip file by clicking on "Code" and unpack the zip file to a local folder):
$git clone https://github.com/metabolomicsworkbench/MetENP.git MetENP
Start R and install devtools.
install.packages("devtools")
library("devtools")
MetENP package depends on following Bioconductor packages to function properly: KEGGREST, KEGGgraph, and pathview. You may need to install these via:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("KEGGREST")
BiocManager::install("KEGGgraph")
BiocManager::install("pathview")
- Through devtools
devtools::install("MetENP")
If you do not have admin priviligages, you can install the packages in the user area, e.g., /home/username/.local/R. Please see detailed instructions below.
If above steps give error: Install other dependencies and then try installing again: plyr,dplyr,tidyr,purrr,tidygraph,reshape2,ggplot2,ggrepel, igraph,ggraph,httr,stringr,jsonlite,rjson,tidyverse,magrittr
-
Through Anaconda
A conda environment.yml file is present in the repository.
This file can be used be with Anaconda to install all of the R requirements.Create the conda environment and activate the environment by running:
conda env create -n metenp -f environment.yml
conda activate metenp
If you do not wish to install, alternatively, download from github(https://github.com/metabolomicsworkbench/MetENP) and load libraries and functions
suppressMessages(library(plyr))
suppressMessages(library(dplyr))
suppressMessages(library(tidyr))
suppressMessages(library(tidygraph))
suppressMessages(library(KEGGREST))
suppressMessages(library(KEGGgraph))
#suppressMessages(library(KEGG.db)); # only for BiocManager version < 3.13
suppressMessages(library(pathview))
suppressMessages(library(reshape2))
suppressMessages(library(ggplot2))
suppressMessages(library(ggrepel))
suppressMessages(library(igraph))
suppressMessages(library(ggraph))
suppressMessages(library(httr))
suppressMessages(library(stringr))
suppressMessages(library(jsonlite))
suppressMessages(library(rjson))
suppressMessages(library(tidyverse))
suppressMessages(library(tictoc))
And load all the function with appropriate path (replace 'path' to your own path, e.g., they are inside R folder relative to the MetENP folder).
Please note this step is needed only when you do not wish to download or are hving difficulty in downloading the package
source('path/compoundinfo.R')
source('path/anova_ana.R')
source('path/met_pathways.R')
source('path/mapspspath.R')
source('path/metclassenrichment.R')
source('path/metcountplot.R')
source('path/getmwstudies.R')
source('path/path_enrichmentscore.R')
source('path/pathinfo.R')
source('path/plot_met_enrichment.R')
source('path/plot_volcano.R')
source('path/rxninfo.R')
source('path/significant_met.R')
source('path/significant_met_own.R')
source('path/enzyme_gene_info.R')
source('path/plot_heatmap.R')
source('path/plot_pathway_networks.R')
source('path/react_substrate.R')
source('path/dotplot_met_class_path.R')
source('path/convert_refmet.R')
source('path/map_keggid.R')
source('path/partial_join.R')
source('path/getExtension.R')
source('path/separate_data.R')
Now please follow example in the vignette
Run the vignette Jupyter Notebook on the web using My Binder:
The syntax of paths is for linux/unix operating system. It can be adjusted for Windows.
If already installed, this section can be ignored.
[[ for general information only:
basic commands: whereis python3 # can check version by starting python3
system python packages go to: /usr/lib/python3.9 /usr/lib64/python3.9 [if installed via sudo dnf] /usr/local/lib/python3.9 /usr/local/lib64/python3.9 [if installed via sudo pip3]
user/local python typically goes into $HOME/.local/various-folders
system R is at /usr/bin/R /usr/lib64/R
system R packages go into /usr/lib64/R/library
]]
Be in your home folder, /home/username:
# install jupyter in user area, in the folder /home/username/.local/bunch-of-folders
$pip3 install --user --no-cache-dir jupyter
# test it
$ jupyter notebook --ip=your_ip_address_format_123.249.124.012 --port=8080
Go to the page listed, e.g.,
http://123.249.124.012:8080/?token=4228fsdrjh346t3fdgve716452997a25f3e36b0dc2c3f02a3a0aa34
User can try to open any existing jupyter notebook if they are in the folder/subfolder
ctrl-C to stop
Install R package IRkernel # need to install R kernel for jupyter in user area; set libloc to user area, e.g., ${HOME}/.local/R if you do not have admin privileges.
# start R, being in home area ; > indicates R prompt
$R
>reposlink = 'http://cran.r-project.org'; libloc = "/usr/lib64/R/library/";
>pkgnames = c('IRkernel'); install.packages(pkgnames, repos=reposlink, lib=libloc);
>IRkernel::installspec() # for only current user
>q()
$ls -al .local/share/jupyter/kernels/
The output will appear similar to the lines below:
total 0
drwxrwxr-x. 4 username username 31 Nov 1 00:08 .
drwxrwxr-x. 7 username username 140 Nov 2 10:45 ..
drwxr-xr-x. 2 username username 64 Nov 1 00:08 ir
drwxrwxr-x. 2 username username 69 Oct 27 22:40 python3
# now jupyter notebooks based on R code should work after you select R kernel after starting jupyter
$ jupyter notebook --ip=123.249.124.012 --port=8080
If already installed, this section can be ignored.
Download or clone MetENP folder from github. Be careful not to overwrite existing folders [create and be in a different folder as needed].
$git clone https://github.com/metabolomicsworkbench/MetENP.git MetENP
The necessary files for installing MetENP R package are located inside the sub-folder R inside the MetENP folder.
# install MetENP R package in user area (e.g., /home/username/.local/R, or /home/username/some-folder/R):
$cd ~/.local; mkdir R;
If you want to install MetENP R package in the folder USER_PWD/R below, create the R folder.
[username@server one-level-up-of-MetENP]$mkdir R
[username@server one-level-up-of-MetENP]$R
# If devtools is not already installed for all, install it in system R or user R area (see how to set libloc below)
>USER_HOME=Sys.getenv("HOME"); # so that we don’t need to hard code /home/username
>reposlink = 'http://cran.r-project.org'; libloc = paste0(USER_HOME, “/.local/R/");
>#pkgnames = c("devtools"); install.packages(pkgnames, repos=reposlink, lib=libloc);
>library("devtools");
>devtools::install("MetENP", args = paste0("--library=", USER_HOME, "/.local/R")); # for unix local account # uses R CMD INSTALL
>USER_PWD=Sys.getenv("PWD");
>devtools::install("MetENP", args = paste0("--library=", USER_PWD, "/R")); # for unix local account # uses R CMD INSTALL
>q()
One-liner for the above:
>library("devtools"); USER_HOME=Sys.getenv("HOME");devtools::install("MetENP", args = paste0("--library=", USER_HOME, "/.local/R")); # for unix local account # uses R CMD INSTALL
>library("devtools"); USER_PWD=Sys.getenv("PWD");devtools::install("MetENP", args = paste0("--library=", USER_PWD, "/R")); # for unix local account # uses R CMD INSTALL
# if all went well, this would have installed MetENP in /home/username/.local/R (or current-folder/R)
$ ls -al /home/username/.local/R
# to check if MetENP can be loaded
$R
# modify .libPaths so that it can find R package MetENP
>USER_HOME=Sys.getenv("HOME");
>USER_PWD=Sys.getenv("PWD");
>.libPaths( c( .libPaths(), paste0(USER_HOME, "/.local/R") )); # since MetENP installed in user area, need to include that in path
>#.libPaths( c( .libPaths(), paste0(USER_PWD, "/R") )); # If installed in the R folder inside PWD
>library("MetENP") # should load without errors
# Now ready to run jupyter, being in a folder containing *.ipynb file, e.g.,
/path-to-MetENP-folder/vignettes/
$ jupyter notebook --ip=123.249.124.012 --port=8080
Go to webpage listed and open a MetENP jupyter notebook
Near top in that file, insert the lines, or some of these lines to set .libPaths and load MetENP R library.
USER_HOME=Sys.getenv("HOME");
USER_PWD=Sys.getenv("PWD");
.libPaths( c( .libPaths(), paste0(USER_HOME, "/.local/R") ))
#.libPaths( c( .libPaths(), paste0(USER_PWD, "/../../R") ))
library("MetENP") # Now, it should load without errors
When possible, it is best to adjust them using arguments passed to function. If that is not possible, e.g., because the corresponding variable cannot be set through the arguments passed, then make a copy of the relevant R file in the folder ..../MetENP/R, edit the file/function suitably and save. Then source the file, e.g.:
>source("PATH-TO-MetENP-FOLDER/R/significant_met_edited.R");
You may also have to load some libraries (see the lines with @importFrom in the R file) if such error messages are displayed. Once the edits are final, the edited file can be renamed (please keep a backup of the original file first) to the original file name and the MetENP package can be rebuilt using the steps above.
To update the documentation automatically after significant change such as adding or removing arguments to a function [2024/03/27]
Assuming that roxygen tags are also updated accordingly for adding/removing arguments (e.g., in the line(s) #'@param and the line after #'@examples), then use the commmand:
>devtools::document('MetENP')
This will update the .rd files inside MetENP/man; reinstall the MetENP package again using the procedure explained above.
Use the command rcmdcheck
>rcmdcheck("MetENP")
to identify errors/warning/notes.