From d85f9c7011a2539dc07582c1642f4255a3724b7c Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 21 Apr 2022 13:16:23 +0200 Subject: [PATCH 01/18] add subworkflow bam_qc_picard --- subworkflows/nf-core/bam_qc_picard/main.nf | 43 +++++++++++++ subworkflows/nf-core/bam_qc_picard/meta.yml | 64 +++++++++++++++++++ .../nf-core/bam_qc_picard/main.nf | 21 ++++++ .../nf-core/bam_qc_picard/test.yml | 33 ++++++++++ 4 files changed, 161 insertions(+) create mode 100644 subworkflows/nf-core/bam_qc_picard/main.nf create mode 100644 subworkflows/nf-core/bam_qc_picard/meta.yml create mode 100644 tests/subworkflows/nf-core/bam_qc_picard/main.nf create mode 100644 tests/subworkflows/nf-core/bam_qc_picard/test.yml diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf new file mode 100644 index 00000000..31edb2c3 --- /dev/null +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -0,0 +1,43 @@ +// +// Run QC steps on BAM/CRAM files using Picard +// + +params.options = [:] + +include { PICARD_COLLECTMULTIPLEMETRICS } from '../../../modules/picardcollectmultiplemetrics/main' addParams( options: params.options ) +include { PICARD_COLLECTWGSMETRICS } from '../../../modules/picardcollectwgsmetrics/main' addParams( options: params.options ) +include { PICARD_COLLECTHSMETRICS } from '../../../modules/picardcollecthsmetrics/main' addParams( options: params.options ) + +workflow BAM_QC_PICARD { + take: + ch_bam_bai // channel: [ val(meta), [ bam ], [bai/csi] ] + ch_fasta // channel: [ fasta ] + ch_bait_interval // channel: [ bait_interval ] + ch_target_interval // channel: [ target_interval ] + + main: + ch_versions = Channel.empty() + + PICARD_COLLECTMULTIPLEMETRICS( ch_bam_bai, ch_fasta] ) + ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) + if (!ch_bait_interval.isEmpty() || !ch_target_interval.isEmpty()) { + if (ch_bait_interval.isEmpty()) { + throw new Error("Bait interval channel is empty") + } + if (ch_target_interval.isEmpty()) { + throw new Error("Target interval channel is empty") + } + PICARD_COLLECTHSMETRICS( ch_bam_bai, ch_fasta, ch_bait_interval, ch_target_interval ) + ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) + } else { + PICARD_COLLECTWGSMETRICS( ch_bam_bai, ch_fasta ) + ch_versions = ch_versions.mix(PICARD_COLLECTWGSMETRICS.out.versions.first()) + } + + emit: + hs_metrics = PICARD_COLLECTHSMETRICS.out.hs_metrics // channel: [ val(meta), [ hs_metrics ] ] + wgs_metrics = PICARD_COLLECTWGSMETRICS.out.metrics // channel: [ val(meta), [ wgs_metrics ] ] + multiple_metrics = PICARD_COLLECTMULTIPLEMETRICS.out.metrics // channel: [ val(meta), [ multiple_metrics ] ] + + versions = ch_versions // channel: [ versions.yml ] +} diff --git a/subworkflows/nf-core/bam_qc_picard/meta.yml b/subworkflows/nf-core/bam_qc_picard/meta.yml new file mode 100644 index 00000000..77104e82 --- /dev/null +++ b/subworkflows/nf-core/bam_qc_picard/meta.yml @@ -0,0 +1,64 @@ +name: bam_qc +description: Produces comprehensive statistics from BAM file +keywords: + - statistics + - counts + - hs_metrics + - wgs_metrics + - bam + - sam + - cram +modules: + - picard/collectmultiplemetrics + - picard/collectwgsmetrics + - picard/collecthsmetrics +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bam: + type: file + description: BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + - bai: + type: file + description: Index for BAM/CRAM/SAM file + pattern: "*.{bai,crai,sai}" + - fasta: + type: optional file + description: Reference file the CRAM was created with + pattern: "*.{fasta,fa}" + - bait_intervals: + type: optional file + description: An interval list file that contains the locations of the baits used. + pattern: "baits.interval_list" + - target_intervals: + type: optional file + description: An interval list file that contains the locations of the targets. + pattern: "targets.interval_list" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - hs_metrics: + type: file + description: Alignment metrics files generated by picard CollectHsMetrics + pattern: "*_collecthsmetrics.txt" + - wgs_metrics: + type: file + description: Alignment metrics files generated by picard CollectWgsMetrics + pattern: "*_{metrics}" + - multiple_metrics: + type: file + description: Alignment metrics files generated by picard CollectMultipleMetrics + pattern: "*_{metrics}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@matthdsm" diff --git a/tests/subworkflows/nf-core/bam_qc_picard/main.nf b/tests/subworkflows/nf-core/bam_qc_picard/main.nf new file mode 100644 index 00000000..d88f2bf9 --- /dev/null +++ b/tests/subworkflows/nf-core/bam_qc_picard/main.nf @@ -0,0 +1,21 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BAM_QC_PICARD } from '../../../../subworkflows/nf-core/bam_qc_picard/main' addParams([:]) + +workflow test_bam_qc_picard_wgs { + input = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_single_end_bam'], checkIfExists: true) + ] + + BAM_QC_PICARD ( input, [], [], [] ) +} + +workflow test_bam_qc_picard_targetted { + input = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + + BAM_QC_PICARD ( input, [], file(params.test_data['sarscov2']['genome']['baits_interval_list'], checkIfExists: true), file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) ) +} diff --git a/tests/subworkflows/nf-core/bam_qc_picard/test.yml b/tests/subworkflows/nf-core/bam_qc_picard/test.yml new file mode 100644 index 00000000..af98230d --- /dev/null +++ b/tests/subworkflows/nf-core/bam_qc_picard/test.yml @@ -0,0 +1,33 @@ +- name: bam qc picard wgs + command: nextflow run ./tests/subworkflows/nf-core/bam_qc_picard -entry test_bam_qc_picard_wgs -c tests/config/nextflow.config + tags: + - subworkflows + # - subworkflows/bam_qc_picard + # Modules + # - picard + # - picard/collectmultiplemetrics + # - picard/collectwgsmetrics + files: + - path: ./output/picard/test.CollectMultipleMetrics.alignment_summary_metrics + - path: ./output/picard/test.CollectMultipleMetrics.insert_size_metrics + - path: ./output/picard/test.CollectMultipleMetrics.base_distribution_by_cycle_metrics + - path: ./output/picard/test.CollectMultipleMetrics.quality_by_cycle_metrics + - path: ./output/picard/test.CollectMultipleMetrics.quality_distribution_metrics + - path: ./output/picard/test.CollectWgsMetrics.coverage_metrics + +- name: bam qc picard targetted + command: nextflow run ./tests/subworkflows/nf-core/bam_qc_picard -entry test_bam_qc_picard_targetted -c tests/config/nextflow.config + tags: + - subworkflows + # - subworkflows/bam_qc_picard + # Modules + # - picard + # - picard/collectmultiplemetrics + # - picard/collecthsmetrics + files: + - path: ./output/picard/test.CollectMultipleMetrics.alignment_summary_metrics + - path: ./output/picard/test.CollectMultipleMetrics.insert_size_metrics + - path: ./output/picard/test.CollectMultipleMetrics.base_distribution_by_cycle_metrics + - path: ./output/picard/test.CollectMultipleMetrics.quality_by_cycle_metrics + - path: ./output/picard/test.CollectMultipleMetrics.quality_distribution_metrics + - path: ./output/picard/test_collecthsmetrics.txt From 2b29ff5883278856200f003328ece8d4897548bc Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:03:02 +0200 Subject: [PATCH 02/18] drop params.options --- subworkflows/nf-core/bam_qc_picard/main.nf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 31edb2c3..b8a92a21 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -4,9 +4,9 @@ params.options = [:] -include { PICARD_COLLECTMULTIPLEMETRICS } from '../../../modules/picardcollectmultiplemetrics/main' addParams( options: params.options ) -include { PICARD_COLLECTWGSMETRICS } from '../../../modules/picardcollectwgsmetrics/main' addParams( options: params.options ) -include { PICARD_COLLECTHSMETRICS } from '../../../modules/picardcollecthsmetrics/main' addParams( options: params.options ) +include { PICARD_COLLECTMULTIPLEMETRICS } from '../../../modules/picardcollectmultiplemetrics/main' +include { PICARD_COLLECTWGSMETRICS } from '../../../modules/picardcollectwgsmetrics/main' +include { PICARD_COLLECTHSMETRICS } from '../../../modules/picardcollecthsmetrics/main' workflow BAM_QC_PICARD { take: From 8fb8199f3115c1a7f136202882b39be403ac5cd5 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:05:07 +0200 Subject: [PATCH 03/18] fix copilot suggestion --- subworkflows/nf-core/bam_qc_picard/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index b8a92a21..e4a7e5f0 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -22,10 +22,10 @@ workflow BAM_QC_PICARD { ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) if (!ch_bait_interval.isEmpty() || !ch_target_interval.isEmpty()) { if (ch_bait_interval.isEmpty()) { - throw new Error("Bait interval channel is empty") + log.error("Bait interval channel is empty") } if (ch_target_interval.isEmpty()) { - throw new Error("Target interval channel is empty") + log.error("Target interval channel is empty") } PICARD_COLLECTHSMETRICS( ch_bam_bai, ch_fasta, ch_bait_interval, ch_target_interval ) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) From 433aaece46967b56ba6a4c937ce1c8b0706b260e Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:05:31 +0200 Subject: [PATCH 04/18] Update tests/subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- tests/subworkflows/nf-core/bam_qc_picard/main.nf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/subworkflows/nf-core/bam_qc_picard/main.nf b/tests/subworkflows/nf-core/bam_qc_picard/main.nf index d88f2bf9..9112416b 100644 --- a/tests/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/tests/subworkflows/nf-core/bam_qc_picard/main.nf @@ -16,6 +16,8 @@ workflow test_bam_qc_picard_targetted { input = [ [ id:'test', single_end:false ], // meta map file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) ] + bait = file(params.test_data['sarscov2']['genome']['baits_interval_list'], checkIfExists: true) + target = file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) - BAM_QC_PICARD ( input, [], file(params.test_data['sarscov2']['genome']['baits_interval_list'], checkIfExists: true), file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) ) + BAM_QC_PICARD ( input, [], bait, target ) } From 3cbf5c63e5677491377f23e6dda20443804a8158 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:09:25 +0200 Subject: [PATCH 05/18] Update subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- subworkflows/nf-core/bam_qc_picard/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index e4a7e5f0..851268c6 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -20,7 +20,7 @@ workflow BAM_QC_PICARD { PICARD_COLLECTMULTIPLEMETRICS( ch_bam_bai, ch_fasta] ) ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) - if (!ch_bait_interval.isEmpty() || !ch_target_interval.isEmpty()) { + if (ch_bait_interval || ch_target_interval) { if (ch_bait_interval.isEmpty()) { log.error("Bait interval channel is empty") } From 881e9db4bfde569c8e9c0d51a1b3916817610fc0 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:19:30 +0200 Subject: [PATCH 06/18] update tests --- subworkflows/nf-core/bam_qc_picard/meta.yml | 2 +- tests/subworkflows/nf-core/bam_qc_picard/main.nf | 12 +++++++----- tests/subworkflows/nf-core/bam_qc_picard/test.yml | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/meta.yml b/subworkflows/nf-core/bam_qc_picard/meta.yml index 77104e82..c4422150 100644 --- a/subworkflows/nf-core/bam_qc_picard/meta.yml +++ b/subworkflows/nf-core/bam_qc_picard/meta.yml @@ -47,7 +47,7 @@ output: - hs_metrics: type: file description: Alignment metrics files generated by picard CollectHsMetrics - pattern: "*_collecthsmetrics.txt" + pattern: "*_metrics.txt" - wgs_metrics: type: file description: Alignment metrics files generated by picard CollectWgsMetrics diff --git a/tests/subworkflows/nf-core/bam_qc_picard/main.nf b/tests/subworkflows/nf-core/bam_qc_picard/main.nf index 9112416b..03696b44 100644 --- a/tests/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/tests/subworkflows/nf-core/bam_qc_picard/main.nf @@ -6,18 +6,20 @@ include { BAM_QC_PICARD } from '../../../../subworkflows/nf-core/bam_qc_picard/m workflow test_bam_qc_picard_wgs { input = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_single_end_bam'], checkIfExists: true) + file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - BAM_QC_PICARD ( input, [], [], [] ) + BAM_QC_PICARD ( input, fasta, [], [] ) } workflow test_bam_qc_picard_targetted { input = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) bait = file(params.test_data['sarscov2']['genome']['baits_interval_list'], checkIfExists: true) - target = file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) + target = file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) - BAM_QC_PICARD ( input, [], bait, target ) + BAM_QC_PICARD ( input, fasta, bait, target ) } diff --git a/tests/subworkflows/nf-core/bam_qc_picard/test.yml b/tests/subworkflows/nf-core/bam_qc_picard/test.yml index af98230d..7b0a6c2b 100644 --- a/tests/subworkflows/nf-core/bam_qc_picard/test.yml +++ b/tests/subworkflows/nf-core/bam_qc_picard/test.yml @@ -30,4 +30,4 @@ - path: ./output/picard/test.CollectMultipleMetrics.base_distribution_by_cycle_metrics - path: ./output/picard/test.CollectMultipleMetrics.quality_by_cycle_metrics - path: ./output/picard/test.CollectMultipleMetrics.quality_distribution_metrics - - path: ./output/picard/test_collecthsmetrics.txt + - path: ./output/picard/test.CollectHsMetrics.coverage_metrics From b92efb7abfc77cb8d9b4149c5fb866409122ce05 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:21:47 +0200 Subject: [PATCH 07/18] add nextflow.config --- tests/subworkflows/nf-core/bam_qc_picard/nextflow.config | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 tests/subworkflows/nf-core/bam_qc_picard/nextflow.config diff --git a/tests/subworkflows/nf-core/bam_qc_picard/nextflow.config b/tests/subworkflows/nf-core/bam_qc_picard/nextflow.config new file mode 100644 index 00000000..8730f1c4 --- /dev/null +++ b/tests/subworkflows/nf-core/bam_qc_picard/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} From dee8ec9e911ec848e93c8ed0b9667e7c674e9132 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 12:53:17 +0200 Subject: [PATCH 08/18] fix typos --- subworkflows/nf-core/bam_qc_picard/main.nf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 851268c6..747d5995 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -2,11 +2,9 @@ // Run QC steps on BAM/CRAM files using Picard // -params.options = [:] - -include { PICARD_COLLECTMULTIPLEMETRICS } from '../../../modules/picardcollectmultiplemetrics/main' -include { PICARD_COLLECTWGSMETRICS } from '../../../modules/picardcollectwgsmetrics/main' -include { PICARD_COLLECTHSMETRICS } from '../../../modules/picardcollecthsmetrics/main' +include { PICARD_COLLECTMULTIPLEMETRICS } from '../../../modules/picard/collectmultiplemetrics/main' +include { PICARD_COLLECTWGSMETRICS } from '../../../modules/picard/collectwgsmetrics/main' +include { PICARD_COLLECTHSMETRICS } from '../../../modules/picard/collecthsmetrics/main' workflow BAM_QC_PICARD { take: @@ -18,7 +16,7 @@ workflow BAM_QC_PICARD { main: ch_versions = Channel.empty() - PICARD_COLLECTMULTIPLEMETRICS( ch_bam_bai, ch_fasta] ) + PICARD_COLLECTMULTIPLEMETRICS( ch_bam_bai, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) if (ch_bait_interval || ch_target_interval) { if (ch_bait_interval.isEmpty()) { From e0a8af869324765ec0c6a375703bfa68f5ba4e77 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:42:14 +0200 Subject: [PATCH 09/18] fix outputs --- subworkflows/nf-core/bam_qc_picard/main.nf | 14 ++++++++------ subworkflows/nf-core/bam_qc_picard/meta.yml | 8 ++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 747d5995..13f4a845 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -8,7 +8,7 @@ include { PICARD_COLLECTHSMETRICS } from '../../../modules/picard/collecth workflow BAM_QC_PICARD { take: - ch_bam_bai // channel: [ val(meta), [ bam ], [bai/csi] ] + ch_bam // channel: [ val(meta), [ bam ]] ch_fasta // channel: [ fasta ] ch_bait_interval // channel: [ bait_interval ] ch_target_interval // channel: [ target_interval ] @@ -16,7 +16,7 @@ workflow BAM_QC_PICARD { main: ch_versions = Channel.empty() - PICARD_COLLECTMULTIPLEMETRICS( ch_bam_bai, ch_fasta ) + PICARD_COLLECTMULTIPLEMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) if (ch_bait_interval || ch_target_interval) { if (ch_bait_interval.isEmpty()) { @@ -25,16 +25,18 @@ workflow BAM_QC_PICARD { if (ch_target_interval.isEmpty()) { log.error("Target interval channel is empty") } - PICARD_COLLECTHSMETRICS( ch_bam_bai, ch_fasta, ch_bait_interval, ch_target_interval ) + PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_bait_interval, ch_target_interval ) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { - PICARD_COLLECTWGSMETRICS( ch_bam_bai, ch_fasta ) + PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTWGSMETRICS.out.versions.first()) } + ch_coverage_metrics = Channel.empty() + ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.coverage_metrics.first(), PICARD_COLLECTWGSMETRICS.out.coverage_metrics.first()) + emit: - hs_metrics = PICARD_COLLECTHSMETRICS.out.hs_metrics // channel: [ val(meta), [ hs_metrics ] ] - wgs_metrics = PICARD_COLLECTWGSMETRICS.out.metrics // channel: [ val(meta), [ wgs_metrics ] ] + coverage_metrics = PICARD_COLLECTWGSMETRICS.out.metrics // channel: [ val(meta), [ coverage_metrics ] ] multiple_metrics = PICARD_COLLECTMULTIPLEMETRICS.out.metrics // channel: [ val(meta), [ multiple_metrics ] ] versions = ch_versions // channel: [ versions.yml ] diff --git a/subworkflows/nf-core/bam_qc_picard/meta.yml b/subworkflows/nf-core/bam_qc_picard/meta.yml index c4422150..67d3496e 100644 --- a/subworkflows/nf-core/bam_qc_picard/meta.yml +++ b/subworkflows/nf-core/bam_qc_picard/meta.yml @@ -44,14 +44,10 @@ output: description: | Groovy Map containing sample information e.g. [ id:'test', single_end:false ] - - hs_metrics: + - coverage_metrics: type: file - description: Alignment metrics files generated by picard CollectHsMetrics + description: Alignment metrics files generated by picard CollectHsMetrics or CollectWgsMetrics pattern: "*_metrics.txt" - - wgs_metrics: - type: file - description: Alignment metrics files generated by picard CollectWgsMetrics - pattern: "*_{metrics}" - multiple_metrics: type: file description: Alignment metrics files generated by picard CollectMultipleMetrics From 55dfe1d8ab35873790c13ee4eb75af818fef80b2 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:43:59 +0200 Subject: [PATCH 10/18] fix hsmetrics input --- subworkflows/nf-core/bam_qc_picard/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 13f4a845..9e429448 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -25,7 +25,7 @@ workflow BAM_QC_PICARD { if (ch_target_interval.isEmpty()) { log.error("Target interval channel is empty") } - PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_bait_interval, ch_target_interval ) + PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, [], ch_bait_interval, ch_target_interval ) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) From 8ad861a645e86c411b47472616a924063afba106 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:52:03 +0200 Subject: [PATCH 11/18] add fasta index --- subworkflows/nf-core/bam_qc_picard/main.nf | 12 +++++++----- subworkflows/nf-core/bam_qc_picard/meta.yml | 10 +++++----- tests/subworkflows/nf-core/bam_qc_picard/main.nf | 12 +++++++----- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 9e429448..e6f82feb 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -10,14 +10,17 @@ workflow BAM_QC_PICARD { take: ch_bam // channel: [ val(meta), [ bam ]] ch_fasta // channel: [ fasta ] + ch_fasta_faix // channel: [ fasta_fai ] ch_bait_interval // channel: [ bait_interval ] ch_target_interval // channel: [ target_interval ] main: ch_versions = Channel.empty() + ch_coverage_metrics = Channel.empty() PICARD_COLLECTMULTIPLEMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) + if (ch_bait_interval || ch_target_interval) { if (ch_bait_interval.isEmpty()) { log.error("Bait interval channel is empty") @@ -26,18 +29,17 @@ workflow BAM_QC_PICARD { log.error("Target interval channel is empty") } PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, [], ch_bait_interval, ch_target_interval ) + ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.coverage_metrics.first()) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTWGSMETRICS.out.versions.first()) + ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.coverage_metrics.first()) } - ch_coverage_metrics = Channel.empty() - ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.coverage_metrics.first(), PICARD_COLLECTWGSMETRICS.out.coverage_metrics.first()) - emit: - coverage_metrics = PICARD_COLLECTWGSMETRICS.out.metrics // channel: [ val(meta), [ coverage_metrics ] ] + coverage_metrics = ch_coverage_metrics // channel: [ val(meta), [ coverage_metrics ] ] multiple_metrics = PICARD_COLLECTMULTIPLEMETRICS.out.metrics // channel: [ val(meta), [ multiple_metrics ] ] - versions = ch_versions // channel: [ versions.yml ] + versions = ch_versions // channel: [ versions.yml ] } diff --git a/subworkflows/nf-core/bam_qc_picard/meta.yml b/subworkflows/nf-core/bam_qc_picard/meta.yml index 67d3496e..c45215d1 100644 --- a/subworkflows/nf-core/bam_qc_picard/meta.yml +++ b/subworkflows/nf-core/bam_qc_picard/meta.yml @@ -22,14 +22,14 @@ input: type: file description: BAM/CRAM/SAM file pattern: "*.{bam,cram,sam}" - - bai: - type: file - description: Index for BAM/CRAM/SAM file - pattern: "*.{bai,crai,sai}" - fasta: type: optional file - description: Reference file the CRAM was created with + description: Reference fasta file pattern: "*.{fasta,fa}" + - fasta_fai: + type: optional file + description: Reference fasta file index + pattern: "*.{fasta,fa}.fai" - bait_intervals: type: optional file description: An interval list file that contains the locations of the baits used. diff --git a/tests/subworkflows/nf-core/bam_qc_picard/main.nf b/tests/subworkflows/nf-core/bam_qc_picard/main.nf index 03696b44..a3e2ed62 100644 --- a/tests/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/tests/subworkflows/nf-core/bam_qc_picard/main.nf @@ -9,17 +9,19 @@ workflow test_bam_qc_picard_wgs { file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ] fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + fasta_fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true) - BAM_QC_PICARD ( input, fasta, [], [] ) + BAM_QC_PICARD ( input, fasta, fasta_fai, [], [] ) } workflow test_bam_qc_picard_targetted { input = [ [ id:'test', single_end:false ], // meta map file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ] - fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - bait = file(params.test_data['sarscov2']['genome']['baits_interval_list'], checkIfExists: true) - target = file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + fasta_fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true) + bait = file(params.test_data['sarscov2']['genome']['baits_interval_list'], checkIfExists: true) + target = file(params.test_data['sarscov2']['genome']['targets_interval_list'], checkIfExists: true) - BAM_QC_PICARD ( input, fasta, bait, target ) + BAM_QC_PICARD ( input, fasta, fasta_fai, bait, target ) } From 2fc857955f42c3aed840f9a61062b481a159ff4a Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:53:48 +0200 Subject: [PATCH 12/18] fix index omission --- subworkflows/nf-core/bam_qc_picard/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index e6f82feb..341a4310 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -10,7 +10,7 @@ workflow BAM_QC_PICARD { take: ch_bam // channel: [ val(meta), [ bam ]] ch_fasta // channel: [ fasta ] - ch_fasta_faix // channel: [ fasta_fai ] + ch_fasta_fai // channel: [ fasta_fai ] ch_bait_interval // channel: [ bait_interval ] ch_target_interval // channel: [ target_interval ] @@ -28,7 +28,7 @@ workflow BAM_QC_PICARD { if (ch_target_interval.isEmpty()) { log.error("Target interval channel is empty") } - PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, [], ch_bait_interval, ch_target_interval ) + PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_fasta_fai, ch_bait_interval, ch_target_interval ) ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.coverage_metrics.first()) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { From 4618c542e9d64cd71176cfd24fe0edc908eb3d10 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:59:46 +0200 Subject: [PATCH 13/18] fix metrics output --- subworkflows/nf-core/bam_qc_picard/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 341a4310..b8be04b2 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -29,12 +29,12 @@ workflow BAM_QC_PICARD { log.error("Target interval channel is empty") } PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_fasta_fai, ch_bait_interval, ch_target_interval ) - ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.coverage_metrics.first()) + ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.metrics.first()) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTWGSMETRICS.out.versions.first()) - ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.coverage_metrics.first()) + ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.metrics.first()) } emit: From 73600b03393ee2ec585bdc6bb5ff2585fc47bdda Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:20:15 +0200 Subject: [PATCH 14/18] Update subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- subworkflows/nf-core/bam_qc_picard/main.nf | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index b8be04b2..c3a441bc 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -22,12 +22,8 @@ workflow BAM_QC_PICARD { ch_versions = ch_versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions.first()) if (ch_bait_interval || ch_target_interval) { - if (ch_bait_interval.isEmpty()) { - log.error("Bait interval channel is empty") - } - if (ch_target_interval.isEmpty()) { - log.error("Target interval channel is empty") - } + if (!ch_bait_interval) log.error("Bait interval channel is empty") + if (!ch_target_interval) log.error("Target interval channel is empty") PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_fasta_fai, ch_bait_interval, ch_target_interval ) ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.metrics.first()) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) From 71ccf0e207d2b034c931d2264b33f5f54abe1f59 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:24:19 +0200 Subject: [PATCH 15/18] Update subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- subworkflows/nf-core/bam_qc_picard/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index c3a441bc..e3c890d5 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -25,7 +25,7 @@ workflow BAM_QC_PICARD { if (!ch_bait_interval) log.error("Bait interval channel is empty") if (!ch_target_interval) log.error("Target interval channel is empty") PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_fasta_fai, ch_bait_interval, ch_target_interval ) - ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.metrics.first()) + ch_coverage_metrics = PICARD_COLLECTHSMETRICS.out.metrics ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) From 20e3767657ba1a4b87a412121321e79ca109b401 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:24:25 +0200 Subject: [PATCH 16/18] Update subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- subworkflows/nf-core/bam_qc_picard/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index e3c890d5..5f46e065 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -30,7 +30,7 @@ workflow BAM_QC_PICARD { } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTWGSMETRICS.out.versions.first()) - ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.metrics.first()) + ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.metrics) } emit: From 343c0ebe203e53ca9149ec473a8396836039a516 Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:26:00 +0200 Subject: [PATCH 17/18] Update subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- subworkflows/nf-core/bam_qc_picard/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 5f46e065..76709ea6 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -30,7 +30,7 @@ workflow BAM_QC_PICARD { } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta ) ch_versions = ch_versions.mix(PICARD_COLLECTWGSMETRICS.out.versions.first()) - ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.metrics) + ch_coverage_metrics = ch_coverage_metrics.mix(PICARD_COLLECTWGSMETRICS.out.metrics) } emit: From 7e391c3a3bfc84b71e79077ba2569276e6fc5d2a Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:26:06 +0200 Subject: [PATCH 18/18] Update subworkflows/nf-core/bam_qc_picard/main.nf Co-authored-by: Maxime U. Garcia --- subworkflows/nf-core/bam_qc_picard/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subworkflows/nf-core/bam_qc_picard/main.nf b/subworkflows/nf-core/bam_qc_picard/main.nf index 76709ea6..e38697c3 100644 --- a/subworkflows/nf-core/bam_qc_picard/main.nf +++ b/subworkflows/nf-core/bam_qc_picard/main.nf @@ -25,7 +25,7 @@ workflow BAM_QC_PICARD { if (!ch_bait_interval) log.error("Bait interval channel is empty") if (!ch_target_interval) log.error("Target interval channel is empty") PICARD_COLLECTHSMETRICS( ch_bam, ch_fasta, ch_fasta_fai, ch_bait_interval, ch_target_interval ) - ch_coverage_metrics = PICARD_COLLECTHSMETRICS.out.metrics + ch_coverage_metrics = ch_coverage_metrics.mix(PICARD_COLLECTHSMETRICS.out.metrics) ch_versions = ch_versions.mix(PICARD_COLLECTHSMETRICS.out.versions.first()) } else { PICARD_COLLECTWGSMETRICS( ch_bam, ch_fasta )