Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
826fcda
Remove BAM_TUMOR_ONLY_SOMATIC_VARIANT_CALLING_GATK.
beatrizsavinhas Oct 16, 2026
9fc036e
Merge logic until GATK4_GETPILEUPSUMMARIES.
beatrizsavinhas Oct 16, 2026
a1ec7a3
refactor using val_tumor_normal_analysis
beatrizsavinhas Oct 19, 2026
16e173f
Fix channel manipulation and ensure case_id meta.
beatrizsavinhas Oct 20, 2026
4eb6294
Add val_case_id.
beatrizsavinhas Oct 20, 2026
844e870
Add val_case_id.
beatrizsavinhas Oct 20, 2026
c0c19df
Re-add pileup output to test snapshot.
beatrizsavinhas Oct 20, 2026
ac3c66d
Restore config to ensure generation of f1r2 file.
beatrizsavinhas Oct 20, 2026
77b171e
Code formatting.
beatrizsavinhas Oct 21, 2026
d105449
Adjustments for tumor only mode.
beatrizsavinhas Oct 21, 2026
0c30792
Remove val_case_id.
beatrizsavinhas Oct 21, 2026
b2a414c
Fix code comments.
beatrizsavinhas Oct 21, 2026
f46df8b
Activate all tests and update snapshot.
beatrizsavinhas Oct 21, 2026
d1f9ba8
Remove logic for pileup_table_normal from emit block.
beatrizsavinhas Oct 21, 2026
f3ecfe3
Remove code duplication in output channels.
beatrizsavinhas Oct 21, 2026
63f5038
Update code comment.
beatrizsavinhas Oct 21, 2026
6b611f8
Update meta.
beatrizsavinhas Oct 21, 2026
97d7543
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 21, 2026
c370a53
Rename folder.
beatrizsavinhas Oct 21, 2026
2efdf20
Fix linting issue in meta.
beatrizsavinhas Oct 21, 2026
ea4e199
Run prek.
beatrizsavinhas Oct 21, 2026
d61ce99
Add pon to TO test.
beatrizsavinhas Oct 21, 2026
feb020a
Remove case_id from test meta.
beatrizsavinhas Oct 21, 2026
b982828
Create params.ext_args_gatk4_mutect2
beatrizsavinhas Oct 21, 2026
035822a
Add params.ext_args_gatk4_mutect2 for TO test. Fix bug with ext_args_…
beatrizsavinhas Oct 21, 2026
ddd5c28
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 21, 2026
5dfaa76
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 22, 2026
f6f34ee
Update title comment.
beatrizsavinhas Oct 22, 2026
8000f49
Use joint input and remove val_tumor_normal_analysis.
beatrizsavinhas Oct 22, 2026
ac55eb7
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 22, 2026
b12965f
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 23, 2026
0838c54
Fix snapshot of pileup_table for TN test.
beatrizsavinhas Oct 23, 2026
b6e7ae7
Update meta.
beatrizsavinhas Oct 23, 2026
3fac4e1
Correct inputs for tumor only tests.
beatrizsavinhas Oct 23, 2026
a7148d0
Update TN test snapshot based on CI results.
beatrizsavinhas Oct 23, 2026
8b4d48a
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 23, 2026
ae1894d
Update TN test snapshot based on CI results.
beatrizsavinhas Oct 23, 2026
820a640
Remove negation in if logic.
beatrizsavinhas Oct 23, 2026
2de169d
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 26, 2026
c8a9b23
Apply suggestion from @imsarath
beatrizsavinhas Oct 26, 2026
2241298
Apply suggestion from @imsarath
beatrizsavinhas Oct 26, 2026
c1df60c
Restore config.
beatrizsavinhas Oct 26, 2026
e9d93b9
Add `sanitizeOutput` to stub tests.
beatrizsavinhas Oct 26, 2026
5085785
Deprecate BAM_TUMOR_NORMAL_SOMATIC_VARIANT_CALLING_GATK.
beatrizsavinhas Oct 26, 2026
c8784a9
Deprecate BAM_TUMOR_NORMAL_SOMATIC_VARIANT_CALLING_GATK.
beatrizsavinhas Oct 26, 2026
5308216
Deprecate BAM_TUMOR_ONLY_SOMATIC_VARIANT_CALLING_GATK.
beatrizsavinhas Oct 26, 2026
7010b29
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 26, 2026
3c66880
Remove assert workflow.success from deprecated subworkflow tests.
beatrizsavinhas Oct 26, 2026
6cdf452
Fix deprecation_message for BAM_TUMOR_ONLY_SOMATIC_VARIANT_CALLING_GATK.
beatrizsavinhas Oct 26, 2026
a4918ee
Add README for bam_tumor_only_somatic_variant_calling_gatk
beatrizsavinhas Oct 26, 2026
1238a97
Add README for bam_tumor_normal_somatic_variant_calling_gatk
beatrizsavinhas Oct 26, 2026
81a78e5
Restore BAM_TUMOR_ONLY_SOMATIC_VARIANT_CALLING_GATK and fix deprecation.
beatrizsavinhas Oct 26, 2026
5eadc6d
Restore BAM_TUMOR_NORMAL_SOMATIC_VARIANT_CALLING_GATK and fix depreca…
beatrizsavinhas Oct 26, 2026
a0e36ef
Restore meta.
beatrizsavinhas Oct 26, 2026
d331220
Restore files from bam_tumor_normal_somatic_variant_calling_gatk.
beatrizsavinhas Oct 29, 2026
d252106
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 29, 2026
ec90598
Update test config logic to support params.gatk4_mutect2_ext_args for…
beatrizsavinhas Oct 29, 2026
d2a47bb
Update snapshot after previous test config changes.
beatrizsavinhas Oct 29, 2026
f9af8d0
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 29, 2026
266d3c4
Update Tumor normal snapshot based on CI results.
beatrizsavinhas Oct 29, 2026
367c75c
Update Tumor normal snapshot based on CI results.
beatrizsavinhas Oct 29, 2026
85203e9
Revert "Update Tumor normal snapshot based on CI results."
beatrizsavinhas Oct 29, 2026
c0f017c
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 30, 2026
fe67962
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 30, 2026
fe00c95
Update grouping logic to ensure correct order of tables in ch_calcula…
beatrizsavinhas Oct 30, 2026
06aef0d
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Oct 30, 2026
302bbec
Improve meta manipulation code comment.
beatrizsavinhas Nov 2, 2026
7aeb29f
Improve meta manipulation code comment.
beatrizsavinhas Nov 2, 2026
3b6bff3
Merge branch 'master' into merge-bam-somatic-variant-calling-gatk
beatrizsavinhas Nov 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions subworkflows/nf-core/bam_somatic_variant_calling_gatk/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
// Run GATK4_MUTECT2 in tumor normal mode, getepileupsummaries, calculatecontamination, learnreadorientationmodel and filtermutectcalls
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved

