From f187f8a101311dfd41e1895500d524267a87a10f Mon Sep 17 00:00:00 2001 From: Emilio Palumbo Date: Thu, 20 Jul 2023 10:40:12 +0200 Subject: [PATCH] Reduce memory usage in RSEM quantification process --- grape-pipeline.nf | 2 ++ templates/quantification/RSEM-Paired-End-MATE1_SENSE | 4 ++-- templates/quantification/RSEM-Paired-End-MATE2_SENSE | 4 ++-- templates/quantification/RSEM-Paired-End-NONE | 4 ++-- templates/quantification/RSEM-Single-End-ANTISENSE | 4 ++-- templates/quantification/RSEM-Single-End-NONE | 4 ++-- templates/quantification/RSEM-Single-End-SENSE | 4 ++-- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/grape-pipeline.nf b/grape-pipeline.nf index 7f49be7..6cde7d7 100755 --- a/grape-pipeline.nf +++ b/grape-pipeline.nf @@ -736,6 +736,8 @@ process quantification { viewTx = "TranscriptQuantifications" viewGn = "GeneQuantifications" memory = (task.memory ?: 1.GB).toMega() + sortMemory = Math.max(1024, (memory / 2) as long) + ciMemory = Math.max(1024, (memory / 4) as long) command = "${task.process}/${params.quantificationTool}" if ( params.quantificationTool == 'RSEM') { command += "-${pairedEnd ? 'Paired-End' : 'Single-End'}" diff --git a/templates/quantification/RSEM-Paired-End-MATE1_SENSE b/templates/quantification/RSEM-Paired-End-MATE1_SENSE index de1b23d..b0fb871 100644 --- a/templates/quantification/RSEM-Paired-End-MATE1_SENSE +++ b/templates/quantification/RSEM-Paired-End-MATE1_SENSE @@ -2,14 +2,14 @@ set -e set -u -sambamba sort -t ${cpus} -m ${memory}MB -N -M -l 0 -o - ${bam} \ +sambamba sort -t ${cpus} -m ${sortMemory}MB -N -M -l 0 -o - ${bam} \ | rsem-calculate-expression --bam \ --estimate-rspd \ --calc-ci \ --no-bam-output \ --seed 12345 \ -p ${cpus} \ - --ci-memory ${memory} \ + --ci-memory ${ciMemory} \ --paired-end \ --forward-prob 1 \ - \ diff --git a/templates/quantification/RSEM-Paired-End-MATE2_SENSE b/templates/quantification/RSEM-Paired-End-MATE2_SENSE index 7ad59a6..9eb43e7 100644 --- a/templates/quantification/RSEM-Paired-End-MATE2_SENSE +++ b/templates/quantification/RSEM-Paired-End-MATE2_SENSE @@ -2,14 +2,14 @@ set -e set -u -sambamba sort -t ${cpus} -m ${memory}MB -N -M -l 0 -o - ${bam} \ +sambamba sort -t ${cpus} -m ${sortMemory}MB -N -M -l 0 -o - ${bam} \ | rsem-calculate-expression --bam \ --estimate-rspd \ --calc-ci \ --no-bam-output \ --seed 12345 \ -p ${cpus} \ - --ci-memory ${memory} \ + --ci-memory ${ciMemory} \ --paired-end \ --forward-prob 0 \ - \ diff --git a/templates/quantification/RSEM-Paired-End-NONE b/templates/quantification/RSEM-Paired-End-NONE index 771ce64..2557930 100644 --- a/templates/quantification/RSEM-Paired-End-NONE +++ b/templates/quantification/RSEM-Paired-End-NONE @@ -2,14 +2,14 @@ set -e set -u -sambamba sort -t ${cpus} -m ${memory}MB -N -M -l 0 -o - ${bam} \ +sambamba sort -t ${cpus} -m ${sortMemory}MB -N -M -l 0 -o - ${bam} \ | rsem-calculate-expression --bam \ --estimate-rspd \ --calc-ci \ --no-bam-output \ --seed 12345 \ -p ${cpus} \ - --ci-memory ${memory} \ + --ci-memory ${ciMemory} \ --paired-end \ - \ ${quantRef}/RSEMref \ diff --git a/templates/quantification/RSEM-Single-End-ANTISENSE b/templates/quantification/RSEM-Single-End-ANTISENSE index 3f25653..0b45f80 100644 --- a/templates/quantification/RSEM-Single-End-ANTISENSE +++ b/templates/quantification/RSEM-Single-End-ANTISENSE @@ -2,14 +2,14 @@ set -e set -u -sambamba sort -t ${cpus} -m ${memory}MB -N -l 0 -o - ${bam} \ +sambamba sort -t ${cpus} -m ${sortMemory}MB -N -l 0 -o - ${bam} \ | rsem-calculate-expression --bam \ --estimate-rspd \ --calc-ci \ --no-bam-output \ --seed 12345 \ -p ${cpus} \ - --ci-memory ${memory} \ + --ci-memory ${ciMemory} \ --forward-prob 0 \ - \ ${quantRef}/RSEMref \ diff --git a/templates/quantification/RSEM-Single-End-NONE b/templates/quantification/RSEM-Single-End-NONE index e50fb1f..237c361 100644 --- a/templates/quantification/RSEM-Single-End-NONE +++ b/templates/quantification/RSEM-Single-End-NONE @@ -2,14 +2,14 @@ set -e set -u -sambamba sort -t ${cpus} -m ${memory}MB -N -l 0 -o - ${bam} \ +sambamba sort -t ${cpus} -m ${sortMemory}MB -N -l 0 -o - ${bam} \ | rsem-calculate-expression --bam \ --estimate-rspd \ --calc-ci \ --no-bam-output \ --seed 12345 \ -p ${cpus} \ - --ci-memory ${memory} \ + --ci-memory ${ciMemory} \ - \ ${quantRef}/RSEMref \ ${prefix} diff --git a/templates/quantification/RSEM-Single-End-SENSE b/templates/quantification/RSEM-Single-End-SENSE index a6aa406..68e0547 100644 --- a/templates/quantification/RSEM-Single-End-SENSE +++ b/templates/quantification/RSEM-Single-End-SENSE @@ -2,14 +2,14 @@ set -e set -u -sambamba sort -t ${cpus} -m ${memory}MB -N -l 0 -o - ${bam} \ +sambamba sort -t ${cpus} -m ${sortMemory}MB -N -l 0 -o - ${bam} \ | rsem-calculate-expression --bam \ --estimate-rspd \ --calc-ci \ --no-bam-output \ --seed 12345 \ -p ${cpus} \ - --ci-memory ${memory} \ + --ci-memory ${ciMemory} \ --forward-prob 1 \ - \ ${quantRef}/RSEMref \