Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Running on a cluster

Every pipeline on this site can send its work to a SLURM or SGE cluster. You set it up once, then add two options to any command: -c <host file> -q <queue>.

How it works

Each module splits its work into tasks: one per chromosome, per region, per sample batch, and so on. Each task already declares the memory, time and CPU cores it needs. When you add -q, SoS writes a small job script for each task, submits it to your scheduler, waits for it to finish, and then moves on to the next step. Without -q, the same tasks run one after another on the machine you are on.

You run sos run once; the cluster runs the tasks. The sos run command itself is light, but it must stay running until the last task finishes (see Keep the pipeline running).

Set up once

1. Install the scheduler plugin. The pixi environment from Environment Setup includes SoS but not its SLURM/SGE plugin:

pixi global install -c conda-forge --environment python sos-pbs

This can take several minutes, because pixi re-checks the whole Python environment.

2. Copy the host file for your scheduler into your clone of the protocol:

SchedulerTemplateQueue name to use
SLURM (sbatch, squeue)code/cluster/slurm.ymlslurm
SGE (qsub, qstat)code/cluster/sge.ymlsge
SGE at Boston University (SCC), as a worked examplecode/cluster/bu_scc.ymlsge
cp code/cluster/slurm.yml my_cluster.yml   # or code/cluster/sge.yml

Not sure which scheduler you have? which sbatch qsub shows which one is installed.

3. Edit the lines marked EDIT. Usually that means:

4. Test it with the toy workflow, which writes 10 small files using 10 jobs:

sos run code/SoS/misc/Job_Example.ipynb toy_example -c my_cluster.yml -q slurm   # or -q sge

While it runs, squeue -u $USER (SLURM) or qstat -u $USER (SGE) should list the jobs. When it finishes, File_1.out to File_10.out are in the current folder.

Run a module on the cluster

Take any command from a module’s Minimal Working Example and add the two options. For example, the gene annotation example from Environment Setup:

sos run pipeline/gene_annotation.ipynb annotate_coord \
    --phenoFile tests/fixtures/gene_annotation/protocol_example.rnaseq.bed.gz \
    --coordinate-annotation tests/fixtures/gene_annotation/Homo_sapiens.GRCh38.103.collapse_only.gene.chr22.gtf.gz \
    --phenotype-id-column gene_id \
    --modular-script-dir code/script --cwd output/gene_annotation \
    -c my_cluster.yml -q slurm

Three options set what each job asks for. They are the same in every module:

OptionMeaningExample
--memmemory per task--mem 40G
--walltimetime limit per task--walltime 24h
--numThreadsCPU cores per task--numThreads 8
--job-sizehow many tasks share one job; raise it when a module makes thousands of short tasks--job-size 200

Each module’s default values are in Default resources by module below, and sos run pipeline/<module>.ipynb -h prints them. The defaults suit the example data; for a full cohort, start from them and raise --mem or --walltime if jobs are killed.

Options with one dash (-c, -q, -s, -j) belong to SoS; options with two dashes belong to the module.

Keep the pipeline running

sos run has to stay alive until its last job finishes, which for a full cohort can take hours or days. Two common ways:

Submit sos run itself as a small job (recommended; some clusters require it). The job needs little memory but a long time limit:

#!/bin/bash
#SBATCH --job-name=xqtl_driver
#SBATCH --time=72:00:00
#SBATCH --mem=4G
#SBATCH --cpus-per-task=1
#SBATCH --output=xqtl_driver.%j.log

cd /path/to/xqtl-protocol
sos run pipeline/<module>.ipynb <workflow> <options> -c my_cluster.yml -q slurm

Save it as driver.sh and submit with sbatch driver.sh. On SGE, use the same body with #$ -N xqtl_driver, #$ -l h_rt=72:00:00, #$ -cwd, #$ -j y and submit with qsub driver.sh.

Or run it inside tmux or screen on a login node, if your cluster allows long-running processes there.

Monitor, resume and rerun

Add the same -c my_cluster.yml -q slurm (or -q sge) to these so SoS looks at the right queue.

To...Run
See the state of every tasksos status -c my_cluster.yml -q slurm -v 3
Read a failed task’s erroropen ~/.sos/tasks/<task id>.err, or run sos status <task id> -c my_cluster.yml -q slurm -v 4
Resume after a failure or a killed driverrun the same sos run command again: finished tasks are skipped
Redo steps whose outputs already existadd -s force
Stop the pipelinepress Ctrl-C twice in the terminal running sos run; jobs already in the queue finish or can be removed with scancel / qdel
Clean up records of finished taskssos purge -s completed -c my_cluster.yml -q slurm

Default resources by module

What each task asks for unless you override it, as set in each module’s code. Run times depend on your data; these defaults are starting points, not measurements.

Module--mem--walltime--numThreads--job-size
Reference Data Standardization16G5h81
Generalized TADB40G20h11
LD pruning80G1h101
RSS LD sketch32G24h81
RNA-seq expression calling16G5h81
Bulk RNA-seq QC16G5h81
Bulk RNA-seq normalization16G5h201
snRNA-seq preprocessing16G5h81
Pseudobulk preprocessing16G5h81
Methylation calling16G5h81
Splicing calling (LeafCutter, LeafCutter2)16G5h81
Isoform usage (Torino)16G5h11
Splicing normalization16G5h81
APA calling200G400h81
APA imputation32G40h161
Genotype VCF QC60G24h11
Genotype formatting16G5h201
Genotype PLINK QC16G5h201
PCA16G5h101
Gene coordinate annotation16G5h11
Phenotype imputation16G72h201
Phenotype formatting16G5h201
Covariate formatting2G5h81
Hidden factor analysis16G5h81
TensorQTL16G12h81
Quantile regression and TWAS20G1h1200
MASH preprocessing16G1h11
Mixture prior16G5h11
MASH fit16G5h11
MASH posterior16G1h11
Fine-mapping and TWAS (mnm_regression)20G1h1200
RSS fine-mapping (GWAS)16G2h11
RSS fine-mapping (QTL summary statistics)16G5h11
Fine-mapping post-processing6G96h21
SuSiE-enloc16G5m1200
TWAS, cTWAS and MR8G5m1100
INTACT8G5h11
ColocBoost20G1h1200
Block-jackknife enrichment16G12h81
Pathway analysis16G12h81
S-LDSC enrichment16G12h161

Common problems

Failed to load task engine of type "pbs". The sos-pbs plugin is missing; install it (step 1).

requested more mem ... than allowed max_mem. A task asked for more than the max_mem in your host file. Lower --mem, or raise max_mem if your cluster allows it.

Every task fails with does not match any existing task. The job started with a different home directory than your login shell, so SoS could not find its task files. The templates set HOME inside each job to prevent this; keep that line if you edit the template.

Jobs sit in the queue and never start. The request may exceed what any node offers, or your cluster needs an account or partition line. Check with squeue -u $USER --start (SLURM) or qstat -j <job id> (SGE).

Jobs are killed for memory or time. Rerun the same command with a higher --mem or --walltime; finished tasks are not repeated.

Thousands of tiny jobs flood the queue. Raise --job-size so several tasks share one job, and lower max_running_jobs in the host file.