From 6293ef5323c99eca638629ccd7c9bedbcbddc845 Mon Sep 17 00:00:00 2001 From: BertGalle Date: Mon, 10 Jun 2024 10:30:42 +0200 Subject: [PATCH 1/4] Added ClinCNV workflow --- conf/modules.config | 26 ++++++++ conf/test.config | 3 +- .../clincnv/bedannotategc/environment.yml | 7 ++ modules/local/clincnv/bedannotategc/main.nf | 44 +++++++++++++ .../local/clincnv/bedcoverage/environment.yml | 7 ++ modules/local/clincnv/bedcoverage/main.nf | 48 ++++++++++++++ .../local/clincnv/germline/environment.yml | 20 ++++++ modules/local/clincnv/germline/main.nf | 51 +++++++++++++++ .../local/clincnv/merge_count/environment.yml | 20 ++++++ modules/local/clincnv/merge_count/main.nf | 48 ++++++++++++++ modules/local/clincnv/pathfile/main.nf | 23 +++++++ nextflow.config | 5 +- nextflow_schema.json | 10 ++- subworkflows/local/clincnv/main.nf | 56 ++++++++++++++++ subworkflows/local/exomedepth/main.nf | 30 +-------- subworkflows/local/input_prepare/main.nf | 48 ++++++++++++++ workflows/exomecnv.nf | 64 ++++++++++++------- 17 files changed, 457 insertions(+), 53 deletions(-) create mode 100644 modules/local/clincnv/bedannotategc/environment.yml create mode 100644 modules/local/clincnv/bedannotategc/main.nf create mode 100644 modules/local/clincnv/bedcoverage/environment.yml create mode 100644 modules/local/clincnv/bedcoverage/main.nf create mode 100644 modules/local/clincnv/germline/environment.yml create mode 100644 modules/local/clincnv/germline/main.nf create mode 100644 modules/local/clincnv/merge_count/environment.yml create mode 100644 modules/local/clincnv/merge_count/main.nf create mode 100644 modules/local/clincnv/pathfile/main.nf create mode 100644 subworkflows/local/clincnv/main.nf create mode 100644 subworkflows/local/input_prepare/main.nf diff --git a/conf/modules.config b/conf/modules.config index 4e76fce..634785f 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -36,6 +36,17 @@ process { ] } + withName: 'BEDCOVERAGE' { + ext.args = {[ + '-min_mapq 3', + '-clear' + ].join(' ').trim()} + } + + withName: 'COUNT_MERGE' { + ext.args = { "-n 4" } + } + withName: 'ENSEMBLVEP_VEP' { ext.prefix = {"${meta.id}.vep"} ext.args = {[ @@ -52,6 +63,21 @@ process { ].join(' ').trim()} } + withName: 'GERMLINE' { + ext.args = {[ + '--minimumNumOfElemsInCluster 20', + '--maxNumGermCNVs 2000', + '--maxNumIter 5', + '--numberOfThreads 10', + '--scoreG 60', + '--lengthG 0', + '--hg38', + '--reanalyseCohort FALSE', + '--visulizationIGV F', + '--noPlot T' + ].join(' ').trim()} + } + withName: 'TABIX_TABIX' { publishDir = [ path: {"$params.outdir/exomedepth/cnv_call"}, diff --git a/conf/test.config b/conf/test.config index 6e89afb..b443290 100644 --- a/conf/test.config +++ b/conf/test.config @@ -31,9 +31,11 @@ params { // Parameters roi_auto = "https://raw.githubusercontent.com/nf-cmgg/test-datasets/exomecnv/data/genomics/homo_sapiens/genome/roi/Homo_sapiens.GRCh38.105.chr21_protein_coding_basic_sorted_merged_autosomal.bed" roi_chrx = "https://raw.githubusercontent.com/nf-cmgg/test-datasets/exomecnv/data/genomics/homo_sapiens/genome/roi/Homo_sapiens.GRCh38.105.chrX_protein_coding_basic_sorted_merged.bed" + roi_merged = "https://raw.githubusercontent.com/nf-cmgg/test-datasets/exomecnv/data/genomics/homo_sapiens/genome/roi/Homo_sapiens.GRCh38.105.chr21X_protein_coding_basic_sorted_merged_autosomal.bed" yamlconfig = "${projectDir}/assets/exomedepth.yaml" exomedepth = false + clincnv = false // VEP options @@ -42,6 +44,5 @@ params { vep_assembly = "GRCh38" vep_cache_version = 105 species = "homo_sapiens" - } diff --git a/modules/local/clincnv/bedannotategc/environment.yml b/modules/local/clincnv/bedannotategc/environment.yml new file mode 100644 index 0000000..c1dea5d --- /dev/null +++ b/modules/local/clincnv/bedannotategc/environment.yml @@ -0,0 +1,7 @@ +name: ngs-env +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - ngs-bits=2023_02 diff --git a/modules/local/clincnv/bedannotategc/main.nf b/modules/local/clincnv/bedannotategc/main.nf new file mode 100644 index 0000000..d128100 --- /dev/null +++ b/modules/local/clincnv/bedannotategc/main.nf @@ -0,0 +1,44 @@ +process BEDANNOTATEGC { + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/ngs-bits:2023_02--py311ha0b7adc_2' : + 'biocontainers/ngs-bits:2023_02--py311ha0b7adc_2' }" + + publishDir "$params.outdir/clincnv", mode: 'copy' + + input: + tuple val(meta), path(exon_target) + tuple val(meta2), path(fasta) + tuple val(meta3), path(fai) + + output: + path("*.bed"), emit: annotatedbed + path "versions.yml", emit:versions + + script: + def args = task.ext.args ?: '' + """ + BedAnnotateGC \\ + -in $exon_target \\ + -out GC_Annotated_$exon_target \\ + -ref $fasta \\ + + awk -F'\\t' '{OFS="\\t"; print \$1, \$2, \$3, \$5, \$4}' GC_Annotated_$exon_target > tmp && mv tmp GC_Annotated_$exon_target + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + BedAnnotateGC: \$(BedAnnotateGC --version | sed 's/BedAnnotateGC //g') + END_VERSIONS + """ + + stub: + """ + touch GC_Annotated.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + BedCoverage: \$(BedCoverage --version | sed 's/BedCoverage //g') + END_VERSIONS + """ +} diff --git a/modules/local/clincnv/bedcoverage/environment.yml b/modules/local/clincnv/bedcoverage/environment.yml new file mode 100644 index 0000000..c1dea5d --- /dev/null +++ b/modules/local/clincnv/bedcoverage/environment.yml @@ -0,0 +1,7 @@ +name: ngs-env +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - ngs-bits=2023_02 diff --git a/modules/local/clincnv/bedcoverage/main.nf b/modules/local/clincnv/bedcoverage/main.nf new file mode 100644 index 0000000..4136b40 --- /dev/null +++ b/modules/local/clincnv/bedcoverage/main.nf @@ -0,0 +1,48 @@ +process BEDCOVERAGE { + tag "$meta.id" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/ngs-bits:2023_02--py311ha0b7adc_2' : + 'biocontainers/ngs-bits:2023_02--py311ha0b7adc_2' }" + + publishDir "$params.outdir/clincnv/counts/$meta.pool", mode: 'copy' + + input: + tuple val(meta), path(bam), path(bai) + tuple val(meta2), path(exon_target) + + output: + tuple val(meta), path("*.cov"), emit: counts + path "versions.yml", emit:versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + """ + BedCoverage \\ + -bam $bam \\ + -in $exon_target \\ + $args \\ + -threads $task.cpus \\ + -out ${meta.id}.cov + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + BedCoverage: \$(BedCoverage --version | sed 's/BedCoverage //g') + END_VERSIONS + """ + + stub: + """ + touch ${meta.id}.cov + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + BedCoverage: \$(BedCoverage --version | sed 's/BedCoverage //g') + END_VERSIONS + """ +} diff --git a/modules/local/clincnv/germline/environment.yml b/modules/local/clincnv/germline/environment.yml new file mode 100644 index 0000000..d627e1c --- /dev/null +++ b/modules/local/clincnv/germline/environment.yml @@ -0,0 +1,20 @@ +name: clincnv +channels: + - bioconda + - conda-forge + - defaults +dependencies: + - r-base=4.2.3 + - r-rcpp=1.0.11 + - r-optparse=1.7.5 + - r-robustbase=0.95_1 + - r-data.table=1.14.8 + - r-foreach=1.5.2 + - r-doparallel=1.0.17 + - r-mclust=6.0.0 + - r-r.utils=2.12.2 + - r-rcolorbrewer=1.1_3 + - r-party=1.3_13 + - r-dbscan=1.1_11 + - r-umap=0.2.10.0 + - r-mass=7.3_60 diff --git a/modules/local/clincnv/germline/main.nf b/modules/local/clincnv/germline/main.nf new file mode 100644 index 0000000..fd8ced3 --- /dev/null +++ b/modules/local/clincnv/germline/main.nf @@ -0,0 +1,51 @@ +process GERMLINE { + tag "$sample" + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/cmgg/clincnv:1.18.3': + 'cmgg/clincnv:1.18.3' }" + conda "${moduleDir}/environment.yml" + + publishDir "$params.outdir/clincnv/calling", mode: 'copy' + + input: + tuple val(meta), val(sample), path(file) + path(bed) + + output: + tuple val(meta), val(sample), path("*.tsv"), emit: tsv + path "versions.yml", emit: versions + + script: + def publishDir = "$params.outdir/clincnv/calling/" + def bedDir = "$params.outdir/clincnv" + def fileDir = "$params.outdir/clincnv/counts/$meta.id" + def args = task.ext.args ?: '' + def VERSION = '1.19.0' + """ + clinCNV.R \\ + --normal ${fileDir}/${file} \\ + --normalSample=${sample} \\ + --bed ${bedDir}/${bed} \\ + --out ${publishDir} \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + ClinCNV: ${VERSION} + R: \$(Rscript --version | sed 's/R scripting front-end //g') + END_VERSIONS + """ + + stub: + def VERSION = '1.19.0' + """ + touch ${sample}.ready_CNVS.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + ClinCNV: ${VERSION} + R: \$(Rscript --version | sed 's/R scripting front-end //g') + END_VERSIONS + """ +} diff --git a/modules/local/clincnv/merge_count/environment.yml b/modules/local/clincnv/merge_count/environment.yml new file mode 100644 index 0000000..d627e1c --- /dev/null +++ b/modules/local/clincnv/merge_count/environment.yml @@ -0,0 +1,20 @@ +name: clincnv +channels: + - bioconda + - conda-forge + - defaults +dependencies: + - r-base=4.2.3 + - r-rcpp=1.0.11 + - r-optparse=1.7.5 + - r-robustbase=0.95_1 + - r-data.table=1.14.8 + - r-foreach=1.5.2 + - r-doparallel=1.0.17 + - r-mclust=6.0.0 + - r-r.utils=2.12.2 + - r-rcolorbrewer=1.1_3 + - r-party=1.3_13 + - r-dbscan=1.1_11 + - r-umap=0.2.10.0 + - r-mass=7.3_60 diff --git a/modules/local/clincnv/merge_count/main.nf b/modules/local/clincnv/merge_count/main.nf new file mode 100644 index 0000000..f0b67fe --- /dev/null +++ b/modules/local/clincnv/merge_count/main.nf @@ -0,0 +1,48 @@ +// MERGE COUNT FILES +process COUNT_MERGE { + tag "$meta.id" + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/cmgg/clincnv:1.18.3': + 'cmgg/clincnv:1.18.3' }" + conda "${moduleDir}/environment.yml" + + publishDir "$params.outdir/clincnv/counts/$meta.id", mode: 'copy' + + input: + tuple val(meta), val(samples), path(file) + + output: + tuple val(meta), val(samples), path("*.txt"), emit: merge + path "versions.yml", emit:versions + + script: + def prefix = task.ext.prefix ?: "${meta.id}.normal" + def args = task.ext.args ?: '' + def VERSION = '1.19.0' + """ + mergeFilesFromFolderDT.R \\ + -i ${file} \\ + -o ${prefix}.txt \\ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + ClinCNV: ${VERSION} + R: \$(Rscript --version | sed 's/R scripting front-end //g') + END_VERSIONS + """ + + stub: + prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = '1.19.0' + """ + touch ${prefix}.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + ClinCNV: ${VERSION} + R: \$(Rscript --version | sed 's/R scripting front-end //g') + END_VERSIONS + """ +} diff --git a/modules/local/clincnv/pathfile/main.nf b/modules/local/clincnv/pathfile/main.nf new file mode 100644 index 0000000..972ec6c --- /dev/null +++ b/modules/local/clincnv/pathfile/main.nf @@ -0,0 +1,23 @@ +process PATHFILE { + tag "$meta.id" + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/coreutils:9.3' : + 'biocontainers/coreutils:9.3' }" + + publishDir "$params.outdir/clincnv/counts/$meta.id", mode: 'copy' + + input: + tuple val(meta), val(samples), path(files) + + output: + tuple val(meta), val(samples), path("*.txt"), emit: counts + + script: + def prefix = task.ext.prefix ?: "${meta.id}_paths" + def publishDir = "$params.outdir/clincnv/counts/$meta.id" + def fileList = files.collect(file -> "${publishDir}/${file}").join('\n') + """ + echo -e "${fileList}" > ${prefix}.txt + """ +} diff --git a/nextflow.config b/nextflow.config index d1de4cc..2590ae6 100644 --- a/nextflow.config +++ b/nextflow.config @@ -19,7 +19,6 @@ params { igenomes_base = null //'s3://ngi-igenomes/igenomes/' igenomes_ignore = true - // MultiQC options multiqc_config = null multiqc_title = null @@ -72,7 +71,9 @@ params { annotate = null vep_assembly = "GRCh38" - + // CLINCNV Parameters + roi_merged = null + clincnv = false } // Load base.config by default for all pipelines diff --git a/nextflow_schema.json b/nextflow_schema.json index e1b07d9..d450003 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -44,6 +44,10 @@ "exomedepth": { "type": "boolean", "description": "Option to execute the ExomeDepth tool" + }, + "clincnv": { + "type": "boolean", + "description": "Option to execute the ClinCNV tool" } } }, @@ -92,9 +96,13 @@ "default": "/conf/", "description": "The config base path for the cmgg configs", "format": "directory-path" + }, + "roi_merged": { + "type": "string", + "description": "Path to the default ROI (regions of interest) BED file of autosomal and chrX merged regions to be used for CNV analysis" } }, - "required": ["fasta", "fai"] + "required": ["fasta", "fai", "roi_merged"] }, "institutional_config_options": { "title": "Institutional config options", diff --git a/subworkflows/local/clincnv/main.nf b/subworkflows/local/clincnv/main.nf new file mode 100644 index 0000000..2c0738f --- /dev/null +++ b/subworkflows/local/clincnv/main.nf @@ -0,0 +1,56 @@ +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + IMPORT MODULES / SUBWORKFLOWS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +include { BEDCOVERAGE } from '../../../modules/local/clincnv/bedcoverage/main' +include { COUNT_MERGE } from '../../../modules/local/clincnv/merge_count/main' +include { PATHFILE } from '../../../modules/local/clincnv/pathfile/main' +include { BEDANNOTATEGC } from '../../../modules/local/clincnv/bedannotategc/main' +include { GERMLINE } from '../../../modules/local/clincnv/germline/main' +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + RUN EXOMEDEPTH WORKFLOW +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +workflow CLINCNV { + + take: + ch_samplesheet + ch_fasta + ch_fai + + main: + ch_versions = Channel.empty() + + ch_roi_merged = Channel.fromPath(params.roi_merged).map{ [[id:"chr21X"], it]}.collect() + + BEDCOVERAGE(ch_samplesheet,ch_roi_merged) + ch_versions = ch_versions.mix(BEDCOVERAGE.out.versions) + + grouped_counts = BEDCOVERAGE.out.counts + .map { meta, txt -> + def new_meta = [id:meta.pool] + [new_meta, meta.sample, txt] + } + .groupTuple() + + PATHFILE(grouped_counts) + + COUNT_MERGE(PATHFILE.out.counts) + ch_versions = ch_versions.mix(COUNT_MERGE.out.versions) + + BEDANNOTATEGC(ch_roi_merged, ch_fasta, ch_fai) + ch_versions = ch_versions.mix(BEDANNOTATEGC.out.versions) + + ch_clincnv = COUNT_MERGE.out.merge.transpose(by:1) + + // GERMLINE(ch_clincnv,BEDANNOTATEGC.out.annotatedbed) + // ch_versions = ch_versions.mix(GERMLINE.out.versions) + + emit: + versions = ch_versions + +} diff --git a/subworkflows/local/exomedepth/main.nf b/subworkflows/local/exomedepth/main.nf index cfebd74..ccde309 100644 --- a/subworkflows/local/exomedepth/main.nf +++ b/subworkflows/local/exomedepth/main.nf @@ -4,7 +4,6 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -include { SAMTOOLS_CONVERT as CRAM_PREPARE } from '../../../modules/nf-core/samtools/convert/main' include { COUNT as COUNT_X } from '../../../modules/local/exomedepth/count/main' include { COUNT as COUNT_AUTO } from '../../../modules/local/exomedepth/count/main' include { COUNT_MERGE as COUNT_MERGE_AUTO } from '../../../modules/local/exomedepth/merge_count/main' @@ -24,43 +23,20 @@ workflow EXOMEDEPTH { take: ch_samplesheet + ch_fai main: ch_versions = Channel.empty() // Importing and convert the input files passed through the parameters to channels - // Branch into CRAM and BAM files - ch_samplesheet.branch { meta, cram, crai -> - CRAM: cram.extension == "cram" - BAM: cram.extension == "bam" - } - .set{ ch_input_prepare } - - ch_fasta = Channel.fromPath(params.fasta).map{ [[id:"reference"], it]}.collect() - ch_fai = params.fai ? Channel.fromPath(params.fai).map{ [[id:"reference"], it]}.collect() : null ch_roi_auto = Channel.fromPath(params.roi_auto).map{ [[id:"autosomal"], it]}.collect() ch_roi_x = Channel.fromPath(params.roi_chrx).map{ [[id:"chrX"], it]}.collect() - // SUBWORKFLOW: Convert CRAM to BAM if no BAM file was provided - - CRAM_PREPARE ( - ch_input_prepare.CRAM, ch_fasta, ch_fai - ) - ch_versions = ch_versions.mix(CRAM_PREPARE.out.versions) - - CRAM_PREPARE.out.bam - .join(CRAM_PREPARE.out.bai) - .set{ ch_cram_prepare } - - ch_input_prepare.BAM - .mix(ch_cram_prepare) - .set{ ch_input_bam } - //MODULE: Count autosomal reads per sample (count file for each sample) COUNT_AUTO ( - ch_input_bam, ch_roi_auto + ch_samplesheet, ch_roi_auto ) ch_versions = ch_versions.mix(COUNT_AUTO.out.versions) @@ -98,7 +74,7 @@ workflow EXOMEDEPTH { //MODULE: Count chrX reads per sample (count file for each sample) COUNT_X ( - ch_input_bam, ch_roi_x + ch_samplesheet, ch_roi_x ) //MODULE: Group chrX counts per pool (count file for each pool) diff --git a/subworkflows/local/input_prepare/main.nf b/subworkflows/local/input_prepare/main.nf new file mode 100644 index 0000000..bb02905 --- /dev/null +++ b/subworkflows/local/input_prepare/main.nf @@ -0,0 +1,48 @@ +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + IMPORT MODULES / SUBWORKFLOWS +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +include { SAMTOOLS_CONVERT as CRAM_PREPARE } from '../../../modules/nf-core/samtools/convert/main' + +/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + RUN INPUT PREPARE WORKFLOW +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +*/ + +workflow INPUT_PREPARE { + + take: + ch_samplesheet + + main: + ch_versions = Channel.empty() + + ch_samplesheet.branch { meta, cram, crai -> + CRAM: cram.extension == "cram" + BAM: cram.extension == "bam" + } + .set{ ch_input_prepare } + + ch_fasta = Channel.fromPath(params.fasta).map{ [[id:"reference"], it]}.collect() + ch_fai = params.fai ? Channel.fromPath(params.fai).map{ [[id:"reference"], it]}.collect() : null + + CRAM_PREPARE ( + ch_input_prepare.CRAM, ch_fasta, ch_fai + ) + ch_versions = ch_versions.mix(CRAM_PREPARE.out.versions) + + CRAM_PREPARE.out.bam + .join(CRAM_PREPARE.out.bai) + .set{ ch_cram_prepare } + + ch_input_prepare.BAM + .mix(ch_cram_prepare) + .set{ ch_input_bam } + + emit: + versions = ch_versions + bam = ch_input_bam +} diff --git a/workflows/exomecnv.nf b/workflows/exomecnv.nf index a4d7e22..75424e2 100644 --- a/workflows/exomecnv.nf +++ b/workflows/exomecnv.nf @@ -11,11 +11,13 @@ include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pi include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_exomecnv_pipeline' // local +include { INPUT_PREPARE as PREPARE } from '../subworkflows/local/input_prepare/main' include { EXOMEDEPTH } from '../subworkflows/local/exomedepth/main' include { VCF_ANNOTATION as ANNOTATION_FROM_CRAM } from '../subworkflows/local/vcf_annotation/main' include { VCF_ANNOTATION as ANNOTATION_FROM_VCF } from '../subworkflows/local/vcf_annotation/main' include { TABIX_TABIX as TABIX } from '../modules/nf-core/tabix/tabix/main' - +include { CLINCNV } from '../subworkflows/local/clincnv/main' +include { SAMTOOLS_CONVERT as CRAM_PREPARE } from '../modules/nf-core/samtools/convert/main' /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RUN MAIN WORKFLOW @@ -38,6 +40,8 @@ workflow EXOMECNV { } .collect() + ch_fai = params.fai ? Channel.fromPath(params.fai).map{ [[id:"reference"], it]}.collect() : null + ch_vep_cache = Channel.fromPath(params.vep_cache).collect() ch_samplesheet.branch { meta, cram, crai, vcf, tbi -> @@ -47,39 +51,55 @@ workflow EXOMECNV { return [ meta, cram, crai]} .set{ ch_input } - // ExomeDepth if (ch_input.no_vcf) { + + // Convert CRAM to BAM if needed + if(params.clincnv || params.exomedepth){ + PREPARE(ch_input.no_vcf) + ch_versions = ch_versions.mix(PREPARE.out.versions) + } + + // ClinCNV + + if (params.clincnv) { + CLINCNV(PREPARE.out.bam, ch_fasta, ch_fai) + ch_versions = ch_versions.mix(CLINCNV.out.versions) + } + + // ExomeDepth + if (params.exomedepth) { - EXOMEDEPTH (ch_input.no_vcf) - ch_versions = EXOMEDEPTH.out.versions + EXOMEDEPTH (PREPARE.out.bam,ch_fai) + ch_versions = ch_versions.mix(EXOMEDEPTH.out.versions) - // Index files for VCF + // Index files for VCF - TABIX ( EXOMEDEPTH.out.vcf ) - ch_exomedepth_vcf = EXOMEDEPTH.out.vcf - .join(TABIX.out.tbi) + TABIX ( EXOMEDEPTH.out.vcf ) + ch_versions = ch_versions.mix(TABIX.out.versions) + ch_exomedepth_vcf = EXOMEDEPTH.out.vcf + .join(TABIX.out.tbi) - // EnsemblVEP after ExomeDepth + // EnsemblVEP after ExomeDepth - if (params.annotate) { + if (params.annotate) { - ANNOTATION_FROM_CRAM ( ch_exomedepth_vcf, ch_fasta, ch_vep_cache ) - ch_versions = ch_versions.mix(ANNOTATION_FROM_CRAM.out.versions) - } - } + ANNOTATION_FROM_CRAM ( ch_exomedepth_vcf, ch_fasta, ch_vep_cache ) + ch_versions = ch_versions.mix(ANNOTATION_FROM_CRAM.out.versions) + } + } } // EnsemblVEP on VCF input file if (ch_input.vcf) { - ch_vcf = ch_input.vcf - .map { meta,bam,bai,vcf,tbi -> - [[id:meta.id], vcf, tbi]} - - ANNOTATION_FROM_VCF ( - ch_vcf, ch_fasta, ch_vep_cache - ) - ch_versions = ANNOTATION_FROM_VCF.out.versions + ch_vcf = ch_input.vcf + .map { meta,bam,bai,vcf,tbi -> + [[id:meta.id], vcf, tbi]} + + ANNOTATION_FROM_VCF ( + ch_vcf, ch_fasta, ch_vep_cache + ) + ch_versions = ch_versions.mix(ANNOTATION_FROM_VCF.out.versions) } // Collate and save software versions From 886e6ef4cc5b3f433d090d1617e23f6dd98ccec6 Mon Sep 17 00:00:00 2001 From: BertGalle Date: Fri, 14 Jun 2024 11:31:48 +0200 Subject: [PATCH 2/4] Changed name --- subworkflows/local/clincnv/main.nf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subworkflows/local/clincnv/main.nf b/subworkflows/local/clincnv/main.nf index 2c0738f..05629eb 100644 --- a/subworkflows/local/clincnv/main.nf +++ b/subworkflows/local/clincnv/main.nf @@ -5,7 +5,7 @@ */ include { BEDCOVERAGE } from '../../../modules/local/clincnv/bedcoverage/main' -include { COUNT_MERGE } from '../../../modules/local/clincnv/merge_count/main' +include { COVERAGE_MERGE } from '../../../modules/local/clincnv/merge_coverage/main' include { PATHFILE } from '../../../modules/local/clincnv/pathfile/main' include { BEDANNOTATEGC } from '../../../modules/local/clincnv/bedannotategc/main' include { GERMLINE } from '../../../modules/local/clincnv/germline/main' @@ -39,13 +39,13 @@ workflow CLINCNV { PATHFILE(grouped_counts) - COUNT_MERGE(PATHFILE.out.counts) - ch_versions = ch_versions.mix(COUNT_MERGE.out.versions) + COVERAGE_MERGE(PATHFILE.out.counts) + ch_versions = ch_versions.mix(COVERAGE_MERGE.out.versions) BEDANNOTATEGC(ch_roi_merged, ch_fasta, ch_fai) ch_versions = ch_versions.mix(BEDANNOTATEGC.out.versions) - ch_clincnv = COUNT_MERGE.out.merge.transpose(by:1) + ch_clincnv = COVERAGE_MERGE.out.merge.transpose(by:1) // GERMLINE(ch_clincnv,BEDANNOTATEGC.out.annotatedbed) // ch_versions = ch_versions.mix(GERMLINE.out.versions) From c37327b819a751b2cb3c86f4d2e0447dcbe1f540 Mon Sep 17 00:00:00 2001 From: BertGalle Date: Fri, 14 Jun 2024 11:32:14 +0200 Subject: [PATCH 3/4] Changed name --- .../clincnv/{merge_count => merge_coverage}/environment.yml | 0 modules/local/clincnv/{merge_count => merge_coverage}/main.nf | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename modules/local/clincnv/{merge_count => merge_coverage}/environment.yml (100%) rename modules/local/clincnv/{merge_count => merge_coverage}/main.nf (98%) diff --git a/modules/local/clincnv/merge_count/environment.yml b/modules/local/clincnv/merge_coverage/environment.yml similarity index 100% rename from modules/local/clincnv/merge_count/environment.yml rename to modules/local/clincnv/merge_coverage/environment.yml diff --git a/modules/local/clincnv/merge_count/main.nf b/modules/local/clincnv/merge_coverage/main.nf similarity index 98% rename from modules/local/clincnv/merge_count/main.nf rename to modules/local/clincnv/merge_coverage/main.nf index f0b67fe..4a1fe88 100644 --- a/modules/local/clincnv/merge_count/main.nf +++ b/modules/local/clincnv/merge_coverage/main.nf @@ -1,5 +1,5 @@ // MERGE COUNT FILES -process COUNT_MERGE { +process COVERAGE_MERGE { tag "$meta.id" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? From 56eeb3e8be4d6f360bccb85aa18c533f3124215c Mon Sep 17 00:00:00 2001 From: BertGalle <129084478+BertGalle@users.noreply.github.com> Date: Tue, 18 Jun 2024 11:55:55 +0200 Subject: [PATCH 4/4] Update exomedepth --- workflows/exomecnv.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflows/exomecnv.nf b/workflows/exomecnv.nf index 3feb819..75424e2 100644 --- a/workflows/exomecnv.nf +++ b/workflows/exomecnv.nf @@ -69,7 +69,7 @@ workflow EXOMECNV { // ExomeDepth if (params.exomedepth) { - EXOMEDEPTH (ch_input.no_vcf) + EXOMEDEPTH (PREPARE.out.bam,ch_fai) ch_versions = ch_versions.mix(EXOMEDEPTH.out.versions) // Index files for VCF