Skip to content

Commit

Permalink
Merge pull request #251 from replikation/feature_param-artic-normalize
Browse files Browse the repository at this point in the history
[Feature] added parameter artic_normalize
  • Loading branch information
replikation authored Aug 3, 2023
2 parents 19b87bf + 0854b0e commit aa993eb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 2 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ params {
list = false
samples = false

artic_normalize = 500

// consensus qc
reference_for_qc = ''
seq_threshold = '0.90'
Expand Down
11 changes: 7 additions & 4 deletions poreCov.nf
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ workflow {

// use medaka or nanopolish artic reconstruction
if (params.nanopolish) {
artic_ncov_np_wf(filtered_reads_ch, dir_input_ch, basecalling_wf.out[1])
artic_ncov_np_wf(filtered_reads_ch, dir_input_ch, basecalling_wf.out[1], artic_ncov_np_wf)
fasta_input_ch = artic_ncov_np_wf.out[0]
}
else if (!params.nanopolish) {
artic_ncov_wf(filtered_reads_ch)
artic_ncov_wf(filtered_reads_ch, params.artic_normalize)
fasta_input_ch = artic_ncov_wf.out[0]
}
}
Expand Down Expand Up @@ -379,11 +379,11 @@ workflow {

external_primer_schemes = Channel.fromPath(workflow.projectDir + "/data/external_primer_schemes", checkIfExists: true, type: 'dir' )

artic_ncov_np_wf(filtered_reads_ch, dir_input_ch, sequence_summary_ch )
artic_ncov_np_wf(filtered_reads_ch, dir_input_ch, sequence_summary_ch, artic_ncov_np_wf)
fasta_input_ch = artic_ncov_np_wf.out
}
else if (!params.nanopolish) {
artic_ncov_wf(filtered_reads_ch)
artic_ncov_wf(filtered_reads_ch, params.artic_normalize)
fasta_input_ch = artic_ncov_wf.out
}
}
Expand Down Expand Up @@ -466,6 +466,9 @@ ${c_yellow}Inputs (choose one):${c_reset}
${c_dim}[Lineage + Reports]${c_reset}
${c_yellow}Workflow control (optional)${c_reset}
--artic_normalize Normalise down to moderate coverage to save runtime [default: $params.artic_normalize]
${c_dim}(after mapping and before variant calling in the ARTIC bioinformatics pipeline)
Use `--artic_normalize False` to turn off this normalisation.${c_reset}
--update Always try to use latest pangolin & nextclade release [default: $params.update]
--samples .csv input (header: Status,_id), renames barcodes (Status) by name (_id), e.g.:
Status,_id
Expand Down
12 changes: 8 additions & 4 deletions workflows/artic_nanopore_nCov19.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ include { covarplot; covarplot_custom_bed } from './process/covarplot.nf'
workflow artic_ncov_wf {
take:
fastq
normalise_threshold
main:

// assembly with a primer bed file
if (params.primerV.toString().contains(".bed")) {
primerBed = Channel.fromPath(params.primerV, checkIfExists: true )
external_primer_schemes = Channel.fromPath(workflow.projectDir + "/data/external_primer_schemes", checkIfExists: true, type: 'dir' )

artic_medaka_custom_bed(fastq.combine(external_primer_schemes).combine(primerBed))
artic_medaka_custom_bed(fastq.combine(external_primer_schemes).combine(primerBed), normalise_threshold)
assembly = artic_medaka_custom_bed.out.fasta

// plot amplicon coverage
Expand All @@ -22,7 +23,7 @@ workflow artic_ncov_wf {
else {
external_primer_schemes = Channel.fromPath(workflow.projectDir + "/data/external_primer_schemes", checkIfExists: true, type: 'dir' )

artic_medaka(fastq.combine(external_primer_schemes))
artic_medaka(fastq.combine(external_primer_schemes), normalise_threshold)
assembly = artic_medaka.out.fasta

// plot amplicon coverage
Expand All @@ -42,6 +43,7 @@ workflow artic_ncov_np_wf {
fastq
fast5
sequence_summaries
normalise_threshold
main:

// assembly
Expand All @@ -55,7 +57,8 @@ workflow artic_ncov_np_wf {
.combine(fast5.map{it -> it[1]})
.combine(sequence_summaries)
.combine(primerBed)
.map{it -> tuple(it[0],it[1],it[2],it[3],it[5],it[6])}
.map{it -> tuple(it[0],it[1],it[2],it[3],it[5],it[6])},
normalise_threshold
)

assembly = artic_nanopolish_custom_bed.out.fasta
Expand All @@ -73,7 +76,8 @@ workflow artic_ncov_np_wf {
.combine(external_primer_schemes)
.combine(fast5.map{it -> it[1]})
.combine(sequence_summaries)
.map{it -> tuple(it[0],it[1],it[2],it[3],it[5])}
.map{it -> tuple(it[0],it[1],it[2],it[3],it[5])},
normalise_threshold
)

assembly = artic_nanopolish.out.fasta
Expand Down
18 changes: 14 additions & 4 deletions workflows/process/artic.nf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ process artic_medaka {

input:
tuple val(name), path(reads), path(external_scheme)
val(normalise_threshold)
output:
tuple val(name), path("*.consensus.fasta"), emit: fasta
tuple val(name), path("${name}_mapped_*.primertrimmed.sorted.bam"), path("${name}_mapped_*.primertrimmed.sorted.bam.bai"), emit: reference_bam
Expand All @@ -22,11 +23,12 @@ process artic_medaka {
tuple val(name), path("${name}.fail.vcf"), emit: vcf_fail

script:
def normalise_arg = normalise_threshold ? "--normalise ${normalise_threshold}" : ''
"""
artic minion --medaka \
--medaka-model ${params.medaka_model} \
--min-depth ${params.min_depth} \
--normalise 500 \
${normalise_arg} \
--threads ${task.cpus} \
--scheme-directory ${external_scheme} \
--read-file ${reads} \
Expand Down Expand Up @@ -76,6 +78,7 @@ process artic_medaka_custom_bed {

input:
tuple val(name), path(reads), path(external_scheme), path(primerBed)
val(normalize_threshold)
output:
tuple val(name), path("*.consensus.fasta"), emit: fasta
tuple val(name), path("${name}_mapped_*.primertrimmed.sorted.bam"), path("${name}_mapped_*.primertrimmed.sorted.bam.bai"), emit: reference_bam
Expand All @@ -86,6 +89,7 @@ process artic_medaka_custom_bed {
tuple val(name), path("${name}.coverage_mask.txt"), emit: coverage_mask
tuple val(name), path("${name}.fail.vcf"), emit: vcf_fail
script:
def normalise_arg = normalise_threshold ? "--normalise ${normalise_threshold}" : ''
"""
# create a new primer dir as input for artic
mkdir -p primer_scheme/nCoV-2019
Expand All @@ -101,7 +105,7 @@ process artic_medaka_custom_bed {
artic minion --medaka \
--medaka-model ${params.medaka_model} \
--min-depth ${params.min_depth} \
--normalise 500 \
${normalise_arg} \
--threads ${task.cpus} \
--scheme-directory primer_scheme \
--read-file ${reads} \
Expand Down Expand Up @@ -152,6 +156,7 @@ process artic_nanopolish {

input:
tuple val(name), path(reads), path(external_scheme), path(fast5_dir), path(txt_files)
val(normalise_threshold)
output:
tuple val(name), path("*.consensus.fasta"), emit: fasta
tuple val(name), path("${name}_mapped_*.primertrimmed.sorted.bam"), path("${name}_mapped_*.primertrimmed.sorted.bam.bai"), emit: reference_bam
Expand All @@ -162,8 +167,10 @@ process artic_nanopolish {
tuple val(name), path("${name}.coverage_mask.txt"), emit: coverage_mask
tuple val(name), path("${name}.fail.vcf"), emit: vcf_fail
script:
def normalise_arg = normalise_threshold ? "--normalise ${normalise_threshold}" : ''
"""
artic minion --minimap2 --normalise 500 \
artic minion --minimap2 \
${normalise_arg} \
--threads ${task.cpus} \
--scheme-directory ${external_scheme} \
--read-file ${reads} \
Expand Down Expand Up @@ -216,6 +223,7 @@ process artic_nanopolish_custom_bed {

input:
tuple val(name), path(reads), path(external_scheme), path(fast5_dir), path(txt_files), path(primerBed)
val(normalise_threshold)
output:
tuple val(name), path("*.consensus.fasta"), emit: fasta
tuple val(name), path("${name}_mapped_*.primertrimmed.sorted.bam"), path("${name}_mapped_*.primertrimmed.sorted.bam.bai"), emit: reference_bam
Expand All @@ -226,6 +234,7 @@ process artic_nanopolish_custom_bed {
tuple val(name), path("${name}.coverage_mask.txt"), emit: coverage_mask
tuple val(name), path("${name}.fail.vcf"), emit: vcf_fail
script:
def normalise_arg = normalise_threshold ? "--normalise ${normalise_threshold}" : ''
"""
# create a new primer dir as input for artic
mkdir -p primer_scheme/nCoV-2019
Expand All @@ -238,7 +247,8 @@ process artic_nanopolish_custom_bed {
sort -k4 > primer_scheme/nCoV-2019/V_custom/nCoV-2019.scheme.bed
# start artic
artic minion --minimap2 --normalise 500 \
artic minion --minimap2 \
${normalise_arg} \
--threads ${task.cpus} \
--scheme-directory primer_scheme \
--read-file ${reads} \
Expand Down

0 comments on commit aa993eb

Please sign in to comment.