Skip to content

Commit

Permalink
Merge pull request #552 from nf-core/mito_wes
Browse files Browse the repository at this point in the history
Skip mitochondrial analysis for WES
  • Loading branch information
ramprasadn committed May 20, 2024
2 parents 4a9bb55 + 8c93dc5 commit 6521bba
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 131 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### `Added`

- A new parameter `run_mt_for_wes` to turn on mitochondrial analysis for targeted analysis [#552](https://github.com/nf-core/raredisease/pull/552)
- A new parameter `bwa_as_fallback` to switch aligner to bwa in case bwamem2 fails [#551](https://github.com/nf-core/raredisease/pull/551)

### `Changed`
Expand All @@ -22,8 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Parameters

| Old parameter | New parameter |
| ------------- | ------------- |
| Old parameter | New parameter |
| ------------- | --------------- |
| | bwa_as_fallback |
| | run_mt_for_wes |

:::note
Parameter has been updated if both old and new parameter information is present.
Expand Down
6 changes: 0 additions & 6 deletions conf/modules/align_MT.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ process {

withName: '.*ALIGN_MT:BWAMEM2_MEM_MT' {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.when = { !(params.analysis_type.equals("wes")) }
ext.prefix = { "${meta.id}_sorted" }
}

withName: '.*ALIGN_MT:BWA_MEM_MT' {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.when = { !(params.analysis_type.equals("wes")) }
ext.prefix = { "${meta.id}_sorted" }
}

withName: '.*ALIGN_MT:SENTIEON_BWAMEM_MT' {
ext.args = { "-M -K 10000000 -R ${meta.read_group}" }
ext.when = { !(params.analysis_type.equals("wes"))}
ext.prefix = { "${meta.id}_sorted" }
}

Expand Down Expand Up @@ -70,19 +67,16 @@ process {

withName: '.*ALIGN_MT_SHIFT:BWAMEM2_MEM_MT' {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.when = { !(params.analysis_type.equals("wes")) }
ext.prefix = { "${meta.id}_sorted_shifted" }
}

withName: '.*ALIGN_MT_SHIFT:SENTIEON_BWAMEM_MT' {
ext.args = { "-M -K 10000000 -R ${meta.read_group}" }
ext.when = { !(params.analysis_type.equals("wes"))}
ext.prefix = { "${meta.id}_sorted_shifted" }
}

withName: '.*ALIGN_MT_SHIFT:BWA_MEM_MT' {
ext.args = { "-M -K 100000000 -R ${meta.read_group}" }
ext.when = { !(params.analysis_type.equals("wes")) }
ext.prefix = { "${meta.id}_sorted_shifted" }
}

Expand Down
4 changes: 0 additions & 4 deletions conf/modules/call_repeat_expansions.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
//

process {
withName: '.*CALL_REPEAT_EXPANSIONS:.*' {
ext.when = { params.analysis_type != "wes" }
}

withName: '.*CALL_REPEAT_EXPANSIONS:EXPANSIONHUNTER' {
ext.args = { ("${meta.sex}" == '1') ? '--sex male' : '--sex female' }
ext.prefix = { "${meta.id}_exphunter" }
Expand Down
10 changes: 5 additions & 5 deletions conf/modules/prepare_references.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ process {
}

withName: '.*PREPARE_REFERENCES:BWAMEM2_INDEX_MT_SHIFT' {
ext.when = { !(params.analysis_type == "wes") && params.aligner == "bwamem2"}
ext.when = { (params.analysis_type.equals("wgs") || params.run_mt_for_wes) && params.aligner == "bwamem2"}
}

withName: '.*PREPARE_REFERENCES:SENTIEON_BWAINDEX_GENOME' {
ext.when = {!params.bwa && params.aligner == "sentieon"}
}

withName: '.*PREPARE_REFERENCES:SENTIEON_BWAINDEX_MT_SHIFT' {
ext.when = { !(params.analysis_type == "wes") && params.aligner == "sentieon"}
ext.when = { (params.analysis_type.equals("wgs") || params.run_mt_for_wes) && params.aligner == "sentieon"}
}

withName: '.*PREPARE_REFERENCES:BWA_INDEX_MT_SHIFT' {
ext.when = { !(params.analysis_type == "wes") && params.aligner == "bwa"}
ext.when = { (params.analysis_type.equals("wgs") || params.run_mt_for_wes) && params.aligner == "bwa"}
}

withName: '.*PREPARE_REFERENCES:BWA_INDEX_GENOME' {
Expand All @@ -63,7 +63,7 @@ process {
}

withName: '.*PREPARE_REFERENCES:SAMTOOLS_FAIDX_MT_SHIFT' {
ext.when = { !(params.analysis_type == "wes")}
ext.when = { (params.analysis_type.equals("wgs") || params.run_mt_for_wes) }
}

withName: '.*PREPARE_REFERENCES:GATK_SD' {
Expand All @@ -75,7 +75,7 @@ process {
}

withName: '.*PREPARE_REFERENCES:GATK_SD_MT_SHIFT' {
ext.when = { !(params.analysis_type == "wes")}
ext.when = { (params.analysis_type.equals("wgs") || params.run_mt_for_wes)}
}

withName: '.*PREPARE_REFERENCES:TABIX_DBSNP' {
Expand Down
8 changes: 4 additions & 4 deletions conf/modules/qc_bam.config
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ process {

withName: '.*QC_BAM:PICARD_COLLECTWGSMETRICS' {
ext.args = "--TMP_DIR ."
ext.when = { params.analysis_type.equals("wgs") && !params.aligner.equals("sentieon") }
ext.when = { !params.aligner.equals("sentieon") }
ext.prefix = { "${meta.id}_wgsmetrics" }
}

withName: '.*QC_BAM:PICARD_COLLECTWGSMETRICS_Y' {
ext.args = "--TMP_DIR ."
ext.when = { params.analysis_type.equals("wgs") && !params.aligner.equals("sentieon") }
ext.when = { !params.aligner.equals("sentieon") }
ext.prefix = { "${meta.id}_wgsmetrics_y" }
}

withName: '.*QC_BAM:SENTIEON_WGSMETRICS' {
ext.when = { params.analysis_type.equals("wgs") && params.aligner.equals("sentieon") }
ext.when = { params.aligner.equals("sentieon") }
ext.prefix = { "${meta.id}_wgsmetrics" }
}

withName: '.*QC_BAM:SENTIEON_WGSMETRICS_Y' {
ext.when = { params.analysis_type.equals("wgs") && params.aligner.equals("sentieon") }
ext.when = { params.aligner.equals("sentieon") }
ext.prefix = { "${meta.id}_wgsmetrics_y" }
}
}
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ params {
analysis_type = 'wgs'
bwa_as_fallback = false
bait_padding = 100
run_mt_for_wes = false
run_rtgvcfeval = false
save_mapped_as_cram = false
skip_eklipse = false
Expand Down
5 changes: 5 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@
"fa_icon": "fas fa-align-center",
"enum": ["xy", "hetx", "sry"]
},
"run_mt_for_wes": {
"type": "boolean",
"description": "Specifies whether to run mitochondrial analysis for wes samples",
"fa_icon": "fas fa-toggle-on"
},
"run_rtgvcfeval": {
"type": "boolean",
"description": "Specifies whether to run rtgtools' vcfeval",
Expand Down
87 changes: 47 additions & 40 deletions subworkflows/local/align.nf
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ workflow ALIGN {
val_platform // string: [mandatory] illumina or a different technology

main:
ch_versions = Channel.empty()
ch_fastp_json = Channel.empty()
ch_bwamem2_bam = Channel.empty()
ch_sentieon_bam = Channel.empty()
ch_bwamem2_bai = Channel.empty()
ch_sentieon_bai = Channel.empty()
ch_bwamem2_bam = Channel.empty()
ch_bwamem2_bai = Channel.empty()
ch_fastp_json = Channel.empty()
ch_mt_bam_bai = Channel.empty()
ch_mt_marked_bam = Channel.empty()
ch_mt_marked_bai = Channel.empty()
ch_mtshift_bam_bai = Channel.empty()
ch_mtshift_marked_bam = Channel.empty()
ch_mtshift_marked_bai = Channel.empty()
ch_sentieon_bam = Channel.empty()
ch_sentieon_bai = Channel.empty()
ch_versions = Channel.empty()

if (!params.skip_fastp) {
FASTP (ch_reads, [], false, false)
Expand Down Expand Up @@ -70,48 +76,49 @@ workflow ALIGN {
ch_genome_bam_bai = ch_genome_marked_bam.join(ch_genome_marked_bai, failOnMismatch:true, failOnDuplicate:true)

// PREPARING READS FOR MT ALIGNMENT
CONVERT_MT_BAM_TO_FASTQ (
ch_genome_bam_bai,
ch_genome_fasta,
ch_genome_fai,
ch_genome_dictionary
)

ALIGN_MT (
CONVERT_MT_BAM_TO_FASTQ.out.fastq,
CONVERT_MT_BAM_TO_FASTQ.out.bam,
ch_genome_bwaindex,
ch_genome_bwamem2index,
ch_genome_fasta,
ch_genome_dictionary,
ch_genome_fai
)
if (params.analysis_type.equals("wgs") || params.run_mt_for_wes) {
CONVERT_MT_BAM_TO_FASTQ (
ch_genome_bam_bai,
ch_genome_fasta,
ch_genome_fai,
ch_genome_dictionary
)

ALIGN_MT_SHIFT (
CONVERT_MT_BAM_TO_FASTQ.out.fastq,
CONVERT_MT_BAM_TO_FASTQ.out.bam,
ch_mtshift_bwaindex,
ch_mtshift_bwamem2index,
ch_mtshift_fasta,
ch_mtshift_dictionary,
ch_mtshift_fai
)
ALIGN_MT (
CONVERT_MT_BAM_TO_FASTQ.out.fastq,
CONVERT_MT_BAM_TO_FASTQ.out.bam,
ch_genome_bwaindex,
ch_genome_bwamem2index,
ch_genome_fasta,
ch_genome_dictionary,
ch_genome_fai
)

ch_mt_marked_bam = ALIGN_MT.out.marked_bam
ch_mt_marked_bai = ALIGN_MT.out.marked_bai
ch_mt_bam_bai = ch_mt_marked_bam.join(ch_mt_marked_bai, failOnMismatch:true, failOnDuplicate:true)
ALIGN_MT_SHIFT (
CONVERT_MT_BAM_TO_FASTQ.out.fastq,
CONVERT_MT_BAM_TO_FASTQ.out.bam,
ch_mtshift_bwaindex,
ch_mtshift_bwamem2index,
ch_mtshift_fasta,
ch_mtshift_dictionary,
ch_mtshift_fai
)

ch_mtshift_marked_bam = ALIGN_MT_SHIFT.out.marked_bam
ch_mtshift_marked_bai = ALIGN_MT_SHIFT.out.marked_bai
ch_mtshift_bam_bai = ch_mtshift_marked_bam.join(ch_mtshift_marked_bai, failOnMismatch:true, failOnDuplicate:true)
ch_mt_marked_bam = ALIGN_MT.out.marked_bam
ch_mt_marked_bai = ALIGN_MT.out.marked_bai
ch_mt_bam_bai = ch_mt_marked_bam.join(ch_mt_marked_bai, failOnMismatch:true, failOnDuplicate:true)
ch_mtshift_marked_bam = ALIGN_MT_SHIFT.out.marked_bam
ch_mtshift_marked_bai = ALIGN_MT_SHIFT.out.marked_bai
ch_mtshift_bam_bai = ch_mtshift_marked_bam.join(ch_mtshift_marked_bai, failOnMismatch:true, failOnDuplicate:true)
ch_versions = ch_versions.mix(ALIGN_MT.out.versions,
ALIGN_MT_SHIFT.out.versions,
CONVERT_MT_BAM_TO_FASTQ.out.versions)
}

if (params.save_mapped_as_cram) {
SAMTOOLS_VIEW( ch_genome_bam_bai, ch_genome_fasta, [] )
ch_versions = ch_versions.mix(SAMTOOLS_VIEW.out.versions)
}
ch_versions = ch_versions.mix(ALIGN_MT.out.versions,
ALIGN_MT_SHIFT.out.versions,
CONVERT_MT_BAM_TO_FASTQ.out.versions)

emit:
fastp_json = ch_fastp_json // channel: [ val(meta), path(json) ]
Expand Down
16 changes: 6 additions & 10 deletions subworkflows/local/alignment/align_MT.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,21 @@ workflow ALIGN_MT {

main:
ch_versions = Channel.empty()
ch_bwa_bam = Channel.empty()
ch_bwamem2_bam = Channel.empty()
ch_sentieon_bam = Channel.empty()

if (params.aligner.equals("bwamem2")) {
BWAMEM2_MEM_MT (ch_fastq, ch_bwamem2index, true)
ch_bwamem2_bam = BWAMEM2_MEM_MT.out.bam
ch_align = BWAMEM2_MEM_MT.out.bam
ch_versions = ch_versions.mix(BWAMEM2_MEM_MT.out.versions.first())
} else if (params.aligner.equals("sentieon")) {
SENTIEON_BWAMEM_MT ( ch_fastq, ch_bwaindex, ch_fasta, ch_fai )
ch_sentieon_bam = SENTIEON_BWAMEM_MT.out.bam_and_bai.map{ meta, bam, bai -> [meta, bam] }
ch_versions = ch_versions.mix(SENTIEON_BWAMEM_MT.out.versions.first())
ch_align = SENTIEON_BWAMEM_MT.out.bam_and_bai.map{ meta, bam, bai -> [meta, bam] }
ch_versions = ch_versions.mix(SENTIEON_BWAMEM_MT.out.versions.first())
} else if (params.aligner.equals("bwa")) {
BWA_MEM_MT ( ch_fastq, ch_bwaindex, true )
ch_bwa_bam = BWA_MEM_MT.out.bam
ch_versions = ch_versions.mix(BWA_MEM_MT.out.versions.first())
ch_align = BWA_MEM_MT.out.bam
ch_versions = ch_versions.mix(BWA_MEM_MT.out.versions.first())
}
Channel.empty()
.mix(ch_bwamem2_bam, ch_sentieon_bam, ch_bwa_bam)
ch_align
.join(ch_ubam, failOnMismatch:true, failOnDuplicate:true)
.set {ch_bam_ubam}

Expand Down
81 changes: 43 additions & 38 deletions subworkflows/local/call_snv.nf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ workflow CALL_SNV {
ch_deepvar_tbi = Channel.empty()
ch_deepvar_gvcf = Channel.empty()
ch_deepvar_gtbi = Channel.empty()
ch_mt_vcf = Channel.empty()
ch_mt_tabix = Channel.empty()
ch_sentieon_vcf = Channel.empty()
ch_sentieon_tbi = Channel.empty()
ch_sentieon_gvcf = Channel.empty()
Expand Down Expand Up @@ -93,46 +95,49 @@ workflow CALL_SNV {
ch_genome_tabix = GATK4_SELECTVARIANTS.out.tbi
ch_genome_vcf_tabix = ch_genome_vcf.join(ch_genome_tabix, failOnMismatch:true, failOnDuplicate:true)

CALL_SNV_MT(
ch_mt_bam_bai,
ch_genome_fasta,
ch_genome_fai,
ch_genome_dictionary,
ch_mt_intervals
)

CALL_SNV_MT_SHIFT(
ch_mtshift_bam_bai,
ch_mtshift_fasta,
ch_mtshift_fai,
ch_mtshift_dictionary,
ch_mtshift_intervals
)
if (params.analysis_type.equals("wgs") || params.run_mt_for_wes) {
CALL_SNV_MT(
ch_mt_bam_bai,
ch_genome_fasta,
ch_genome_fai,
ch_genome_dictionary,
ch_mt_intervals
)

POSTPROCESS_MT_CALLS(
CALL_SNV_MT.out.vcf,
CALL_SNV_MT_SHIFT.out.vcf,
ch_genome_fasta,
ch_genome_dictionary,
ch_genome_fai,
ch_mtshift_backchain,
ch_case_info,
ch_foundin_header,
ch_genome_chrsizes
)
CALL_SNV_MT_SHIFT(
ch_mtshift_bam_bai,
ch_mtshift_fasta,
ch_mtshift_fai,
ch_mtshift_dictionary,
ch_mtshift_intervals
)

ch_versions = ch_versions.mix(CALL_SNV_MT.out.versions)
ch_versions = ch_versions.mix(CALL_SNV_MT_SHIFT.out.versions)
ch_versions = ch_versions.mix(POSTPROCESS_MT_CALLS.out.versions)
ch_versions = ch_versions.mix(GATK4_SELECTVARIANTS.out.versions)
POSTPROCESS_MT_CALLS(
CALL_SNV_MT.out.vcf,
CALL_SNV_MT_SHIFT.out.vcf,
ch_genome_fasta,
ch_genome_dictionary,
ch_genome_fai,
ch_mtshift_backchain,
ch_case_info,
ch_foundin_header,
ch_genome_chrsizes
)
ch_mt_vcf = POSTPROCESS_MT_CALLS.out.vcf
ch_mt_tabix = POSTPROCESS_MT_CALLS.out.tbi
ch_versions = ch_versions.mix(CALL_SNV_MT.out.versions)
ch_versions = ch_versions.mix(CALL_SNV_MT_SHIFT.out.versions)
ch_versions = ch_versions.mix(POSTPROCESS_MT_CALLS.out.versions)
ch_versions = ch_versions.mix(GATK4_SELECTVARIANTS.out.versions)
}

emit:
genome_vcf = ch_genome_vcf // channel: [ val(meta), path(vcf) ]
genome_tabix = ch_genome_tabix // channel: [ val(meta), path(tbi) ]
genome_vcf_tabix = ch_genome_vcf_tabix // channel: [ val(meta), path(vcf), path(tbi) ]
genome_gvcf = ch_gvcf // channel: [ val(meta), path(gvcf) ]
genome_gtabix = ch_gtabix // channel: [ val(meta), path(gtbi) ]
mt_vcf = POSTPROCESS_MT_CALLS.out.vcf // channel: [ val(meta), path(vcf) ]
mt_tabix = POSTPROCESS_MT_CALLS.out.tbi // channel: [ val(meta), path(tbi) ]
versions = ch_versions // channel: [ path(versions.yml) ]
genome_vcf = ch_genome_vcf // channel: [ val(meta), path(vcf) ]
genome_tabix = ch_genome_tabix // channel: [ val(meta), path(tbi) ]
genome_vcf_tabix = ch_genome_vcf_tabix // channel: [ val(meta), path(vcf), path(tbi) ]
genome_gvcf = ch_gvcf // channel: [ val(meta), path(gvcf) ]
genome_gtabix = ch_gtabix // channel: [ val(meta), path(gtbi) ]
mt_vcf = ch_mt_vcf // channel: [ val(meta), path(vcf) ]
mt_tabix = ch_mt_tabix // channel: [ val(meta), path(tbi) ]
versions = ch_versions // channel: [ path(versions.yml) ]
}
Loading

0 comments on commit 6521bba

Please sign in to comment.