Skip to content

Commit

Permalink
Merge pull request #864 from maxulysse/dev_ultima
Browse files Browse the repository at this point in the history
add realigned bam export possibilities to gatk4_haplotypecaller
  • Loading branch information
maxulysse authored Nov 24, 2022
2 parents 6c262b0 + 16ac8f6 commit 36bb01d
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- [#864](https://github.com/nf-core/sarek/pull/864) - Added possibilities to export assembled haplotypes and locally realigned reads

### Changed

- [#859](https://github.com/nf-core/sarek/pull/859) - Back to dev
Expand Down
12 changes: 12 additions & 0 deletions conf/modules/haplotypecaller.config
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,16 @@ process {
pattern: "*{vcf.gz,vcf.gz.tbi}"
]
}

if (!(params.tools && params.tools.split(',').contains('haplotypecaller'))) {
withName: 'NFCORE_SAREK:SAREK:BAM_VARIANT_CALLING_GERMLINE_ALL:BAM_VARIANT_CALLING_HAPLOTYPECALLER:BAM_MERGE_INDEX_SAMTOOLS:(MERGE_BAM|INDEX_MERGE_BAM)' {
ext.prefix = { "${meta.id}.realigned" }
publishDir = [
enabled: true,
mode: params.publish_dir_mode,
path: { "${params.outdir}/variant_calling/haplotypecaller/${meta.id}/" },
pattern: "*{bam,bai}"
]
}
}
}
5 changes: 3 additions & 2 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
},
"bcftools/mpileup": {
"branch": "master",
"git_sha": "6301e29d77e7ec7ce98b55b8a361b316a9a91bfe"
"git_sha": "6301e29d77e7ec7ce98b55b8a361b316a9a91bfe",
"installed_by": ["modules"]
},
"bcftools/sort": {
"branch": "master",
Expand Down Expand Up @@ -233,7 +234,7 @@
},
"gatk4/haplotypecaller": {
"branch": "master",
"git_sha": "7578005a576f3ac1b0d4f10c037dde34cdedfb67",
"git_sha": "9e9cd1dc1865ee28514c6435e02f1618c091ae20",
"installed_by": ["modules"]
},
"gatk4/intervallisttobed": {
Expand Down
9 changes: 6 additions & 3 deletions modules/nf-core/gatk4/haplotypecaller/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions modules/nf-core/gatk4/haplotypecaller/meta.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions subworkflows/local/bam_variant_calling_haplotypecaller/main.nf
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include { GATK4_MERGEVCFS as MERGE_HAPLOTYPECALLER } from '../../../modules/nf-core/gatk4/mergevcfs/main'
include { GATK4_HAPLOTYPECALLER } from '../../../modules/nf-core/gatk4/haplotypecaller/main'
include { BAM_JOINT_CALLING_GERMLINE_GATK } from '../bam_joint_calling_germline_gatk/main'
include { BAM_MERGE_INDEX_SAMTOOLS } from '../bam_merge_index_samtools/main'
include { VCF_VARIANT_FILTERING_GATK } from '../vcf_variant_filtering_gatk/main'
include { GATK4_HAPLOTYPECALLER } from '../../../modules/nf-core/gatk4/haplotypecaller/main'
include { GATK4_MERGEVCFS as MERGE_HAPLOTYPECALLER } from '../../../modules/nf-core/gatk4/mergevcfs/main'

workflow BAM_VARIANT_CALLING_HAPLOTYPECALLER {
take:
Expand All @@ -22,6 +23,7 @@ workflow BAM_VARIANT_CALLING_HAPLOTYPECALLER {

ch_versions = Channel.empty()
filtered_vcf = Channel.empty()
realigned_bam = Channel.empty()

GATK4_HAPLOTYPECALLER(
cram,
Expand All @@ -42,6 +44,11 @@ workflow BAM_VARIANT_CALLING_HAPLOTYPECALLER {
no_intervals: it[0].num_intervals <= 1
}.set{haplotypecaller_tbi_branch}

GATK4_HAPLOTYPECALLER.out.bam.branch{
intervals: it[0].num_intervals > 1
no_intervals: it[0].num_intervals <= 1
}.set{haplotypecaller_bam_branch}

if (params.joint_germline) {
// merge vcf and tbis
genotype_gvcf_to_call = Channel.empty().mix(GATK4_HAPLOTYPECALLER.out.vcf
Expand Down Expand Up @@ -100,6 +107,25 @@ workflow BAM_VARIANT_CALLING_HAPLOTYPECALLER {
MERGE_HAPLOTYPECALLER.out.tbi,
haplotypecaller_tbi_branch.no_intervals)

// BAM output
BAM_MERGE_INDEX_SAMTOOLS(
haplotypecaller_bam_branch.intervals
.map{ meta, bam ->

new_meta = [
id: meta.sample,
num_intervals: meta.num_intervals,
patient: meta.patient,
sample: meta.sample,
sex: meta.sex,
status: meta.status
]

[groupKey(new_meta, new_meta.num_intervals), bam]
}.groupTuple().mix(haplotypecaller_bam_branch.no_intervals))

realigned_bam = BAM_MERGE_INDEX_SAMTOOLS.out.bam_bai

VCF_VARIANT_FILTERING_GATK(haplotypecaller_vcf.join(haplotypecaller_tbi),
fasta,
fasta_fai,
Expand All @@ -117,4 +143,5 @@ workflow BAM_VARIANT_CALLING_HAPLOTYPECALLER {
emit:
versions = ch_versions
filtered_vcf
realigned_bam
}
3 changes: 3 additions & 0 deletions tests/config/pytest_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ haplotypecaller:
- modules/nf-core/gatk4/haplotypecaller/main.nf
- modules/nf-core/gatk4/mergevcfs/main.nf
- modules/nf-core/gatk4/variantrecalibrator/main.nf
- modules/nf-core/samtools/index/main.nf
- modules/nf-core/samtools/merge/main.nf
- modules/nf-core/tabix/tabix/main.nf
- subworkflows/local/bam_joint_calling_germline_gatk/main.nf
- subworkflows/local/bam_merge_index_samtools/main.nf
- subworkflows/local/bam_variant_calling_haplotypecaller/main.nf
- subworkflows/local/vcf_variant_filtering_gatk/main.nf

Expand Down

0 comments on commit 36bb01d

Please sign in to comment.