Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 8 Next »

Running R Scripts on the HPC

If all your data is on the HPC, or your analysis is too large or takes too long on your desktop/laptop, it is possible to run the R scripts on the HPC.

Preparing your R script for the HPC

QUT’s HPC is based on Linux so the path names of where your files are, are likely different on the HPC so we must update them to the HPC path.

Using R studio, you can adjust the paths in your script. In the DESeq2.R script, there are a number of places that we need to change for it to work on the HPC:

# The setwd line needs to be changed to:
setwd("~/workshop/2024/small_RNAseq/DESeq2")

# The line where you read in the mature counts table needs to be changed:
metacounts <- read.table("~/workshop/2024/small_RNAseq/DESeq2/mature_counts.txt", header = TRUE, row.names = 1)

# The line where you read in the metadata table needs to be changed:
meta <- read.table("~/workshop/2024/small_RNAseq/DESeq2/metadata_microRNA.txt", header = TRUE)

The H: and W: drives to not exist on the HPC. The folders are there, just under a different path.

Preparing a Script to run the R script on the HPC

You will need to log on to the HPC, via PuTTY (or ssh to lyra in the terminal on a mac)…

A job script needs to be built to request resources and run the script. This one works well for the DESeq2.R script:

#!/bin/bash -l
#PBS -N R_analysis
#PBS -l select=1:ncpus=1:mem=4gb
#PBS -l walltime=00:10:00
#PBS -m abe

module load r/4.2.1-foss-2022a
mkdir -p ~/workshop/small_RNAseq/r_library
export R_LIBS_USER='~/workshop/small_RNAseq/r_library'

cd $PBS_O_WORKDIR

Rscript DESeq2.R

Using R Studio, create a Text File and paste in the contents of this script.

Save it as launch_R.pbs in H:\workshop\small_RNAseq\DESeq2 (Same folder as DESeq2.R)(Remember, H: is pointed at your HPC Home Folder).

Running the Script on the HPC

Now the script is on the HPC, we can run it, but we have to convert it first. R Studio on Windows will save the text file as a “Windows” format file. The HPC has trouble reading this file so we can easily convert it “Linux” format file. Once we have converted the file, we can submit the script to the scheduler and wait for it to run. Copy and paste each of the unhashed lines into the linux command line on the HPC.

# Convert the launch_R.pbs to Linux format
dos2unix launch_R.pbs
#Once this is run, you do not need to run it again, unless you edit it on R Studio again

# Submit the job to the HPC
qsub launch_R.pbs

# Check the status of the job
qjobs
  • No labels