Bogdan Tanasa
2017-Jul-12 00:25 UTC
[R] submitting R scripts with command_line_arguments to PBS HPC clusters
Dear all, please could you advise me on the following : I've written a R script that reads 3 arguments from the command line, i.e. : " args <- commandArgs(TRUE) TUMOR <- args[1] GERMLINE <- args[2] CHR <- args[3] ". when I submit the R script to a PBS HPC scheduler, I do the following (below), but ... I am getting an error message. (I am not posting the error message, because the R script I wrote works fine when it is run from a regular terminal ..) Please may I ask, how do you usually submit the R scripts with command line arguments to PBS HPC schedulers ? qsub -d $PWD -l nodes=1:ppn=4 -l vmem=10gb -m bea -M tanasa at gmail.com \ -v TUMOR="tumor.bam",GERMLINE="germline.bam",CHR="chr22" \ -e script.efile.chr22 \ -o script.ofile.chr22 \ script.R Thank you very very much ! -- bogdan [[alternative HTML version deleted]]
Jeff Newmiller
2017-Jul-12 01:01 UTC
[R] submitting R scripts with command_line_arguments to PBS HPC clusters
This sounds like an operating system specific question, in that "submit the R script to a PBS HPC scheduler" would be the kind of action that would run R with very different environment variables and possibly different access credentials than your usual interactive terminal. A thorough reading of the "Installation and Administration Guide" and some study of your HPC documentation are in order. -- Sent from my phone. Please excuse my brevity. On July 11, 2017 5:25:20 PM PDT, Bogdan Tanasa <tanasa at gmail.com> wrote:>Dear all, > >please could you advise me on the following : I've written a R script >that >reads 3 arguments from the command line, i.e. : > >" args <- commandArgs(TRUE) >TUMOR <- args[1] >GERMLINE <- args[2] >CHR <- args[3] ". > >when I submit the R script to a PBS HPC scheduler, I do the following >(below), but ... I am getting an error message. >(I am not posting the error message, because the R script I wrote works >fine when it is run from a regular terminal ..) > >Please may I ask, how do you usually submit the R scripts with command >line >arguments to PBS HPC schedulers ? > >qsub -d $PWD -l nodes=1:ppn=4 -l vmem=10gb -m bea -M tanasa at gmail.com \ >-v TUMOR="tumor.bam",GERMLINE="germline.bam",CHR="chr22" \ >-e script.efile.chr22 \ >-o script.ofile.chr22 \ >script.R > >Thank you very very much ! > >-- bogdan > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
Anthoni, Peter (IMK)
2017-Jul-12 06:34 UTC
[R] submitting R scripts with command_line_arguments to PBS HPC clusters
Hi, The problem is most likely, you need to call a R CMD BATCH with your arguments and the R-script inside of a shell script that you submit to your qsub. Unfortunately we don't use qsub anymore so can't test it, but it should be as follows: R-script eg. test.R:> ##First read in the arguments listed at the command line > args=(commandArgs(TRUE)) > > ##args is now a list of character vectors > ## First check to see if arguments are passed. > if(length(args)==0){ > stop("no args specified") > } > ## Then cycle through each element of the list and evaluate the expressions. > for(i in 1:length(args)){ > print(args[[i]]) > eval(parse(text=args[[i]])) > } > print(TUMOR) > print(GERMLINE) > print(CHR)qsub shell script test.sh:> #!/bin/bash > > #Note: the single quote '...' around the --args ... "..." "..." is important! > R CMD BATCH --no-save --no-restore '--args TUMOR="tumor.bam" GERMLINE="germline.bam" CHR="chr22"' test.R test.Routthen you submit with a qsub with all the options you specified the test.sh qsub .... test.sh cheers Peter> On 12. Jul 2017, at 03:01, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: > > This sounds like an operating system specific question, in that "submit the R script to a PBS HPC scheduler" would be the kind of action that would run R with very different environment variables and possibly different access credentials than your usual interactive terminal. A thorough reading of the "Installation and Administration Guide" and some study of your HPC documentation are in order. > -- > Sent from my phone. Please excuse my brevity. > > On July 11, 2017 5:25:20 PM PDT, Bogdan Tanasa <tanasa at gmail.com> wrote: >> Dear all, >> >> please could you advise me on the following : I've written a R script >> that >> reads 3 arguments from the command line, i.e. : >> >> " args <- commandArgs(TRUE) >> TUMOR <- args[1] >> GERMLINE <- args[2] >> CHR <- args[3] ". >> >> when I submit the R script to a PBS HPC scheduler, I do the following >> (below), but ... I am getting an error message. >> (I am not posting the error message, because the R script I wrote works >> fine when it is run from a regular terminal ..) >> >> Please may I ask, how do you usually submit the R scripts with command >> line >> arguments to PBS HPC schedulers ? >> >> qsub -d $PWD -l nodes=1:ppn=4 -l vmem=10gb -m bea -M tanasa at gmail.com \ >> -v TUMOR="tumor.bam",GERMLINE="germline.bam",CHR="chr22" \ >> -e script.efile.chr22 \ >> -o script.ofile.chr22 \ >> script.R >> >> Thank you very very much ! >> >> -- bogdan >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Maybe Matching Threads
- submitting R scripts with command_line_arguments to PBS HPC clusters
- submitting R scripts with command_line_arguments to PBS HPC clusters
- segfault when using data.table package in conjunction with foreach
- Histogram for each ID value
- transforming one column into 2 columns