How to work in R on Teton

An example session of using R interactively is in a video embedded in the https://microcollaborative.atlassian.net/wiki/spaces/DSC/pages/102563845

Working in R interactively

Use slurm to get an interactive job. See https://microcollaborative.atlassian.net/wiki/spaces/DSC/pages/102563845 for steps to do this.

module load r

Other versions of R are also available. module spider r will list them all.

Type R to begin an interactive session (UNIX is case-sensitive, so r is not equivalent to R). On the log-in and FastX nodes, you can also now use Rstudio as a development environment and light-duty computing. To do this you’ll need X Windows forwarding or a FastX connection to the cluster.

Running an R script non-interactively

For longer-running analyses, you will want to run them non-interactively. The teton system uses SLURM for managing jobs (see https://microcollaborative.atlassian.net/wiki/spaces/DSC/pages/102563845 ). Before you can run an R script non-interactively, you will need to install any add-on R packages your script uses. Then, to run your script non-interactively as a slurm job, you should write a slurm/sbatch script to execute it (example below). Suppose the example script were named run_slurm_myprecious.sh

#!/bin/bash #SBATCH --nodes=1 #SBATCH --cpus-per-task=1 #SBATCH --ntasks-per-node=1 #SBATCH --account=microbiome #SBATCH --time=0-00:10:00 echo $HOSTNAME module load r Rscript myprecious.R ## alternatively you can also run: R CMD BATCH myprecious.R

Here you would want to substitute your project account name for microbiome and adjust the wall you are requesting (the example requests only 10 minutes).

You would submit this script with sbatch run_slurm_myprecious.sh