Using the Launcher to automate Rscript analyses
Introduction
The R code that you need to automate should be wrapped up in a text file, and coded to expect parameters to be passed in from the command line. There are several ways to do this in R, but we will demonstrate an extremely simple method to illustrate the basic principle.
A simple R script
This script takes a named parameter 'string' and prints it to standard output - that's it!
#! /usr/bin/Rscript # Input arguments: # string - The string you want to print # Parse command line arguments args=(commandArgs(TRUE)) for(i in 1:length(args)){ eval(parse(text=args[i])) } cat(c(string, "\n"))
Setting up the TACC Parametric Launcher
You've seen the TACC Parametric Launcher used to increase throughput speed of a single calculation, but it was actually designed to run 'parameter sweeps', in which the same task is run but with different arguments. We will now set up a Launcher to print the first six United States states to standard output.
#!/bin/bash #$ -V #$ -cwd # NOTE: This 'wayness' is different from our BWA example. In this case, we # want to run up to 12 R jobs on a single compute node. #$ -pe 12way 12 #$ -q normal #$ -l h_rt=00:10:00 #$ -A 20121008-NGS-ACES #$ -m be #$ -M vaughn@tacc.utexas.edu #$ -N rscript-parallel module load R module load launcher rm -rf paramlist echo "Rscript printString.r \"string='Alabama'\"" >> paramlist echo "Rscript printString.r \"string='Alaska'\"" >> paramlist echo "Rscript printString.r \"string='Arizona'\"" >> paramlist echo "Rscript printString.r \"string='California'\"" >> paramlist echo "Rscript printString.r \"string='Colorado'\"" >> paramlist echo "Rscript printString.r \"string='Connecticut'\"" >> paramlist EXECUTABLE=$TACC_LAUNCHER_DIR/init_launcher $TACC_LAUNCHER_DIR/paramrun $EXECUTABLE paramlist
If submit this to the queue and allow it to run, you will find the names of the states printed in the rscript-parallel.o<JOB_ID>
file, interspersed with other messages. Details of writing to files, changing parameterization, etc are left to the reader but we hope you get the general idea!
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache.