Troubleshooting Installing R Packages on Quest and Quest Analytics

Installing R Packages on the RStudio instance on the QUEST analytics node and QUEST Log-In Nodes.

Introduction

Due to technical limitations in RStudio Server, some R packages installed on Quest login nodes may not work when loaded in RStudio Server on the Quest Analytics nodes. If you would still like to use the graphical interface of RStudio but are unable to load all the R packages you need on Quest Analytics, you will need to launch RStudio within a graphical session on Quest. The simplest way is to use FastX: https://kb.northwestern.edu/quest-login.

The R environment of the Quest Analytics nodes includes the following modules:

R/4.2.3
gdal/3.1.3-R-4.1.1
proj/7.1.1
geos/3.8.1
hdf5/1.10.6-openmpi-3.1.3-gcc-8.4.0-R

Please check for files where you may have at some point accidentally hardcoded paths before starting these instructions. This includes ~/.bash_profile, ~/.bashrc, ~/.local/share/rstudio/Renviron, ~/.local/share/rstudio/.Rprofile, or ~/.R/Makevars.

If issues arise, you can delete the folder where R/4.12x packages get installed, which is (usually) ~/R/x86_64-pc-linux-gnu-library/4.2, and start again.

Seurat

Seurat is an R package designed for QC, analysis, and exploration of single-cell RNA-seq data.

Note: the commands can be run within an interactive R session, either on a Quest login node or an RStudio Server session.

On the Quest log-in node, create a script called build.R which contains the following lines or on the RStudio Server simply copy and paste them into your R command window:

Sys.setenv(INCLUDE = "/software/geos/3.8.1/include:/software/gcc/8.4.0/include")
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/geos/3.8.1/bin", old_path, sep = ":"))
install.packages("BiocManager", repos="https://cloud.r-project.org/")
install.packages("Rcpp", repos="https://cloud.r-project.org/")
install.packages("png", repos="https://cloud.r-project.org/")
BiocManager::install("multtest")
install.packages("Seurat", repos="https://cloud.r-project.org/")

On the Quest log-in node, run the follow commands on the command-line to install Seurat.

module purge all
module load R/4.2.3
module load geos/3.8.1
Rscript --vanilla "build.R"

Monocle3

The monocle3 package provides a toolkit for analyzing single-cell gene expression experiments. Single-cell transcriptome sequencing (sc-RNA-seq) experiments help discover new cell types and understand how they arise in development.

Note: the commands below should be run within an interactive R session, either on a Quest login node or an RStudio Server session:

Sys.setenv(INCLUDE = "/software/geos/3.8.1/include:/software/gcc/8.4.0/include:/software/proj/7.1.1/include")
Sys.setenv(PKG_CONFIG_PATH = "/software/sqlite/3.27.2/lib/pkgconfig:/software/proj/7.1.1/lib/pkgconfig:/software/gdal/3.1.3-R-4.1.1/lib/pkgconfig")
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/geos/3.8.1/bin", old_path, sep = ":"))
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/proj/7.1.1/bin", old_path, sep = ":"))
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/gdal/3.1.3-R-4.1.1/bin", old_path, sep = ":"))
install.packages("devtools", repos="https://cloud.r-project.org/")
install.packages("Rcpp", repos="https://cloud.r-project.org/")
install.packages("grr", repos="https://cloud.r-project.org/")
install.packages("https://cran.r-project.org/src/contrib/Archive/Matrix.utils/Matrix.utils_0.9.7.tar.gz",
	repos = NULL, type="source")
install.packages(c("shiny", "RCurl", "matrixStats", "futile.logger", "snow", "ggbeeswarm", "viridis", "RcppAnnoy",
	"RcppHNSW", "irlba", "rsvd", "igraph"), repos="https://cloud.r-project.org/")
install.packages(c("dplyr", "ggrepel", "lmtest", "pbapply", "pbmcapply", "pheatmap", "plotly", "plyr",
	"proxy", "pscl", "RANN", "reshape2", "rsample", "RhpcBLASctl", "Rtsne", "slam",
	"spdep", "speedglm", "uwot", "tidyr"), repos="https://cloud.r-project.org/")
install.packages("BiocManager", repos="https://cloud.r-project.org/")
BiocManager::install('DelayedArray', update = FALSE, ask = FALSE)
BiocManager::install(c("BiocNeighbors", "BiocSingular", "scater"), update = FALSE, ask = FALSE)
BiocManager::install(c('BiocGenerics', 'DelayedMatrixStats', 'limma', 'S4Vectors', 'SingleCellExperiment', 'SummarizedExperiment', 'batchelor'), update = FALSE, ask = FALSE)
devtools::install_github('cole-trapnell-lab/leidenbase')
devtools::install_github('cole-trapnell-lab/monocle3')

SF

The sf package provides support for simple features in R. It binds to 'GDAL' for reading and writing data, to 'GEOS' for geometrical operations, and to 'PROJ' for projection conversions and datum transformations. This package can also use the 's2' package for spherical geometry operations on geographic coordinates.

Note: the commands below should be run within an interactive R session, either on a Quest login node or an RStudio Server session:

