简体   繁体   中英

Run multiple R scripts in parallel with command line arguments

I have an R script that performs analysis on one chromosome. I want to run this script repeatedly for each chromosome (1-22, X and Y). Right now I have the script set up to accept one argument from command line, the chromosome number. I want to submit multiple jobs to my server in parallel since analysis for one chromosome takes a few hours. After playing around with some options and googling everything, I'm still not sure what the best option is as I've never submitted jobs in parallel to a server (Sun Grid Engine server). I looked into GNU parallel but I'm not sure how to use it or if it even runs for R scripts. Maybe throw everything in a shell script and submit that to the server? This is a pretty basic question, but any direction would be greatly appreciated!

parallel Rscript plot_LRR_BAF_chromosome_parallel ::: {1..22} X Y

using GNU make with option -j , replace __CHROM__ in your R script with the chromosome name.

chroms=1 2 3 4 5 6 7 8 9 10

define method1

$$(addsuffix .out,$(1)) : script.R
    cat $$< | sed 's/__CHROM__/$(1)/g' | R --nosave > $$@

endef

all: $(addsuffix .out,$(chroms))

$(foreach C, $(chroms),$(eval $(call method1, $(C) )))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM