Skip to content

Commit

Permalink
Starting on bcftools caller
Browse files Browse the repository at this point in the history
  • Loading branch information
Joon-Klaps committed Aug 21, 2023
1 parent 64e089e commit 80ac911
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
16 changes: 6 additions & 10 deletions subworkflows/local/bam_call_variants.nf
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// TODO nf-core: If in doubt look at other nf-core/subworkflows to see how we are doing things! :)
// https://github.com/nf-core/modules/tree/master/subworkflows
// You can also ask for help via your pull request or on the #subworkflows channel on the nf-core Slack workspace:
// https://nf-co.re/join
// TODO nf-core: A subworkflow SHOULD import at least two modules

include { SAMTOOLS_SORT } from '../../../modules/nf-core/samtools/sort/main'
include { SAMTOOLS_INDEX } from '../../../modules/nf-core/samtools/index/main'
include { TABIX_TABIX } from '../../modules/nf-core/tabix/tabix/main'
include { BCFTOOLS_STATS } from '../../modules/nf-core/bcftools/stats/main'

workflow {

take:
// TODO nf-core: edit input (take) channels
ch_bam // channel: [ val(meta), [ bam ] ]
bam // channel: [ val(meta), [ bam ] ]
fasta // channel: [val (meta), [ fasta] ]
variant_caller // value: [ bcftools | ivar ]


main:

Expand Down
53 changes: 44 additions & 9 deletions subworkflows/local/bam_variants_bcftools.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
// TODO nf-core: If in doubt look at other nf-core/subworkflows to see how we are doing things! :)
// https://github.com/nf-core/modules/tree/master/subworkflows
// You can also ask for help via your pull request or on the #subworkflows channel on the nf-core Slack workspace:
// https://nf-co.re/join
// TODO nf-core: A subworkflow SHOULD import at least two modules

include { SAMTOOLS_SORT } from '../../../modules/nf-core/samtools/sort/main'
include { SAMTOOLS_INDEX } from '../../../modules/nf-core/samtools/index/main'
include { BCFTOOLS_MPILEUP } from '../../modules/nf-core/bcftools/mpileup/main'
include { BCFTOOLS_NORM } from '../../modules/nf-core/bcftools/norm/main'

workflow {

Expand All @@ -14,9 +8,50 @@ workflow {
ch_bam // channel: [ val(meta), [ bam ] ]

main:

ch_versions = Channel.empty()

//
// Call variants
//
BCFTOOLS_MPILEUP (
bam.map{ meta, bam_file -> [ meta, bam_file, [] ] },
fasta,
params.save_mpileup
)
ch_versions = ch_versions.mix(BCFTOOLS_MPILEUP.out.versions.first())

// Filter out samples with 0 variants
BCFTOOLS_MPILEUP
.out
.vcf
.join(BCFTOOLS_MPILEUP.out.tbi)
.join(BCFTOOLS_MPILEUP.out.stats)
.filter { meta, vcf, tbi, stats -> WorkflowCommons.getNumVariantsFromBCFToolsStats(stats) > 0 }
.set { ch_vcf_tbi_stats }

ch_vcf_tbi_stats
.map { meta, vcf, tbi, stats -> [ meta, vcf ] }
.set { ch_vcf }

ch_vcf_tbi_stats
.map { meta, vcf, tbi, stats -> [ meta, tbi ] }
.set { ch_tbi }

ch_vcf_tbi_stats
.map { meta, vcf, tbi, stats -> [ meta, stats ] }
.set { ch_stats }

//
// Split multi-allelic positions
//
BCFTOOLS_NORM (
ch_vcf.join(ch_tbi, by: [0]),
fasta
)
ch_versions = ch_versions.mix(BCFTOOLS_NORM.out.versions.first())


// TODO nf-core: substitute modules here for the modules of your subworkflow

SAMTOOLS_SORT ( ch_bam )
Expand Down

0 comments on commit 80ac911

Please sign in to comment.