From 0098906f37370bd630bd0beca2e4edcebf9df8d9 Mon Sep 17 00:00:00 2001 From: kopichris Date: Tue, 29 Oct 2024 18:18:05 +0800 Subject: [PATCH 1/5] feat(cellranger count and multi): Add create-bam option to cellranger count and multi pipelines --- conf/modules.config | 2 +- nextflow.config | 2 ++ nextflow_schema.json | 11 +++++++++++ workflows/scrnaseq.nf | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index 81395a1d..15073a21 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -82,7 +82,7 @@ if(params.aligner == "cellranger") { path: "${params.outdir}/${params.aligner}/count", mode: params.publish_dir_mode ] - ext.args = {"--chemistry ${meta.chemistry} --create-bam true " + (meta.expected_cells ? "--expect-cells ${meta.expected_cells}" : '')} + ext.args = {"--chemistry ${meta.chemistry} --create-bam ${params.cellranger_create_bam}" + " " + (meta.expected_cells ? "--expect-cells ${meta.expected_cells}" : '')} time = { check_max( 240.h * task.attempt, 'time' ) } } } diff --git a/nextflow.config b/nextflow.config index e1b608d2..7a5a6c76 100644 --- a/nextflow.config +++ b/nextflow.config @@ -43,6 +43,7 @@ params { // Cellranger parameters skip_cellranger_renaming = false cellranger_index = null + cellranger_create_bam = true // Cellranger ARC parameters motifs = null @@ -65,6 +66,7 @@ params { vdj_inner_enrichment_primers = null gex_barcode_sample_assignment = null cellranger_multi_barcodes = null + cellranger_multi_create_bam = true // Template Boilerplate options diff --git a/nextflow_schema.json b/nextflow_schema.json index e5fb71b5..f582e934 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -270,6 +270,11 @@ "skip_cellranger_renaming": { "type": "boolean", "description": "Should it skip the automatic renaming included in cellranger-related modules?" + }, + "cellranger_create_bam": { + "type": "boolean", + "description": "Create BAM alignment file. Note: Using the default value of true will increase computational resources and disk space. Please see the [10x documentation about create-bam parameter](https://kb.10xgenomics.com/hc/en-us/articles/24292856143885-Understanding-the-create-bam-Parameter-in-Cell-Ranger-v8-0) for more information.", + "default": true } } }, @@ -366,6 +371,11 @@ "exists": true, "mimetype": "text/csv", "description": "Additional samplesheet to provide information about multiplexed samples. See the 'Usage' section for more details." + }, + "cellranger_multi_create_bam": { + "type": "boolean", + "description": "Create BAM alignment file. Note: Using the default value of true will increase computational resources and disk space. Please see the [10x documentation about create-bam parameter](https://kb.10xgenomics.com/hc/en-us/articles/24292856143885-Understanding-the-create-bam-Parameter-in-Cell-Ranger-v8-0) for more information.", + "default": true } } }, @@ -617,3 +627,4 @@ } ] } + diff --git a/workflows/scrnaseq.nf b/workflows/scrnaseq.nf index 10ced221..94bbb844 100644 --- a/workflows/scrnaseq.nf +++ b/workflows/scrnaseq.nf @@ -237,7 +237,7 @@ workflow SCRNASEQ { // add cellranger options that are currently handled by pipeline, coming from samplesheet // the module parses them from the 'gex' options if (meta.feature_type.toString() == 'gex') { - parsed_meta.options['create-bam'] = true // force bam creation -- param required by cellranger multi + parsed_meta.options['create-bam'] = params.cellranger_multi_create_bam // force bam creation -- param required by cellranger multi if (meta.expected_cells) { parsed_meta.options['expected-cells'] = meta.expected_cells } } From c749bf2aee0ea769b77ad44e51c2c04b83a456a2 Mon Sep 17 00:00:00 2001 From: kopichris Date: Tue, 29 Oct 2024 18:54:40 +0800 Subject: [PATCH 2/5] chore: Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd1b6e41..239b53b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +- Add --create-bam parameter to cellranger count and multi pipelines ([#384](https://github.com/nf-core/scrnaseq/issues/384)) + ## v2.7.1 - 2024-08-13 - Fix that tests have not been executed with nf-test v0.9 ([#359](https://github.com/nf-core/scrnaseq/pull/359)) From 36eeee39339446e84a4d5362ff47562ff9fe5441 Mon Sep 17 00:00:00 2001 From: kopichris Date: Sat, 2 Nov 2024 01:17:38 +0800 Subject: [PATCH 3/5] feat: Create single boolean parameter allowing users to control how alignment files are saved for CellRanger and STAR --- conf/modules.config | 25 +++++++++++++++++++------ nextflow.config | 3 +-- nextflow_schema.json | 15 +++++---------- workflows/scrnaseq.nf | 2 +- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index 15073a21..502f00ff 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -82,7 +82,7 @@ if(params.aligner == "cellranger") { path: "${params.outdir}/${params.aligner}/count", mode: params.publish_dir_mode ] - ext.args = {"--chemistry ${meta.chemistry} --create-bam ${params.cellranger_create_bam}" + " " + (meta.expected_cells ? "--expect-cells ${meta.expected_cells}" : '')} + ext.args = {"--chemistry ${meta.chemistry} --create-bam ${params.save_align_intermeds}" + " " + (meta.expected_cells ? "--expect-cells ${meta.expected_cells}" : '')} time = { check_max( 240.h * task.attempt, 'time' ) } } } @@ -186,11 +186,24 @@ if (params.aligner == "star") { enabled: params.save_reference ] } - withName: STAR_ALIGN { - publishDir = [ - path: { "${params.outdir}/${params.aligner}/${meta.id}" }, - mode: params.publish_dir_mode - ] + + if(params.save_align_intermeds) { + withName: 'STAR_ALIGN' { + publishDir = [ + path: { "${params.outdir}/${params.aligner}/${meta.id}" }, + mode: params.publish_dir_mode + ] + } + } + else { + withName: 'STAR_ALIGN' { + publishDir = [ + path: { "${params.outdir}/${params.aligner}/${meta.id}" }, + mode: params.publish_dir_mode, + pattern: '*', + saveAs: { it.endsWith('.bam') ? null : it } + ] + } } } } diff --git a/nextflow.config b/nextflow.config index 7a5a6c76..0e8f3399 100644 --- a/nextflow.config +++ b/nextflow.config @@ -13,6 +13,7 @@ params { aligner = 'alevin' input = null save_reference = false + save_align_intermeds = true protocol = 'auto' // reference files @@ -43,7 +44,6 @@ params { // Cellranger parameters skip_cellranger_renaming = false cellranger_index = null - cellranger_create_bam = true // Cellranger ARC parameters motifs = null @@ -66,7 +66,6 @@ params { vdj_inner_enrichment_primers = null gex_barcode_sample_assignment = null cellranger_multi_barcodes = null - cellranger_multi_create_bam = true // Template Boilerplate options diff --git a/nextflow_schema.json b/nextflow_schema.json index f582e934..07e53e4c 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -142,6 +142,11 @@ "description": "Specify this parameter to save the indices created (STAR, Kallisto, Salmon) to the results.", "fa_icon": "fas fa-bookmark" }, + "save_align_intermeds": { + "type": "boolean", + "description": "Specify this parameter to save the intermediate alignment files (STAR, CellRanger) to the results.", + "fa_icon": "fas fa-bookmark" + }, "igenomes_base": { "type": "string", "format": "directory-path", @@ -270,11 +275,6 @@ "skip_cellranger_renaming": { "type": "boolean", "description": "Should it skip the automatic renaming included in cellranger-related modules?" - }, - "cellranger_create_bam": { - "type": "boolean", - "description": "Create BAM alignment file. Note: Using the default value of true will increase computational resources and disk space. Please see the [10x documentation about create-bam parameter](https://kb.10xgenomics.com/hc/en-us/articles/24292856143885-Understanding-the-create-bam-Parameter-in-Cell-Ranger-v8-0) for more information.", - "default": true } } }, @@ -371,11 +371,6 @@ "exists": true, "mimetype": "text/csv", "description": "Additional samplesheet to provide information about multiplexed samples. See the 'Usage' section for more details." - }, - "cellranger_multi_create_bam": { - "type": "boolean", - "description": "Create BAM alignment file. Note: Using the default value of true will increase computational resources and disk space. Please see the [10x documentation about create-bam parameter](https://kb.10xgenomics.com/hc/en-us/articles/24292856143885-Understanding-the-create-bam-Parameter-in-Cell-Ranger-v8-0) for more information.", - "default": true } } }, diff --git a/workflows/scrnaseq.nf b/workflows/scrnaseq.nf index 94bbb844..2a0ea5d2 100644 --- a/workflows/scrnaseq.nf +++ b/workflows/scrnaseq.nf @@ -237,7 +237,7 @@ workflow SCRNASEQ { // add cellranger options that are currently handled by pipeline, coming from samplesheet // the module parses them from the 'gex' options if (meta.feature_type.toString() == 'gex') { - parsed_meta.options['create-bam'] = params.cellranger_multi_create_bam // force bam creation -- param required by cellranger multi + parsed_meta.options['create-bam'] = params.save_align_intermeds // force bam creation -- param required by cellranger multi if (meta.expected_cells) { parsed_meta.options['expected-cells'] = meta.expected_cells } } From bf1a9df2004bac856008a0a073e054bc83b2aeae Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 6 Nov 2024 19:09:32 +0800 Subject: [PATCH 4/5] Remove check_max function in cellranger_count block Co-authored-by: Gregor Sturm --- conf/modules.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index dd65957a..c049e5b3 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -82,7 +82,7 @@ if(params.aligner == "cellranger") { mode: params.publish_dir_mode ] ext.args = {"--chemistry ${meta.chemistry} --create-bam ${params.save_align_intermeds}" + " " + (meta.expected_cells ? "--expect-cells ${meta.expected_cells}" : '')} - time = { check_max( 240.h * task.attempt, 'time' ) } + time = { 240.h * task.attempt, 'time' } } } } From 2cfe0df9fdff0f84abc45ad3643572f171654da5 Mon Sep 17 00:00:00 2001 From: kopichris Date: Fri, 8 Nov 2024 12:59:12 +0800 Subject: [PATCH 5/5] chore: remove string from time property in cellranger count module --- conf/modules.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index c049e5b3..d00278a6 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -82,7 +82,7 @@ if(params.aligner == "cellranger") { mode: params.publish_dir_mode ] ext.args = {"--chemistry ${meta.chemistry} --create-bam ${params.save_align_intermeds}" + " " + (meta.expected_cells ? "--expect-cells ${meta.expected_cells}" : '')} - time = { 240.h * task.attempt, 'time' } + time = { 240.h * task.attempt } } } }