From 3d7e09069e5c195d7ac3953873dcfbd5ec14f614 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 12:48:58 +0000 Subject: [PATCH 1/7] Optimize qualimap performance with multi-threaded name sorting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-sort BAM files by read name using samtools with multi-threading before running qualimap rnaseq. This reduces qualimap execution time by >50% (from ~85 min to <40 min) by offloading the single-threaded sorting to the multi-threaded samtools sort with the -n flag, then passing the sorted BAM to qualimap with the --sorted flag. Resolves #1356 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/nf-core/qualimap/rnaseq/nextflow.config | 6 ++++++ workflows/rnaseq/main.nf | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/nf-core/qualimap/rnaseq/nextflow.config b/modules/nf-core/qualimap/rnaseq/nextflow.config index 2d3756d58..ce5a87ef7 100644 --- a/modules/nf-core/qualimap/rnaseq/nextflow.config +++ b/modules/nf-core/qualimap/rnaseq/nextflow.config @@ -1,7 +1,13 @@ if (!params.skip_qc) { if (!params.skip_qualimap) { process { + withName: 'SAMTOOLS_SORT_QUALIMAP' { + ext.args = '-n' + ext.prefix = { "${meta.id}.namesorted" } + } + withName: 'QUALIMAP_RNASEQ' { + ext.args = '--sorted' publishDir = [ path: { "${params.outdir}/${params.aligner}/qualimap" }, mode: params.publish_dir_mode, diff --git a/workflows/rnaseq/main.nf b/workflows/rnaseq/main.nf index d3a3ded0c..4d0046e2e 100755 --- a/workflows/rnaseq/main.nf +++ b/workflows/rnaseq/main.nf @@ -47,6 +47,7 @@ include { MULTIQC } from '../../modules/nf-core/multiqc' include { BEDTOOLS_GENOMECOV as BEDTOOLS_GENOMECOV_FW } from '../../modules/nf-core/bedtools/genomecov' include { BEDTOOLS_GENOMECOV as BEDTOOLS_GENOMECOV_REV } from '../../modules/nf-core/bedtools/genomecov' include { SAMTOOLS_INDEX } from '../../modules/nf-core/samtools/index' +include { SAMTOOLS_SORT as SAMTOOLS_SORT_QUALIMAP } from '../../modules/nf-core/samtools/sort' // // SUBWORKFLOW: Consisting entirely of nf-core/modules @@ -539,8 +540,15 @@ workflow RNASEQ { // if (!params.skip_qc) { if (!params.skip_qualimap) { - QUALIMAP_RNASEQ ( + // Sort BAM by name for qualimap (performance optimization) + SAMTOOLS_SORT_QUALIMAP ( ch_genome_bam, + ch_fasta.map { [ [:], it ] } + ) + ch_versions = ch_versions.mix(SAMTOOLS_SORT_QUALIMAP.out.versions.first()) + + QUALIMAP_RNASEQ ( + SAMTOOLS_SORT_QUALIMAP.out.bam, ch_gtf.map { [ [:], it ] } ) ch_multiqc_files = ch_multiqc_files.mix(QUALIMAP_RNASEQ.out.results.collect{it[1]}) From 4406a60cc669599274ceaf9346f056837605f729 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 12:50:10 +0000 Subject: [PATCH 2/7] Update changelog for qualimap optimization PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add changelog entry for PR #1621 which optimizes qualimap performance through multi-threaded name sorting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c45983f..f84594c35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Special thanks to the following for their contributions to the release: - [PR #1608](https://github.com/nf-core/rnaseq/pull/1608) - Bump version after release 3.21.0 - [PR #1617](https://github.com/nf-core/rnaseq/pull/1617) - Update bbmap/bbsplit module +- [PR #1621](https://github.com/nf-core/rnaseq/pull/1621) - Optimize qualimap performance with multi-threaded name sorting ## [[3.21.0](https://github.com/nf-core/rnaseq/releases/tag/3.21.0)] - 2025-09-18 From 5ee83f814fed26546f679a81ce8cbe301193b93f Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 14:17:29 +0000 Subject: [PATCH 3/7] Disable publishing of intermediate sorted BAM files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent the name-sorted BAM files created for qualimap from being published as they are only intermediate files used for performance optimization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- modules/nf-core/qualimap/rnaseq/nextflow.config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/nf-core/qualimap/rnaseq/nextflow.config b/modules/nf-core/qualimap/rnaseq/nextflow.config index ce5a87ef7..5c1b59423 100644 --- a/modules/nf-core/qualimap/rnaseq/nextflow.config +++ b/modules/nf-core/qualimap/rnaseq/nextflow.config @@ -4,6 +4,9 @@ if (!params.skip_qc) { withName: 'SAMTOOLS_SORT_QUALIMAP' { ext.args = '-n' ext.prefix = { "${meta.id}.namesorted" } + publishDir = [ + enabled: false + ] } withName: 'QUALIMAP_RNASEQ' { From e481c5a978c3206de85f6cf52a81235695e70fb9 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 16:21:30 +0000 Subject: [PATCH 4/7] Update test snapshots for SAMTOOLS_SORT_QUALIMAP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add SAMTOOLS_SORT_QUALIMAP version entry to all test snapshots that run qualimap, reflecting the new samtools sort step added for performance optimization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/bam_input.nf.test.snap | 6 ++++++ tests/default.nf.test.snap | 3 +++ tests/featurecounts_group_type.nf.test.snap | 3 +++ tests/hisat2.nf.test.snap | 3 +++ tests/min_mapped_reads.nf.test.snap | 3 +++ tests/remove_ribo_rna.nf.test.snap | 3 +++ tests/sentieon_default.nf.test.snap | 3 +++ tests/skip_trimming.nf.test.snap | 3 +++ tests/star_rsem.nf.test.snap | 3 +++ tests/umi.nf.test.snap | 3 +++ 10 files changed, 33 insertions(+) diff --git a/tests/bam_input.nf.test.snap b/tests/bam_input.nf.test.snap index 17dfec744..72edbe04e 100644 --- a/tests/bam_input.nf.test.snap +++ b/tests/bam_input.nf.test.snap @@ -79,6 +79,9 @@ "SAMTOOLS_INDEX": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, @@ -1041,6 +1044,9 @@ "SAMTOOLS_INDEX": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/default.nf.test.snap b/tests/default.nf.test.snap index 8571c3100..62d351014 100644 --- a/tests/default.nf.test.snap +++ b/tests/default.nf.test.snap @@ -199,6 +199,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/featurecounts_group_type.nf.test.snap b/tests/featurecounts_group_type.nf.test.snap index 4b07d4b71..24f35578f 100644 --- a/tests/featurecounts_group_type.nf.test.snap +++ b/tests/featurecounts_group_type.nf.test.snap @@ -196,6 +196,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/hisat2.nf.test.snap b/tests/hisat2.nf.test.snap index cf66b6527..219ec3a68 100644 --- a/tests/hisat2.nf.test.snap +++ b/tests/hisat2.nf.test.snap @@ -203,6 +203,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/min_mapped_reads.nf.test.snap b/tests/min_mapped_reads.nf.test.snap index 72ced7061..10c8f47c3 100644 --- a/tests/min_mapped_reads.nf.test.snap +++ b/tests/min_mapped_reads.nf.test.snap @@ -98,6 +98,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/remove_ribo_rna.nf.test.snap b/tests/remove_ribo_rna.nf.test.snap index e2789c952..f1efd3454 100644 --- a/tests/remove_ribo_rna.nf.test.snap +++ b/tests/remove_ribo_rna.nf.test.snap @@ -98,6 +98,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/sentieon_default.nf.test.snap b/tests/sentieon_default.nf.test.snap index 6c9d283f5..d523e1bf3 100644 --- a/tests/sentieon_default.nf.test.snap +++ b/tests/sentieon_default.nf.test.snap @@ -199,6 +199,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/skip_trimming.nf.test.snap b/tests/skip_trimming.nf.test.snap index a95a80efe..88d6365c4 100644 --- a/tests/skip_trimming.nf.test.snap +++ b/tests/skip_trimming.nf.test.snap @@ -98,6 +98,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/star_rsem.nf.test.snap b/tests/star_rsem.nf.test.snap index f0f78f74f..b70e7e35c 100644 --- a/tests/star_rsem.nf.test.snap +++ b/tests/star_rsem.nf.test.snap @@ -109,6 +109,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, diff --git a/tests/umi.nf.test.snap b/tests/umi.nf.test.snap index fc7524acf..8c63c87bb 100644 --- a/tests/umi.nf.test.snap +++ b/tests/umi.nf.test.snap @@ -92,6 +92,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 }, From 3bd27e8dc895af97a5ea8252f2de9ebaf102345d Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 17:16:45 +0000 Subject: [PATCH 5/7] Update version counts in QUALIMAP test blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Increment version counts by 5 in test blocks that run qualimap to account for the additional SAMTOOLS_SORT_QUALIMAP process. Only test blocks containing QUALIMAP_RNASEQ are updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- tests/bam_input.nf.test.snap | 4 ++-- tests/default.nf.test.snap | 2 +- tests/featurecounts_group_type.nf.test.snap | 2 +- tests/hisat2.nf.test.snap | 2 +- tests/min_mapped_reads.nf.test.snap | 2 +- tests/remove_ribo_rna.nf.test.snap | 2 +- tests/sentieon_default.nf.test.snap | 2 +- tests/skip_trimming.nf.test.snap | 2 +- tests/star_rsem.nf.test.snap | 2 +- tests/umi.nf.test.snap | 4 ++-- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/bam_input.nf.test.snap b/tests/bam_input.nf.test.snap index 72edbe04e..388233d7d 100644 --- a/tests/bam_input.nf.test.snap +++ b/tests/bam_input.nf.test.snap @@ -1,7 +1,7 @@ { "BAM input for Salmon": { "content": [ - 139, + 144, { "BBMAP_BBSPLIT": { "bbmap": 39.18 @@ -961,7 +961,7 @@ }, "BAM input for RSEM": { "content": [ - 138, + 143, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/default.nf.test.snap b/tests/default.nf.test.snap index 62d351014..0798e8ef4 100644 --- a/tests/default.nf.test.snap +++ b/tests/default.nf.test.snap @@ -102,7 +102,7 @@ }, "Params: default": { "content": [ - 209, + 214, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/featurecounts_group_type.nf.test.snap b/tests/featurecounts_group_type.nf.test.snap index 24f35578f..5f34e3174 100644 --- a/tests/featurecounts_group_type.nf.test.snap +++ b/tests/featurecounts_group_type.nf.test.snap @@ -102,7 +102,7 @@ }, "Params: --featurecounts_group_type false": { "content": [ - 199, + 204, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/hisat2.nf.test.snap b/tests/hisat2.nf.test.snap index 219ec3a68..032160724 100644 --- a/tests/hisat2.nf.test.snap +++ b/tests/hisat2.nf.test.snap @@ -103,7 +103,7 @@ }, "Params: --aligner hisat2": { "content": [ - 200, + 205, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/min_mapped_reads.nf.test.snap b/tests/min_mapped_reads.nf.test.snap index 10c8f47c3..00ffc5607 100644 --- a/tests/min_mapped_reads.nf.test.snap +++ b/tests/min_mapped_reads.nf.test.snap @@ -1,7 +1,7 @@ { "Params: --min_mapped_reads 90": { "content": [ - 163, + 168, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/remove_ribo_rna.nf.test.snap b/tests/remove_ribo_rna.nf.test.snap index f1efd3454..f6de3f886 100644 --- a/tests/remove_ribo_rna.nf.test.snap +++ b/tests/remove_ribo_rna.nf.test.snap @@ -1,7 +1,7 @@ { "Params: --remove_ribo_rna": { "content": [ - 220, + 225, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/sentieon_default.nf.test.snap b/tests/sentieon_default.nf.test.snap index d523e1bf3..69e433e8a 100644 --- a/tests/sentieon_default.nf.test.snap +++ b/tests/sentieon_default.nf.test.snap @@ -102,7 +102,7 @@ }, "Params: default --use_sentieon_star": { "content": [ - 209, + 214, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/skip_trimming.nf.test.snap b/tests/skip_trimming.nf.test.snap index 88d6365c4..e4e43d55b 100644 --- a/tests/skip_trimming.nf.test.snap +++ b/tests/skip_trimming.nf.test.snap @@ -1,7 +1,7 @@ { "Params: --skip_trimming": { "content": [ - 199, + 204, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/star_rsem.nf.test.snap b/tests/star_rsem.nf.test.snap index b70e7e35c..68292fc9e 100644 --- a/tests/star_rsem.nf.test.snap +++ b/tests/star_rsem.nf.test.snap @@ -1,7 +1,7 @@ { "Params: --aligner star_rsem": { "content": [ - 207, + 212, { "BBMAP_BBSPLIT": { "bbmap": 39.18 diff --git a/tests/umi.nf.test.snap b/tests/umi.nf.test.snap index 8c63c87bb..0acdb8986 100644 --- a/tests/umi.nf.test.snap +++ b/tests/umi.nf.test.snap @@ -1,7 +1,7 @@ { "--umi_dedup_tool 'umitools'": { "content": [ - 261, + 266, { "BEDTOOLS_GENOMECOV_FW": { "bedtools": "2.31.1" @@ -1510,7 +1510,7 @@ }, "Params: --aligner hisat2 --umi_dedup_tool 'umicollapse'": { "content": [ - 194, + 199, { "BEDTOOLS_GENOMECOV_FW": { "bedtools": "2.31.1" From c31e770164819f02b2349cbad424d250594e16c3 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 18:10:54 +0000 Subject: [PATCH 6/7] Final test file fix --- tests/min_mapped_reads.nf.test.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/min_mapped_reads.nf.test.snap b/tests/min_mapped_reads.nf.test.snap index 00ffc5607..014c2f424 100644 --- a/tests/min_mapped_reads.nf.test.snap +++ b/tests/min_mapped_reads.nf.test.snap @@ -1,7 +1,7 @@ { "Params: --min_mapped_reads 90": { "content": [ - 168, + 166, { "BBMAP_BBSPLIT": { "bbmap": 39.18 From b9d5e0829a46bc39965d8e1c364690ef02f216b1 Mon Sep 17 00:00:00 2001 From: Jonathan Manning Date: Fri, 14 Nov 2025 18:32:24 +0000 Subject: [PATCH 7/7] Final test file fix --- tests/umi.nf.test.snap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/umi.nf.test.snap b/tests/umi.nf.test.snap index 0acdb8986..8ddd1d27c 100644 --- a/tests/umi.nf.test.snap +++ b/tests/umi.nf.test.snap @@ -1604,6 +1604,9 @@ "SAMTOOLS_SORT": { "samtools": 1.21 }, + "SAMTOOLS_SORT_QUALIMAP": { + "samtools": 1.21 + }, "SAMTOOLS_STATS": { "samtools": 1.21 },