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.0.0/ and is compiled using mvapich2 with the GNU compilers. Simply adding

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

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 R 2.15.2 and 2.15.3 are also currently installed and can be used by modifying the “module add” 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. It is vital that all paths are updated in the .bashrc file is because that file is run for non-interactive jobs, which all the jobs submitted to the Moab queues are.

Parallel R

The rMPI and doMPI packages are already installed to allow R to use MPI to distribute its work across multiple nodes of the cluster.

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

Example job script file:

#!/bin/bash
#MSUB -l nodes=2:ppn=8
#MSUB -l walltime=1:00:00
#MSUB -V
#MSUB -o /export/home/username/scratch/simulations/job-1.out
#MSUB -e /export/home/username/scratch/simulations/job-1.err
#MSUB -d /export/home/username/scratch/simulations
#MSUB -M be your_emall@address
#MSUB -q 

nproc=`cat $PBS_NODEFILE | wc -l`

mpirun -np $nproc -machinefile $PBS_NODEFILE  R --slave -f /export/home/username/scratch/simulations/job-1.r

Notes:

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