R

How to add packages to your local repository

Depending on the packages you want installed, you can do one of two things within R. First we load the R module and run R:
[abc123@login01 ]$ module load R/3.5.1
[abc123@login01 ]$ R

For BioConductor packages, type the following:
source("https://bioconductor.org/biocLite.R")
biocLite()

Install specific packages, e.g., “GenomicFeatures” and “AnnotationDbi”, with
biocLite(c("GenomicFeatures", "AnnotationDbi"))

The biocLite() function (in the BiocInstaller package installed by the biocLite.R script) has arguments that change its default behavior; type ?biocLite for further help. For more information regarding the BioConductor package, please visit their Installation website here https://www.bioconductor.org/install/

For CRAN packages, type the following:
install.packages(c("package_name"))

How to use R or Rstudio on Shamu

Now that you have your packages installed, you have two (2) ways of using R on Shamu, interactively or non-interactive.

Non-interactive

Below is a sample submit script that you can edit for your R input file and submit with qsub name_of_this_file.qsub. This sample assumes you are using R in parallel mode and requesting 20 cores.
#!/bin/bash
#$ -S /bin/bash
#$ -N Name_of_job
#S -q all.q
#$ -cwd
#$ -j y
#$ -o $JOB_ID.log
#$ -pe threaded 20
. /etc/profile.d/modules.sh
# Load one of these
module load shared R/3.5.1
R -e "source('Script_Simulation_2_15_65.R')"

Interactive

Grab a compute node with qlogin, load the rstudio module and run the rstudio program:
[abc123@login01 ~]$ qlogin
[abc123@compute015 ~]$ module load R/3.5.1 rstudio
[abc123@compute015 ~]$ rstudio

Using R in parallel mode

Your R input file must contain the parallel() section for parallel execution of R binaries to work properly. Here is an example:

require(parallel); require(mvtnorm); set.seed(2000)
cat('Cores: ', detectCores(), '\n')

Using R with GPU

You need to log onto a GPU node and install gpuR library

[abc123]@login02 ~]$ qlogin -q gpu.q

on a GPU node, load the modules for CUDA and R

[abc123]@gpu02 ~]$ module load cuda90/toolkit/9.0.176
[abc123]@gpu02 ~]$ module load R/3.5.1

and launch R and install the gpuR library

[abc123]@gpu02 ~]$ R
> install.packages("gpuR")

The current version of gpuR can only identify one GPU.

-- AdminUser - 26 Jul 2017
Topic revision: r10 - 17 May 2019, AdminUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding UTSA Research Support Group? Send feedback