Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Specify compute resources using process labels #219

Merged
merged 13 commits into from
Sep 28, 2020
33 changes: 33 additions & 0 deletions conf/compute_resources.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

// define computing resources via process labels
process {

/*
set a default compute profile
applies to all 'compute_resources__.*' labels:
*/
withLabel: 'compute_resources__.*|compute_resources__default' {
cpus = 2
memory = '2 GB'
time = '1h'
// additional cluster options (applies to grid based executors):
clusterOptions = "-A cluster_account"
}

withLabel: 'compute_resources__minimal' {
cpus = 1
memory = '1 GB'
}

withLabel: 'compute_resources__mem' {
cpus = 4
memory = '30 GB'
}

withLabel: 'compute_resources__cpu' {
cpus = 20
memory = '30 GB'
}
cflerin marked this conversation as resolved.
Show resolved Hide resolved

}

4 changes: 1 addition & 3 deletions conf/global.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ params {
global {
project_name = '10x_PBMC'
outdir = 'out'
qsubaccount = ''
qsubemail = ''
}
}
}
1 change: 0 additions & 1 deletion conf/test__scenic.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ params {
}
scenic {
filteredLoom = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/expr_mat_tiny.loom'
numWorkers = 2
grn {
tfs = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/test_TFs_tiny.txt'
}
Expand Down
1 change: 0 additions & 1 deletion conf/test__scenic_multiruns.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ params {
}
scenic {
filteredLoom = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/expr_mat_small.loom'
numWorkers = 2
grn {
tfs = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/test_TFs_small.txt'
}
Expand Down
1 change: 0 additions & 1 deletion conf/test__single_sample_scenic.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ params {
}
}
scenic {
numWorkers = 2
grn {
tfs = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/test_TFs_small.txt'
}
Expand Down
1 change: 0 additions & 1 deletion conf/test__single_sample_scenic_multiruns.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ params {
}
scenic {
//filteredLoom = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/expr_mat_small.loom'
numWorkers = 2
grn {
tfs = 'https://raw.githubusercontent.com/aertslab/SCENICprotocol/master/example/test_TFs_small.txt'
}
Expand Down
9 changes: 6 additions & 3 deletions main_atac.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import static groovy.json.JsonOutput.*
nextflow.preview.dsl=2

include {
INIT
} from '../utils/workflows/utils.nf' params(params)
INIT;
} from './src/utils/workflows/utils' params(params)
INIT()
include {
SC__FILE_CONVERTER;
} from './src/utils/processes/utils' params(params)

include {
getDataChannel
getDataChannel;
} from './src/channels/channels' params(params)

/*
Expand Down
5 changes: 4 additions & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ params {
}
}

// load these configs first:
includeConfig 'conf/global.config'
includeConfig 'conf/compute_resources.config'

process {
executor = 'local'
Expand Down Expand Up @@ -376,4 +378,5 @@ min {

includeConfig 'src/utils/conf/scope.config'
includeConfig 'src/utils/utils.config' // utilities config
includeConfig 'conf/generic.config'
includeConfig 'conf/generic.config'

4 changes: 2 additions & 2 deletions src/utils/processes/gtf.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ nextflow.preview.dsl=2
process FORMAT_GTF {

publishDir "${params.global.outdir}/00.refdata", mode: 'symlink'
clusterOptions "-l nodes=1:ppn=${params.global.threads} -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
file(annotation)
Expand All @@ -23,7 +23,7 @@ process FORMAT_GTF {
process FORMAT_GTF_IGENOMES {

publishDir "${params.global.outdir}/00.refdata", mode: 'symlink'
clusterOptions "-l nodes=1:ppn=${params.global.threads} -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
file(annotation)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/processes/h5adAnnotate.nf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ process SC__ANNOTATE_BY_CELL_METADATA {

container params.sc.scanpy.container
publishDir "${getPublishDir(params.global.outdir,tool)}", mode: "${getMode(tool)}", overwrite: true
clusterOptions "-l nodes=1:ppn=2 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple \
Expand Down Expand Up @@ -69,7 +69,7 @@ process SC__ANNOTATE_BY_SAMPLE_METADATA() {

container params.sc.scanpy.container
publishDir "${params.global.outdir}/data/intermediate", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=2 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple val(sampleId), path(f)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/processes/h5adExtractMetadata.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process SC__UTILS__EXTRACT_FEATURE_METADATA {

container params.sc.scanpy.container
publishDir "${params.global.outdir}/data/intermediate", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=2 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple val(sampleId), path(f)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/processes/h5adSubset.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ process SC__PREPARE_OBS_FILTER {

container params.sc.scanpy.container
publishDir "${params.global.outdir}/data/intermediate", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=2 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple \
Expand Down Expand Up @@ -57,7 +57,7 @@ process SC__APPLY_OBS_FILTER {

container params.sc.scanpy.container
publishDir "${params.global.outdir}/data/intermediate", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=2 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple \
Expand Down
4 changes: 2 additions & 2 deletions src/utils/processes/h5adToLoom.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ binDir = !params.containsKey("test") ? "${workflow.projectDir}/src/utils/bin" :
process SC__H5AD_TO_LOOM {

container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/loom", mode: 'link', overwrite: true, saveAs: { filename -> "${sampleId}.SCope_output.loom" }
label 'compute_resources__mem'

input:
// Expects:
Expand Down Expand Up @@ -42,8 +42,8 @@ process SC__H5AD_TO_LOOM {
process SC__H5AD_TO_FILTERED_LOOM {

container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/data/intermediate", mode: 'symlink', overwrite: true
label 'compute_resources__mem'

input:
tuple val(sampleId), path(f)
Expand Down
6 changes: 3 additions & 3 deletions src/utils/processes/h5adUpdate.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ binDir = !params.containsKey("test") ? "${workflow.projectDir}/src/utils/bin" :
process SC__H5AD_UPDATE_X_PCA {

container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__mem'

input:
tuple \
Expand All @@ -34,7 +34,7 @@ process SC__H5AD_UPDATE_X_PCA {
process SC__H5AD_CLEAN {

container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__mem'

input:
tuple \
Expand All @@ -56,4 +56,4 @@ process SC__H5AD_CLEAN {
"${sampleId}.SC__H5AD_CLEAN.h5ad"
"""

}
}
2 changes: 1 addition & 1 deletion src/utils/processes/h5adUpdateMetadata.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process SC__UTILS__UPDATE_FEATURE_METADATA_INDEX {

container params.sc.scanpy.container
publishDir "${params.global.outdir}/data/intermediate", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=2 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple val(sampleId), path(f), path(additionalMetadata)
Expand Down
6 changes: 3 additions & 3 deletions src/utils/processes/reports.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import static groovy.json.JsonOutput.*
process UTILS__GENERATE_WORKFLOW_CONFIG_REPORT {

container params.utils.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/notebooks/intermediate", mode: 'link', overwrite: true
label 'compute_resources__default'

input:
path(ipynb)
Expand All @@ -27,11 +27,11 @@ process UTILS__GENERATE_WORKFLOW_CONFIG_REPORT {
process UTILS__REPORT_TO_HTML {

container params.utils.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/notebooks/intermediate", mode: 'link', overwrite: true
// copy final "merged_report" to notbooks root:
publishDir "${params.global.outdir}/notebooks", pattern: '*merged_report*', mode: 'link', overwrite: true
maxForks 2
label 'compute_resources__minimal'

input:
tuple \
Expand All @@ -46,4 +46,4 @@ process UTILS__REPORT_TO_HTML {
jupyter nbconvert ${ipynb} --to html
"""

}
}
6 changes: 3 additions & 3 deletions src/utils/processes/sra.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ process GET_SRA_DB {

container params.utils.container
publishDir "${processParams.sraDbOutDir}", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=1 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

output:
file("SRAmetadb.sqlite")
Expand All @@ -29,9 +29,9 @@ process SRA_TO_METADATA {

container params.utils.container
publishDir "${params.global.outdir}/metadata", mode: 'link', overwrite: true
clusterOptions "-l nodes=1:ppn=1 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
errorStrategy 'retry'
maxRetries 5
label 'compute_resources__default'

input:
tuple val(sraId), val(sampleFilters)
Expand Down Expand Up @@ -78,7 +78,7 @@ def normalizeSRAFastQ(fastQPath, sampleName) {
process NORMALIZE_SRA_FASTQS {

// publishDir "${params.global.outdir}/data", mode: 'symlink'
clusterOptions "-l nodes=1:ppn=1 -l walltime=1:00:00 -A ${params.global.qsubaccount}"
label 'compute_resources__default'

input:
tuple val(sampleId), file(fastqs)
Expand Down
11 changes: 6 additions & 5 deletions src/utils/processes/utils.nf
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ process SC__FILE_CONVERTER {
container "vibsinglecellnf/sceasy:0.0.5"
else
container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/data/intermediate", mode: 'symlink', overwrite: true
label 'compute_resources__mem'

input:
tuple \
Expand Down Expand Up @@ -192,6 +192,7 @@ process SC__FILE_CONVERTER {
process SC__FILE_CONVERTER_HELP {

container params.sc.scanpy.container
label 'compute_resources__minimal'

output:
stdout()
Expand All @@ -207,8 +208,8 @@ process SC__FILE_CONCATENATOR {

cache 'deep'
container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/data/intermediate", mode: 'symlink', overwrite: true
label 'compute_resources__mem'

input:
file("*")
Expand All @@ -230,8 +231,8 @@ process SC__FILE_CONCATENATOR {
process SC__STAR_CONCATENATOR() {

container params.sc.scanpy.container
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/data/intermediate", mode: 'symlink', overwrite: true
label 'compute_resources__mem'

input:
tuple \
Expand Down Expand Up @@ -274,14 +275,14 @@ process SC__PUBLISH {
return "${tag}.${fileOutputSuffix}.${f.extension}"
}

clusterOptions "-l nodes=1:ppn=2 -l pmem=3gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir \
"${getPublishDir(params.global.outdir,toolName)}", \
mode: 'link', \
overwrite: true, \
saveAs: {
filename -> "${outputFileName}"
}
label 'compute_resources__minimal'


input:
Expand Down Expand Up @@ -320,8 +321,8 @@ process SC__PUBLISH {
process COMPRESS_HDF5() {

container "vibsinglecellnf/hdf5:1.10.5-r2"
clusterOptions "-l nodes=1:ppn=2 -l pmem=30gb -l walltime=1:00:00 -A ${params.global.qsubaccount}"
publishDir "${params.global.outdir}/data/intermediate", mode: 'symlink', overwrite: true
label 'compute_resources__mem'

def getFileOutputSuffix = { params, fileOutputSuffix, toolName ->
if(isParamNull(fileOutputSuffix) && isParamNull(toolName) &&
Expand Down