From d4422a10a166ddb67e302b56169e4dbb781b6c1b Mon Sep 17 00:00:00 2001 From: Shihab Dider Date: Thu, 17 Oct 2024 13:58:21 -0400 Subject: [PATCH] feat: wire up estimatelibrarycomplexity to bam_qc --- conf/modules.config | 8 ++++++++ .../local/{bam_qc_picard => bam_qc}/main.nf | 20 +++++++++++++++---- tests/test_runs/chr21_test/params.json | 2 +- workflows/nfcasereports.nf | 11 ++++++---- 4 files changed, 32 insertions(+), 9 deletions(-) rename subworkflows/local/{bam_qc_picard => bam_qc}/main.nf (63%) diff --git a/conf/modules.config b/conf/modules.config index 0325c71..6900ab0 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -53,6 +53,14 @@ process { ] } + withName: 'GATK4_ESTIMATELIBRARYCOMPLEXITY' { + publishDir = [ + mode: params.publish_dir_mode, + path: { "${params.outdir}/qc_reports/gatk/${meta.id}" }, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename }, + ] + } + withName: 'SAMTOOLS_STATS' { ext.when = { !(params.skip_tools && params.skip_tools.split(',').contains('samtools')) } ext.prefix = { "${meta.id}.sorted.cram" } diff --git a/subworkflows/local/bam_qc_picard/main.nf b/subworkflows/local/bam_qc/main.nf similarity index 63% rename from subworkflows/local/bam_qc_picard/main.nf rename to subworkflows/local/bam_qc/main.nf index 8ae0e7e..b0333e4 100644 --- a/subworkflows/local/bam_qc_picard/main.nf +++ b/subworkflows/local/bam_qc/main.nf @@ -4,14 +4,16 @@ include { PICARD_COLLECTWGSMETRICS } from '../../../modules/nf-core/picard/collectwgsmetrics/main' include { PICARD_COLLECTMULTIPLEMETRICS } from '../../../modules/nf-core/picard/collectmultiplemetrics/main' +include { GATK4_ESTIMATELIBRARYCOMPLEXITY } from '../../../modules/nf-core/gatk4/estimatelibrarycomplexity/main' -fasta = WorkflowNfcasereports.create_file_channel(params.fasta) -fai = WorkflowNfcasereports.create_file_channel(params.fasta_fai) -intervals = WorkflowNfcasereports.create_file_channel(params.intervals) +fasta = WorkflowNfcasereports.create_file_channel(params.fasta) +fai = WorkflowNfcasereports.create_file_channel(params.fasta_fai) +intervals = WorkflowNfcasereports.create_file_channel(params.intervals) -workflow BAM_QC_PICARD { +workflow BAM_QC { take: bam // channel: [mandatory] [ meta, bam, bai ] + dict main: versions = Channel.empty() @@ -30,13 +32,23 @@ workflow BAM_QC_PICARD { fai.map{ it -> [ [ id:'fai' ], it ] }, ) + bam_only = bam.map{ meta, bam, bai -> [ meta, bam ] } + GATK4_ESTIMATELIBRARYCOMPLEXITY( + bam_only, + fasta, + fai, + dict + ) + // Gather all reports generated reports = reports.mix(PICARD_COLLECTWGSMETRICS.out.metrics) reports = reports.mix(PICARD_COLLECTMULTIPLEMETRICS.out.metrics) + reports = reports.mix(GATK4_ESTIMATELIBRARYCOMPLEXITY.out.metrics) // Gather versions of all tools used versions = versions.mix(PICARD_COLLECTWGSMETRICS.out.versions) versions = versions.mix(PICARD_COLLECTMULTIPLEMETRICS.out.versions) + versions = versions.mix(GATK4_ESTIMATELIBRARYCOMPLEXITY.out.versions) emit: reports diff --git a/tests/test_runs/chr21_test/params.json b/tests/test_runs/chr21_test/params.json index f065504..03dd3d5 100644 --- a/tests/test_runs/chr21_test/params.json +++ b/tests/test_runs/chr21_test/params.json @@ -4,7 +4,7 @@ "fasta": "/gpfs/commons/home/sdider/DB/GATK/human_g1k_v37_decoy.fasta", "fasta_fai": "/gpfs/commons/home/sdider/DB/GATK/human_g1k_v37_decoy.fasta.fai", "bwa": "/gpfs/commons/home/sdider/DB/GATK/bwa/", - "tools": "snv_multiplicity", + "tools": "bamqc", "outdir": "./results", "pon_dryclean": "/gpfs/commons/home/sdider/Projects/nf-casereports/tests/test_data/chr21_pon.rds", "field_dryclean": "reads", diff --git a/workflows/nfcasereports.nf b/workflows/nfcasereports.nf index bc6352c..8aae161 100644 --- a/workflows/nfcasereports.nf +++ b/workflows/nfcasereports.nf @@ -498,7 +498,7 @@ include { CRAM_QC_MOSDEPTH_SAMTOOLS as CRAM_QC_NO_MD } from '../subworkflows/loc include { CRAM_QC_MOSDEPTH_SAMTOOLS as CRAM_QC_RECAL } from '../subworkflows/local/cram_qc_mosdepth_samtools/main' // BAM Picard QC -include { BAM_QC_PICARD } from '../subworkflows/local/bam_qc_picard/main' +include { BAM_QC } from '../subworkflows/local/bam_qc/main' // Create recalibration tables include { BAM_BASERECALIBRATOR } from '../subworkflows/local/bam_baserecalibrator/main' @@ -876,11 +876,14 @@ workflow NFCASEREPORTS { bam_qc_calling = alignment_bams_final .join(bam_qc_inputs) .map { it -> [ it[1], it[2], it[3] ] } // meta, bam, bai - BAM_QC_PICARD(bam_qc_calling) + + // omit meta since it is not used in the BAM_QC + dict_path = dict.map{ meta, dict -> dict } + BAM_QC(bam_qc_calling, dict_path) // Gather QC - reports = reports.mix(BAM_QC_PICARD.out.reports.collect{ meta, report -> report }) - versions = versions.mix(BAM_QC_PICARD.out.versions) + reports = reports.mix(BAM_QC.out.reports.collect{ meta, report -> report }) + versions = versions.mix(BAM_QC.out.versions) } // SV Calling