easypar can be used to generate scripts that submit array jobs to the LSF cluster system.

First, write in R your code.

# Computation function 
FUN = function(x, y){  ... }

# Input for 25 array jobs that match FUN arguments
PARAMS = data.frame(x = runif(25), y = runif(25))

# Generates submission files 
run_lsf(FUN, PARAMS)

Then, in your terminal.

# Test if the generated script runs with the first input 
head -1 EASYPAR_LSF_input_jobarray.csv | Rscript EASYPAR_LSF_Run.R

# Submit array jobs (after loading the cluster module)
bsub < EASYPAR_LSF_submission.sh

Requirements

Note: FUN will be run as an indipendent process.

Conceptually, you set up the data as for an apply(FUN, MARGIN = 1) by row.

The input should have column names without dots or spaces; these will match the arguments of FUN. So, for instance, an input with 2-columns will only work if FUN has 2 parameters.

Output

run_lsf generates 3 files:

Before submitting the job, test the computation as explained above.

Customising jobs

Cluster-specific BSUB instructions can be specified, as well as other dependencies from modules available on the cluster.

Function run_lsf allows to:

The package comes with a default BSUB configuration, that has to be updated according to your cluster setup.

library(easypar)

# Default parameters in the package
default_BSUB_config()

These are classical BSUB parameters:

It is required to modify the default values of -P and -q, the project and queue ID, according to your LSF configuration. Otherwise, the submission script will generate an error becaue the default values do not mean anything.

Modifications are done to the default list of parameters; other BSUB flags can be used as well. No checkings on their correctness are done by easypar.

custom_BSUB = default_BSUB_config()

# More informative job ID
custom_BSUB$`-J` = "bwa_aligner"

# A token for a project allowed to run on the cluster
custom_BSUB$`-P` = "DKSMWOP331"

# A queue name that is valid on the cluster
custom_BSUB$`-q` = "bioinformatics"

print(custom_BSUB)

# Shorter version
custom_BSUB = default_BSUB_config(J = 'bwa_aligner', P = 'DKSMWOP331', q = 'bioinformatics')

print(custom_BSUB)

Once the BSUB has been customized, you can either:

By default (run = FALSE) the run_lsf function outputs the shell command that should be used to submit the jobs, but leaves the user to submit the job. This is because we experienced some command line issues calling modules with a system call.

Example

An example computation follows.

# A simple function that prints some outputs
FUN = function(x, y){ 
  print(x, y) 
}

# input for 25 array jobs
PARAMS = data.frame(
  x = runif(25), 
  y = runif(25)
  )

# generates the input files, adding some module dependencies
run_lsf(FUN, 
        PARAMS, 
        BSUB_config = custom_BSUB,
        modules = 'R/3.5.0'
        )

Submitting the job

If you do not try to run it automatically, command bsub < EASYPAR_LSF_submission.sh will submit the jobs to the cluster.



caravagn/easypar documentation built on June 4, 2022, 4:25 a.m.