/
2024-2: 7c.2 Installing other R packages on HPC
2024-2: 7c.2 Installing other R packages on HPC
Installing R packages on the HPC (when you come to do your own DE and FA analysis)
When you come to running your own R scripts on the HPC, you will need to install the packages your script needs. We have done this for you for this training session but to install your own packages you can follow a procedure like this:
First, in RStudio create a new R script (File → New File → R script), and save as install.R
# This line will use the Canberra mirror for CRAN
chooseCRANmirror(graphics = getOption("menu.graphics"), ind = 3, local.only = TRUE)
# Sometimes you need to install packages from github, like this:
install.packages("devtools")
devtools::install_github("YuLab-SMU/ggtree")
# Sometimes you will have bioconductor packages
bioconductor_packages <- c("clusterProfiler", "pathview", "AnnotationHub", "org.Hs.eg.db")
# Sometimes you will have CRAN packages
cran_packages <- c("tidyverse", "ggplot2", "plyr", "readxl", "scales")
# Compares installed packages to above packages and returns a vector of missing packages
new_packages <- bioconductor_packages[!(bioconductor_packages %in% installed.packages()[,"Package"])]
new_cran_packages <- cran_packages[!(cran_packages %in% installed.packages()[,"Package"])]
# Install missing bioconductor packages
# You may need to change the version of BiocManager depending on the bioconductor packages you need to install
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager", version = "3.16")
BiocManager::install(new_packages, dependencies = TRUE, INSTALL_opts = '--no-lock')
# Install missing cran packages
if (length(new_cran_packages)) install.packages(new_cran_packages, repos = "https://cran.csiro.au/")
# Update all installed packages to the latest version
update.packages(bioconductor_packages, ask = FALSE)
update.packages(cran_packages, ask = FALSE, repos = "https://cran.csiro.au/")
Then, in RStudio create a new Text File (File → New File → Text File), and save as install.pbs
#!/bin/bash -l
#PBS -N R_install
#PBS -l select=1:ncpus=1:mem=4gb
#PBS -l walltime=2:00:00
#PBS -m abe
cd $PBS_O_WORKDIR
module purge
module load r/4.2.2-foss-2022b
mkdir -p $PBS_O_WORKDIR/r_library
export R_LIBS_USER="${PBS_O_WORKDIR}/r_library"
echo $R_LIBS_USER
Rscript install.R
Run this on the HPC:
# Convert the launch_R.pbs to Linux format
dos2unix install.pbs
# Submit the job to the HPC
qsub install.pbs
# Check the status of the job
qjobs
, multiple selections available,
Related content
2024-2: 7c.1 Running R scripts on HPC
2024-2: 7c.1 Running R scripts on HPC
More like this
2024-2: 7a.1 DE analysis for smallRNAseq against mirBase
2024-2: 7a.1 DE analysis for smallRNAseq against mirBase
Read with this
2. Setup
2. Setup
More like this
copy_2. Setup
copy_2. Setup
More like this
2024-2: 5b.2 R packages (FA) - installing, loading and data importation
2024-2: 5b.2 R packages (FA) - installing, loading and data importation
More like this
2. Initial setup
2. Initial setup
More like this