Sys.setenv(INCLUDE = "/software/geos/3.8.1/include:/software/gcc/8.4.0/include:/software/proj/7.1.1/include")
Sys.setenv(PKG_CONFIG_PATH = "/software/sqlite/3.27.2/lib/pkgconfig:/software/proj/7.1.1/lib/pkgconfig:/software/gdal/3.1.3-R-4.1.1/lib/pkgconfig")
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/geos/3.8.1/bin", old_path, sep = ":"))
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/proj/7.1.1/bin", old_path, sep = ":"))
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/gdal/3.1.3-R-4.1.1/bin", old_path, sep = ":"))
install.packages("sf", repos="https://cloud.r-project.org/")

RGDAL

Provides bindings to the 'Geospatial' Data Abstraction Library ('GDAL') (>= 1.11.4) and access to projection/transformation operations from the 'PROJ' library. Use is made of classes defined in the 'sp' package. Raster and vector map data can be imported into R, and raster and vector 'sp' objects exported. The 'GDAL' and 'PROJ' libraries are external to the package, and, when installing the package from source, must be correctly installed first; it is important that 'GDAL' < 3 be matched with 'PROJ' < 6. From 'rgdal' 1.5-8, installed with to 'GDAL' >=3, 'PROJ' >=6 and 'sp' >= 1.4, coordinate reference systems use 'WKT2_2019' strings, not 'PROJ' strings.

Note: the command below should be run within an interactive R session, either on a Quest login node or an RStudio Server session:

Sys.setenv(INCLUDE = "/software/geos/3.8.1/include:/software/gcc/8.4.0/include:/software/proj/7.1.1/include")
Sys.setenv(PKG_CONFIG_PATH = "/software/sqlite/3.27.2/lib/pkgconfig:/software/proj/7.1.1/lib/pkgconfig:/software/gdal/3.1.3-R-4.1.1/lib/pkgconfig")
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/geos/3.8.1/bin", old_path, sep = ":"))
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/proj/7.1.1/bin", old_path, sep = ":"))
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/gdal/3.1.3-R-4.1.1/bin", old_path, sep = ":"))
install.packages("rgdal", repos="https://cloud.r-project.org/",)

hdf5r

Note: the command below should be run within an interactive R session, either on a Quest login node or an RStudio Server session:

old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("/software/hdf5/1.10.6/bin", old_path, sep = ":"))
install.packages("hdf5r", repos="https://cloud.r-project.org/",)

RJAGS

The rjags package provides an interface from R to the JAGS library for Bayesian data analysis. JAGS uses Markov Chain Monte Carlo (MCMC) to generate a sequence of dependent samples from the posterior distribution of the parameters

Note: the commands below must be run in a terminal session on a Quest login node.

On the Quest log-in node, create a script called build.R which contains the following lines:

install.packages("Rcpp", repos="https://cloud.r-project.org/")
install.packages("rjags", repos="https://cloud.r-project.org/")
On the Quest log-in node, run the follow commands on the command-line to install RJAGS.
module purge all
module load R/4.2.3
module load jags
Rscript --vanilla "build.R"

V8/RSTANARM/RSTAN

The rstan package is the R interface to Stan. User-facing R functions are provided to parse, compile, test, estimate, and analyze Stan models by accessing the header-only Stan library provided by the 'StanHeaders' package. The Stan project develops a probabilistic programming language that implements full Bayesian statistical inference via Markov Chain Monte Carlo (MCMC), rough Bayesian inference via 'variational' approximation, and (optionally penalized) maximum likelihood estimation via optimization. In all three cases, automatic differentiation is used to quickly and accurately evaluate gradients without burdening the user with the need to derive the partial derivatives.

Note: the commands below must be run in a terminal session on a Quest login node.

On the Quest log-in node, create a script called build.R which contains the following lines:

install.packages("V8", repos="https://cloud.r-project.org/")
install.packages(c("rstanarm", "rstan"), repos="https://cloud.r-project.org/")

On the Quest log-in node, run the follow commands on the command-line to install V8/RSTANARM/RSTAN.

module purge all
module load R/4.2.3
DOWNLOAD_STATIC_LIBV8=1 Rscript --vanilla "build.R"

DiffBind

DiffBind is an R package that is used for identifying sites that are differentially enriched between two or more sample groups. It helps to compute differentially bound sites from multiple ChIP-seq experiments using affinity (quantitative) data and allows occupancy (overlap) analysis and plotting functions.

Note: the commands below must be run in a terminal session on a Quest login node.

On the Quest log-in node, create a script called build.R which contains the following lines:

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("V8")
BiocManager::install("DiffBind")

On the Quest log-in node, run the follow commands on the command-line to install DiffBind.

mkdir -p ~/.R/
echo CC=gcc >> ~/.R/Makevars 
DOWNLOAD_STATIC_LIBV8=1 Rscript --vanilla "build.R"
Was this helpful?
0 reviews

Details

Article ID: 1834
Created
Thu 5/12/22 12:39 PM
Modified
Mon 10/2/23 12:18 PM