include { GATK4_CALCULATECONTAMINATION } from '../../../modules/nf-core/gatk4/calculatecontamination'
include { GATK4_FILTERMUTECTCALLS } from '../../../modules/nf-core/gatk4/filtermutectcalls'
include { GATK4_GETPILEUPSUMMARIES as GATK4_GETPILEUPSUMMARIES_NORMAL } from '../../../modules/nf-core/gatk4/getpileupsummaries'
include { GATK4_GETPILEUPSUMMARIES as GATK4_GETPILEUPSUMMARIES_TUMOR } from '../../../modules/nf-core/gatk4/getpileupsummaries'
include { GATK4_LEARNREADORIENTATIONMODEL } from '../../../modules/nf-core/gatk4/learnreadorientationmodel'
include { GATK4_MUTECT2 } from '../../../modules/nf-core/gatk4/mutect2'

workflow BAM_SOMATIC_VARIANT_CALLING_GATK {
take:
ch_input_tumor // channel: [ val(meta), path(input), path(input_index)]
ch_input_normal // channel: [ val(meta), path(input), path(input_index)]
ch_fasta // channel: [ val(meta), path(fasta) ]
ch_fai // channel: [ val(meta), path(fai), path(gzi) ]
ch_dict // channel: [ val(meta), path(dict) ]
ch_alleles // channel: /path/to/alleles
ch_alleles_tbi // channel: /path/to/alleles/index
ch_germline_resource // channel: /path/to/germline/resource
ch_germline_resource_tbi // channel: /path/to/germline/index
ch_panel_of_normals // channel: /path/to/panel/of/normals
ch_panel_of_normals_tbi // channel: /path/to/panel/of/normals/index
ch_interval_file // channel: /path/to/interval/file
val_tumor_normal_analysis // boolean: if true, perform tumor-normal comparison, otherwise run tumor-only comparison with pon
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved

main:

if (val_tumor_normal_analysis) {

ch_mutect2_in = ch_input_tumor
.combine(ch_input_normal)
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved
.map { meta_tumor, bam_tumor, bai_tumor, meta_normal, bam_normal, bai_normal ->
[[id: "${meta_tumor.id}_${meta_normal.id}" ], [bam_tumor, bam_normal], [bai_tumor, bai_normal]]
}
.combine(ch_interval_file)
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved

// Ensure that the panel of normals is not used for tumor-normal analysis, even if provided
ch_panel_of_normals = []
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved
ch_panel_of_normals_tbi = []
}
else {
ch_mutect2_in = ch_input_tumor
.combine(ch_interval_file)
}

GATK4_MUTECT2(
ch_mutect2_in,
ch_fasta,
ch_fai,
ch_dict,
ch_alleles,
ch_alleles_tbi,
ch_germline_resource,
ch_germline_resource_tbi,
ch_panel_of_normals,
ch_panel_of_normals_tbi,
)

ch_mutect2_vcf = GATK4_MUTECT2.out.vcf
ch_mutect2_stats = GATK4_MUTECT2.out.stats
ch_mutect2_tbi = GATK4_MUTECT2.out.tbi
ch_mutect2_f1r2 = GATK4_MUTECT2.out.f1r2

// Generate artifactpriors using learnreadorientationmodel on the f1r2 output of GATK4_MUTECT2
GATK4_LEARNREADORIENTATIONMODEL(ch_mutect2_f1r2)


ch_artifact_priors = GATK4_LEARNREADORIENTATIONMODEL.out.artifactprior

// Generate pileup summary tables using getepileupsummaries
ch_getpileupsummaries_tumor_in = ch_input_tumor
.combine(ch_interval_file)

GATK4_GETPILEUPSUMMARIES_TUMOR(
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved
ch_getpileupsummaries_tumor_in,
ch_fasta,
ch_fai.map { meta, fai, _gzi -> [meta, fai] },
ch_dict,
ch_germline_resource,
ch_germline_resource_tbi,
)

ch_pileup_table_tumor = GATK4_GETPILEUPSUMMARIES_TUMOR.out.table

if (val_tumor_normal_analysis) {

ch_getpileupsummaries_normal_in = ch_input_normal
.combine(ch_interval_file)

GATK4_GETPILEUPSUMMARIES_NORMAL(
ch_getpileupsummaries_normal_in,
ch_fasta,
ch_fai.map { meta, fai, _gzi -> [meta, fai] },
ch_dict,
ch_germline_resource,
ch_germline_resource_tbi,
)

ch_pileup_table_normal = GATK4_GETPILEUPSUMMARIES_NORMAL.out.table

// Ensure the correct order of the files in the input channel for GATK4_CALCULATECONTAMINATION
ch_calccon_in = ch_pileup_table_tumor
.combine(ch_pileup_table_normal)
.map { meta_tumor, table_tumor, meta_normal, table_normal ->
[[id: "${meta_tumor.id}_${meta_normal.id}"], table_tumor, table_normal]
}
Comment on lines +95 to +113

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic could be improved and simplified! Any suggestions?

}
else {
ch_pileup_table_normal = channel.empty()

ch_calccon_in = ch_pileup_table_tumor
.map { meta_tumor, table_tumor ->
[meta_tumor, table_tumor, []]
}
}

// Contamination and segmentation tables created using calculatecontamination on the pileup summary table
GATK4_CALCULATECONTAMINATION(ch_calccon_in)

ch_contamination_table = GATK4_CALCULATECONTAMINATION.out.contamination
ch_segmentation_table = GATK4_CALCULATECONTAMINATION.out.segmentation

// GATK4_MUTECT2 calls filtered by filtermutectcalls using the artifactpriors, contamination and segmentation tables
ch_filtermutect_in = ch_mutect2_vcf
.join(ch_mutect2_tbi, failOnDuplicate: true, failOnMismatch: true)
.join(ch_mutect2_stats, failOnDuplicate: true, failOnMismatch: true)
.join(ch_artifact_priors, failOnDuplicate: true, failOnMismatch: true)
.join(ch_segmentation_table, failOnDuplicate: true, failOnMismatch: true)
.join(ch_contamination_table, failOnDuplicate: true, failOnMismatch: true)
.map{ meta, vcf, tbi, stats, artifactprior, segmentation, contamination ->
[
meta,
vcf,
tbi,
stats,
artifactprior,
segmentation,
contamination,
[], // Since the contamination table is provided, the value estimate is not relevant
]
}

GATK4_FILTERMUTECTCALLS(
ch_filtermutect_in,
ch_fasta,
ch_fai.map { meta, fai, _gzi -> [meta, fai] },
ch_dict,
)

emit:
artifact_priors = ch_artifact_priors // channel: [ val(meta), path(artifactprior) ]
contamination_table = ch_contamination_table // channel: [ val(meta), path(table) ]
filtered_stats = GATK4_FILTERMUTECTCALLS.out.stats // channel: [ val(meta), path(stats) ]
filtered_tbi = GATK4_FILTERMUTECTCALLS.out.tbi // channel: [ val(meta), path(tbi) ]
filtered_vcf = GATK4_FILTERMUTECTCALLS.out.vcf // channel: [ val(meta), path(vcf) ]
mutect2_f1r2 = ch_mutect2_f1r2 // channel: [ val(meta), path(f1r2) ]
mutect2_stats = ch_mutect2_stats // channel: [ val(meta), path(stats) ]
mutect2_tbi = ch_mutect2_tbi // channel: [ val(meta), path(tbi) ]
mutect2_vcf = ch_mutect2_vcf // channel: [ val(meta), path(vcf) ]
pileup_table_normal = ch_pileup_table_normal // channel: [ val(meta), path(table) ]
pileup_table_tumor = ch_pileup_table_tumor // channel: [ val(meta), path(table) ]
segmentation_table = ch_segmentation_table // channel: [ val(meta), path(table) ]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: bam_tumor_normal_somatic_variant_calling_gatk
name: bam_somatic_variant_calling_gatk
description: |
Perform variant calling on a paired tumor normal set of samples using mutect2 tumor normal mode.
f1r2 output of mutect2 is run through learnreadorientationmodel to get the artifact priors.
Expand All @@ -22,12 +22,16 @@ components:
- gatk4/calculatecontamination
- gatk4/filtermutectcalls
input:
- ch_input:
- ch_input_tumor:
description: |
The tumor and normal BAM files, in that order, also able to take CRAM as an input
Can contain an optional list of sample headers contained in the normal sample input file.
The tumor BAM or CRAM file and corresponding index file.

Structure: [ val(meta), path(input), path(input_index), val(which_norm) ]
Structure: [ val(meta), path(input), path(input_index) ]
- ch_input_normal:
description: |
The normal BAM or CRAM file and corresponding index file.

Structure: [ val(meta), path(input), path(input_index) ]
Comment thread
beatrizsavinhas marked this conversation as resolved.
Resolved
- ch_fasta:
description: |
The reference fasta file
Expand Down Expand Up @@ -65,19 +69,25 @@ input:
Structure: [ path(germline_resources_tbi) ]
- ch_panel_of_normals:
description: |
Vcf file to be used as a panel of normals.
Vcf file to be used as a panel of normals. Only used for tumor-only analysis.

Structure: [ path(panel_of_normals) ]
- ch_panel_of_normals_tbi:
description: |
Index for the panel of normals.
Index for the panel of normals. Only used for tumor-only analysis.

Structure: [ path(panel_of_normals_tbi) ]
- ch_interval_file:
description: |
File containing intervals.

Structure: [ path(interval_files) ]
- val_tumor_normal_analysis:
description: |
Boolean flag indicating if tumor-normal comparison should be performed.
If true, the workflow will perform a tumor-normal comparison. If false, it will run a tumor-only analysis using the panel of normals.

Structure: [ val(meta), val(tumor_normal_analysis) ]
output:
- artifact_priors:
description: |
Expand Down Expand Up @@ -126,7 +136,7 @@ output:
Structure: [ val(meta), path(vcf) ]
- pileup_table_normal:
description: |
File containing the normal pileup summary table, kept separate as calculatecontamination needs them individually specified.
File containing the normal pileup summary table, kept separate as calculatecontamination needs them individually specified. Only output in tumor-normal analysis.

Structure: [ val(meta), path(table) ]
- pileup_table_tumor:
Expand Down
Loading
Loading