Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

No Format
module load R/3.4.0-gu (awoonga)
module load R/3.4.0 (gowonda)

Old Packages:
=============
module load R/3.3.3
OR
module load R/3.2.3
OR
module load R/3.2.0
module load R/3.4.0
There are other older versions as well.
module avail R

Griffith Uni R Users site

Griffith Uni R Users site: http://guru.forumotion.co.nz/


Accessing R on the gowonda cluster

...

No Format
#!/bin/bash
######################################################################
#### This section defines options for the pbs batching system
######################################################################
#PBS -m abe
#PBS -M YourEmail@griffith.edu.au
#PBS -q workq
#PBS -l select=1:ncpus=1:mem=2gb,walltime=60:00:00
#PBS -N vivaxIBMS3
#
###Load the pgi compilers.
module load compilers/pgi-32bit-12.4
###Load the R 
module load R/4.0.3


#####################################################################
#### This section is for my debugging purposes (not required)
######################################################################
echo Running on host `hostname`
echo Time is `date`
######################################################################
#### This section is setting up and running your executable or script
######################################################################
cd
cd  $PBS_O_WORKDIR
###cd /export/home/s12345/pbs/R/
echo Directory is `pwd`

source $HOME/.bashrc
R CMD BATCH '--args a=1 b=c(2,5,6)' test.R test.out
#CMD BATCH options which tells it to immediately run an R program
#instead of presenting an interactive prompt
#R.out is the screen output
#results.Rout is the R program output

...

No Format
qsub -I -l select=1:ncpus=8:mem=12gb,walltime=1:11:00 -q small
Once you are on the compute node:
module load R/4.0.3
R
library(plyr)
library(doParallel)
cores <- detectCores()
cores
[1] 12
registerDoParallel(cores=8)
fake_func <- function(x) {
Sys.sleep(0.1)
return(x)
}
library(microbenchmark)
microbenchmark(
serial = llply(1:24, fake_func),
parallel = llply(1:24, fake_func, .parallel = TRUE),
times = 1
)


Unit: milliseconds
     expr       min        lq      mean    median        uq       max neval
   serial 2402.7702 2402.7702 2402.7702 2402.7702 2402.7702 2402.7702     1
 parallel  320.0491  320.0491  320.0491  320.0491  320.0491  320.0491     1
> 


Create R conda environment (Recommended way on the new cluster) to run R on the new cluster

Another easy way to install R and R packages is to use conda . Here are the steps

No Format
source /usr/local/bin/s3proxy.sh
module load anaconda3/2024.06
conda create --name myRenv R=4.3.1
source activate myRenv

To install packes like "tidyverse","lubridate","ggplot2", "tmap", "ggmap", "sf", "ggsci", "remotes", "raster", "readxl", "terra"
Simply google with the package name and conda as search strings e.g. tidyverse conda
You will see instructions to install these packages:

conda install r::r-lubridate
conda install r::r-tidyverse
conda install conda-forge::r-ggplot2
conda install conda-forge::r-tmap
conda install conda-forge::r-ggmap
conda install conda-forge::r-sf
conda install conda-forge::r-ggsci
conda install conda-forge::r-remotes
conda install conda-forge::r-raster
conda install conda-forge::r-readxl
conda install conda-forge::r-terra

Or simply:
conda create --name myRenv r=4.3.1 r-tidyverse r-ggplot2 r-tmap r-ggmap r-sf r-ggsci r-remotes r-raster r-readxl r-terra -c conda-forge 

Here is a sample pbs script:
#!/bin/bash
#PBS -m abe
#PBS -M XXXX@griffithuni.edu.au
#PBS -N MyTest
#PBS -q workq
#PBS -l select=1:ncpus=1:mem=4gb,walltime=01:00:00
module load anaconda3/2024.06
source activate myRenv
module list
cd $PBS_O_WORKDIR
R '--save' <MAIN_CODEmodel1.R
##sleep 22
echo "Done with job"
>>>>>

R script can start with loading the packages like this:
package_names <- c("tidyverse","lubridate","ggplot2", "tmap", "ggmap", "sf", "ggsci", "remotes", "raster", "readxl", "terra")

# Loop to load the packages
for (package_name in package_names) {
if (!requireNamespace(package_name, quietly = TRUE)) {
message(paste("Installing and loading", package_name))
install.packages(package_name, dependencies = TRUE)
}
library(package_name, character.only = TRUE)
}

<snip>



Reference

1. http://yusung.blogspot.com.au/2009/01/install-jags-and-rjags-in-fedora.html

...