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
[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.

Current installed R packages

> installed.packages()[1:5,]
 Package LibPath Version Priority
 Depends 
beachmat NA 
BiocParallel "methods" 
BiocSingular NA 
DelayedArray "R (>= 3.4), methods, stats4, matrixStats, BiocGenerics (>=\n0.27.1), S4Vectors (>= 0.21.7), IRanges (>= 2.17.3),\nBiocParallel"
formatR "R (>= 3.0.2)" 
 Imports
beachmat "methods, DelayedArray, BiocGenerics, Matrix"
BiocParallel "stats, utils, futile.logger, parallel, snow"
BiocSingular "BiocGenerics, S4Vectors, Matrix, methods, utils, DelayedArray,\nBiocParallel, irlba, rsvd, Rcpp"
DelayedArray "stats, Matrix"
formatR NA
 LinkingTo
beachmat NA
BiocParallel "BH"
BiocSingular "Rcpp, beachmat"
DelayedArray "S4Vectors"
formatR NA
 Suggests 
beachmat "testthat, BiocStyle, knitr, rmarkdown, devtools" 
BiocParallel "BiocGenerics, tools, foreach, BatchJobs, BBmisc, doParallel,\nRmpi, GenomicRanges, RNAseqData.HNRNPC.bam.chr14,\nTxDb.Hsapiens.UCSC.hg19.knownGene, VariantAnnotation,\nRsamtools, GenomicAlignments, ShortRead, codetools, RUnit,\nBiocStyle, knitr, batchtools, data.table"
BiocSingular "testthat, BiocStyle, knitr, rmarkdown, beachmat" 
DelayedArray "Matrix, HDF5Array, genefilter, SummarizedExperiment, airway,\npryr, DelayedMatrixStats, knitr, BiocStyle, RUnit" 
formatR "codetools, shiny, testit, rmarkdown, knitr" 
 Enhances License License_is_FOSS License_restricts_use
beachmat NA "GPL-3" NA NA
BiocParallel NA "GPL-2 | GPL-3" NA NA
BiocSingular NA "GPL-3" NA NA
DelayedArray NA "Artistic-2.0" NA NA
formatR NA "GPL" NA NA
 OS_type MD5sum NeedsCompilation Built
beachmat NA NA "yes" "3.6.0"
BiocParallel NA NA "yes" "3.6.0"
BiocSingular NA NA "yes" "3.6.0"
DelayedArray NA NA "yes" "3.6.0"
formatR NA NA "no" "3.6.0"

-- AdminUser - 26 Jul 2017
Topic revision: r12 - 23 Jan 2020, 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