User Tools

Site Tools


howto:r

This is an old revision of the document!


Using R

R is installed in /opt/gridware/applications/R/R-3.1.3/ and is compiled using openmpi 1.6.5 with the GNU compilers. Simply adding:

export MODULEPATH=/opt/gridware/bioinformatics/modules:$MODULEPATH
module add R/3.1.3

to your .bashrc file in your home directory will set up the appropriate paths to R, the compilers (if you want to add your own R packages) and the mpi libraries. Note that there are several versions of R installed and can be seen by running the:

module avail

command.

Changes to .profile file

On the CHPC clusters the .bashrc file is not automatically run for interactive logins, only the .profile file is. To rectify this add the following lines to the end of your .profile file:

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

Then make any changes to the PATH variable in your .bashrc file.

Parallel R

The Rmpi, doMPI and other packages are already installed to allow R to use MPI to distribute its work across multiple nodes of the cluster. Please submit a request to helpdesk should you need any other packages installed.

Once you've created your R script file, called 'myScRipt.r', you will need to create a job script file to submit to the PBSPro scheduler.

Example job script file:

my_R_job.qsub
#!/bin/bash
#PBS -l select=2:ncpus=12:jobtype=dell,place=excl
#PBS -l walltime=1:00:00
#PBS -q workq
#PBS -V
#PBS -o /export/home/username/scratch5/my_R_data/stdout.txt
#PBS -e /export/home/username/scratch5/my_R_data/stderr.txt
#PBS -N RJob
#PBS -M myemailaddress@someplace.com
#PBS -m abe
 
# make sure appropriate R module is available
source /etc/profile.d/modules.sh
MODULEPATH=/opt/gridware/bioinformatics/modules:${MODULEPATH}
# Add R module (includes appropriate openMPI and gcc modules)
module add R/3.1.3
 
# explicitly calculate number of processes.
nproc=`cat $PBS_NODEFILE | wc -l`
 
# make sure we're in the correct working directory.
cd /export/home/username/scratch5/my_R_data
 
mpirun -np $nproc -machinefile $PBS_NODEFILE  R --slave -f /export/home/username/scratch5/my_R_data/myScRipt.r

Notes:

  • Replace username with your user name.
  • Replace myemailaddress@someplace.com with your email address.
  • And replace my_R_data with your program's working directory (which must be on scratch).
  • And change myScRipt.r to be your script file name.
/app/dokuwiki/data/attic/howto/r.1430915915.txt.gz · Last modified: 2021/12/09 16:42 (external edit)