|
|
# How to submit a R-script with qsub
|
|
|
----
|
|
|
'**R on Shark**'
|
|
|
R can be run on all compute nodes, please do not run R on the head node, this will be automatically detected and an alert will be sent to the system maintainer and the job can and will be killed.
|
|
|
|
|
|
R is not a parallel program, it is single threaded which means that it only uses one processor, please keep in mind that R loads everything into memory and therefore you must keep an eye on the memory consumption on the node where R is running on,
|
|
|
you will not be the only one running on Shark. R can use multiple processors, there are multicore packages for R please read http://cran.r-project.org/web/views/HighPerformanceComputing.html
|
|
|
|
|
|
Please use R on Shark together with qsub, this is easily done with the folowing example:
|
|
|
The command to use in a shell script is : R CMD BATCH <script-naam.R>
|
|
|
Your R-script file with the name test.R looks like this:
|
|
|
|
|
|
#!sh
|
|
|
M <- replicate(2, runif(10e5, 0, 1))
|
|
|
d <- data.frame(M)
|
|
|
colnames(d) <- c("y1", "y2")
|
|
|
attach(d)
|
|
|
|
|
|
reg <- glm(cbind(y2) ~ y1, family = binomial)
|
|
|
save(reg, file = "reg.Rdata")
|
|
|
}}}
|
|
|
To submit this R-script with qsub you need to create a shell script with the name R_test.sh that looks like this:
|
|
|
|
|
|
#!sh
|
|
|
#!/bin/bash
|
|
|
#$ -S /bin/bash
|
|
|
#$ -q all.q
|
|
|
#$ -N R_test
|
|
|
#$ -cwd
|
|
|
#$ -j Y
|
|
|
#$ -V
|
|
|
#$ -m be
|
|
|
#$ -M your.mail.address@lumc.nl
|
|
|
|
|
|
R CMD BATCH test.R
|
|
|
}}}
|
|
|
Now you can qsub your R-script like this:
|
|
|
|
|
|
qsub R_test.sh
|
|
|
|
|
|
|
|
|
The output of R can be found in the filename <script-name>.Rout and the test.R example .Rout file looks like this:
|
|
|
|
|
|
#!sh
|
|
|
R version 2.13.0 (2011-04-13)
|
|
|
Copyright (C) 2011 The R Foundation for Statistical Computing
|
|
|
ISBN 3-900051-07-0
|
|
|
Platform: x86_64-unknown-linux-gnu (64-bit)
|
|
|
|
|
|
R is free software and comes with ABSOLUTELY NO WARRANTY.
|
|
|
You are welcome to redistribute it under certain conditions.
|
|
|
Type 'license()' or 'licence()' for distribution details.
|
|
|
|
|
|
Natural language support but running in an English locale
|
|
|
|
|
|
R is a collaborative project with many contributors.
|
|
|
Type 'contributors()' for more information and
|
|
|
'citation()' on how to cite R or R packages in publications.
|
|
|
|
|
|
Type 'demo()' for some demos, 'help()' for on-line help, or
|
|
|
'help.start()' for an HTML browser interface to help.
|
|
|
Type 'q()' to quit R.
|
|
|
|
|
|
[saved workspace restored](Previously)
|
|
|
|
|
|
> M <- replicate(2, runif(10e5, 0, 1))
|
|
|
> d <- data.frame(M)
|
|
|
> colnames(d) <- c("y1", "y2")
|
|
|
> attach(d)
|
|
|
>
|
|
|
> reg <- glm(cbind(y2) ~ y1, family = binomial)
|
|
|
Warning message:
|
|
|
In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
|
|
|
> save(reg, file = "reg.Rdata")
|
|
|
>
|
|
|
> proc.time()
|
|
|
user system elapsed
|
|
|
32.430 1.240 49.674
|
|
|
}}} |
|
|
\ No newline at end of file |