Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] added parameter artic_normalize #251

Merged
merged 7 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -8,18 +8,20 @@ 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
tuple val(name), path("SNP_${name}.pass.vcf"), emit: vcf
tuple val(name), path("${name}.pass.vcf.gz"), path("${name}.coverage_mask.txt.*1.depths"), path("${name}.coverage_mask.txt.*2.depths"), emit: covarplot
tuple val(name), path("${name}.trimmed.rg.sorted.bam"), emit: fullbam
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 @@ -63,13 +65,15 @@ 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
tuple val(name), path("SNP_${name}.pass.vcf"), emit: vcf
tuple val(name), path("${name}.pass.vcf.gz"), path("${name}.coverage_mask.txt.*1.depths"), path("${name}.coverage_mask.txt.*2.depths"), emit: covarplot
tuple val(name), path("${name}.trimmed.rg.sorted.bam"), emit: fullbam
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 @@ -85,7 +89,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 @@ -130,15 +134,18 @@ 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
tuple val(name), path("SNP_${name}.pass.vcf"), emit: vcf
tuple val(name), path("${name}.pass.vcf.gz"), path("${name}.coverage_mask.txt.*1.depths"), path("${name}.coverage_mask.txt.*2.depths"), emit: covarplot
tuple val(name), path("${name}.trimmed.rg.sorted.bam"), emit: fullbam
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 @@ -185,13 +192,15 @@ 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
tuple val(name), path("SNP_${name}.pass.vcf"), emit: vcf
tuple val(name), path("${name}.pass.vcf.gz"), path("${name}.coverage_mask.txt.*1.depths"), path("${name}.coverage_mask.txt.*2.depths"), emit: covarplot
tuple val(name), path("${name}.trimmed.rg.sorted.bam"), emit: fullbam
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 @@ -204,7 +213,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