From 8dfd971f6983a10e066282719e0d5be6dfac2176 Mon Sep 17 00:00:00 2001 From: Dan Fornika Date: Fri, 30 Aug 2024 17:10:02 -0700 Subject: [PATCH] Add support for aligning untrimmed reads (#31) --- main.nf | 28 ++++++++++++++++++++-------- modules/short_read_qc.nf | 2 +- nextflow.config | 3 ++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/main.nf b/main.nf index 0fd16de..159d4e5 100644 --- a/main.nf +++ b/main.nf @@ -66,6 +66,12 @@ workflow { fastp(ch_illumina_fastq) + if (! params.align_untrimmed_reads) { + ch_illumina_reads_to_align = fastp.out.trimmed_reads + } else { + ch_illumina_reads_to_align = ch_illumina_fastq + } + nanoq_pre_filter(ch_nanopore_fastq.combine(Channel.of("pre_filter"))) filtlong(ch_nanopore_fastq) @@ -74,11 +80,17 @@ workflow { merge_nanoq_reports(nanoq_pre_filter.out.report.join(nanoq_post_filter.out.report)) - bwa_mem(fastp.out.reads.join(ch_indexed_ref)) + if (! params.align_unfiltered_reads) { + ch_nanopore_reads_to_align = filtlong.out.filtered_reads + } else { + ch_nanopore_reads_to_align = ch_nanopore_fastq + } + + bwa_mem(ch_illumina_reads_to_align.join(ch_indexed_ref)) ch_bwa_alignment = bwa_mem.out.alignment - minimap2(ch_nanopore_fastq.join(ch_indexed_ref)) + minimap2(ch_nanopore_reads_to_align.join(ch_indexed_ref)) ch_minimap2_alignment = minimap2.out.alignment @@ -137,8 +149,8 @@ workflow { // ...and then concatenate them all together in the 'collect_provenance' process. ch_provenance = ch_provenance.combine(ch_pipeline_provenance).map{ it -> [it[0], [it[1]]] } ch_provenance = ch_provenance.join(hash_ref.out.provenance).map{ it -> [it[0], it[1] << it[2]] } - ch_provenance = ch_provenance.join(hash_fastq_short.out.provenance).map{ it -> [it[0], it[1] << it[2]] } - ch_provenance = ch_provenance.join(fastp.out.provenance).map{ it -> [it[0], it[1] << it[2]] } + ch_provenance = ch_provenance.join(hash_fastq_short.out.provenance).map{ it -> [it[0], it[1] << it[2]] } + ch_provenance = ch_provenance.join(fastp.out.provenance).map{ it -> [it[0], it[1] << it[2]] } if (params.align_long_reads) { ch_provenance = ch_provenance.join(hash_fastq_long.out.provenance).map{ it -> [it[0], it[1] << it[2]] } } @@ -149,10 +161,10 @@ workflow { ch_provenance = ch_provenance.join(nanoq_post_filter.out.provenance).map{ it -> [it[0], it[1] << it[2]] } ch_provenance = ch_provenance.join(minimap2.out.provenance).map{ it -> [it[0], it[1] << it[2]] } } - ch_provenance = ch_provenance.join(qualimap_bamqc.out.provenance).map{ it -> [it[0], it[1] << it[2]] } - ch_provenance = ch_provenance.join(samtools_mpileup.out.provenance).map{ it -> [it[0], it[1] << it[2]] } - ch_provenance = ch_provenance.join(samtools_stats.out.provenance).map{ it -> [it[0], it[1] << it[2]] } - ch_provenance = ch_provenance.join(freebayes.out.provenance).map{ it -> [it[0], it[1] << it[2]] } + ch_provenance = ch_provenance.join(qualimap_bamqc.out.provenance).map{ it -> [it[0], it[1] << it[2]] } + ch_provenance = ch_provenance.join(samtools_mpileup.out.provenance).map{ it -> [it[0], it[1] << it[2]] } + ch_provenance = ch_provenance.join(samtools_stats.out.provenance).map{ it -> [it[0], it[1] << it[2]] } + ch_provenance = ch_provenance.join(freebayes.out.provenance).map{ it -> [it[0], it[1] << it[2]] } collect_provenance(ch_provenance) diff --git a/modules/short_read_qc.nf b/modules/short_read_qc.nf index 8ed1044..995e690 100644 --- a/modules/short_read_qc.nf +++ b/modules/short_read_qc.nf @@ -10,7 +10,7 @@ process fastp { output: tuple val(sample_id), path("${sample_id}_fastp.json"), emit: fastp_json tuple val(sample_id), path("${sample_id}_fastp.csv"), emit: fastp_csv - tuple val(sample_id), path("${sample_id}_trimmed_R1.fastq.gz"), path("${sample_id}_trimmed_R2.fastq.gz"), emit: reads + tuple val(sample_id), path("${sample_id}_trimmed_R1.fastq.gz"), path("${sample_id}_trimmed_R2.fastq.gz"), emit: trimmed_reads tuple val(sample_id), path("${sample_id}_fastp_provenance.yml"), emit: provenance script: diff --git a/nextflow.config b/nextflow.config index 1693045..d2ae197 100644 --- a/nextflow.config +++ b/nextflow.config @@ -4,7 +4,7 @@ manifest { description = 'Alignment and variant calling pipeline' mainScript = 'main.nf' nextflowVersion = '>=20.01.0' - version = '0.1.10' + version = '0.1.11' } params { @@ -33,6 +33,7 @@ params { coverage_plot_height_inches_per_chrom = 2 coverage_plot_window_size = 1000 qualimap_memory = '4G' + align_untrimmed_reads = false skip_alignment_cleaning = false align_long_reads = false ref = 'NO_FILE'