diff --git a/modules/controlfreec/assesssignificance/main.nf b/modules/controlfreec/assesssignificance/main.nf index dc9c6e86..f85a3c7f 100644 --- a/modules/controlfreec/assesssignificance/main.nf +++ b/modules/controlfreec/assesssignificance/main.nf @@ -11,7 +11,7 @@ process CONTROLFREEC_ASSESSSIGNIFICANCE { tuple val(meta), path(cnvs), path(ratio) output: - tuple val(meta), path("*.p.value.txt"), emit: bam + tuple val(meta), path("*.p.value.txt"), emit: p_value_txt path "versions.yml" , emit: versions when: @@ -19,9 +19,12 @@ process CONTROLFREEC_ASSESSSIGNIFICANCE { script: def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" """ cat /usr/local/bin/assess_significance.R | R --slave --args ${cnvs} ${ratio} + mv *.p.value.txt ${prefix}.p.value.txt + cat <<-END_VERSIONS > versions.yml "${task.process}": controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) diff --git a/modules/controlfreec/makegraph/main.nf b/modules/controlfreec/makegraph/main.nf new file mode 100644 index 00000000..9a0c7281 --- /dev/null +++ b/modules/controlfreec/makegraph/main.nf @@ -0,0 +1,40 @@ +process CONTROLFREEC_MAKEGRAPH { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::control-freec=11.6" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/control-freec:11.6--h1b792b2_1': + 'quay.io/biocontainers/control-freec:11.6--h1b792b2_1' }" + + input: + tuple val(meta), path(ratio), path(baf) + + output: + tuple val(meta), path("*_BAF.png") , emit: png_baf + tuple val(meta), path("*_ratio.log2.png"), emit: png_ratio_log2 + tuple val(meta), path("*_ratio.png") , emit: png_ratio + + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: "" + def prefix = task.ext.prefix ?: "${meta.id}" + def baf = baf ?: "" + """ + cat /usr/local/bin/makeGraph.R | R --slave --args ${args} ${ratio} ${baf} + + mv *_BAF.txt.png ${prefix}_BAF.png + mv *_ratio.txt.log2.png ${prefix}_ratio.log2.png + mv *_ratio.txt.png ${prefix}_ratio.png + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) + END_VERSIONS + """ +} diff --git a/modules/controlfreec/makegraph/meta.yml b/modules/controlfreec/makegraph/meta.yml new file mode 100644 index 00000000..a207ec8c --- /dev/null +++ b/modules/controlfreec/makegraph/meta.yml @@ -0,0 +1,58 @@ +name: controlfreec_makegraph +description: Plot Freec output +keywords: + - cna + - cnv + - somatic + - single + - tumor-only +tools: + - controlfreec: + description: Copy number and genotype annotation from whole genome and whole exome sequencing data. + homepage: http://boevalab.inf.ethz.ch/FREEC + documentation: http://boevalab.inf.ethz.ch/FREEC/tutorial.html + tool_dev_url: https://github.com/BoevaLab/FREEC/ + doi: "10.1093/bioinformatics/btq635" + licence: ["GPL >=2"] + +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - ratio: + type: file + description: ratio file generated by FREEC + pattern: "*.ratio.txt" + - baf: + type: file + description: .BAF file generated by FREEC + pattern: "*.BAF" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - png_baf: + type: file + description: Image of BAF plot + pattern: "*_BAF.png" + - png_ratio_log2: + type: file + description: Image of ratio log2 plot + pattern: "*_ratio.log2.png" + - png_ratio: + type: file + description: Image of ratio plot + pattern: "*_ratio.png" + +authors: + - "@FriederikeHanssen" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 0c77497d..6e2dbb9a 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -431,6 +431,10 @@ controlfreec/freec2bed: - modules/controlfreec/freec2bed/** - tests/modules/controlfreec/freec2bed/** +controlfreec/makegraph: + - modules/controlfreec/makegraph/** + - tests/modules/controlfreec/makegraph/** + cooler/cload: - modules/cooler/cload/** - tests/modules/cooler/cload/** diff --git a/tests/modules/controlfreec/assesssignificance/test.yml b/tests/modules/controlfreec/assesssignificance/test.yml index 58f83f43..f8393330 100644 --- a/tests/modules/controlfreec/assesssignificance/test.yml +++ b/tests/modules/controlfreec/assesssignificance/test.yml @@ -4,7 +4,7 @@ - controlfreec/assesssignificance - controlfreec files: - - path: output/controlfreec/test2.mpileup.gz_CNVs.p.value.txt + - path: output/controlfreec/test.p.value.txt md5sum: 44e23b916535fbc1a3f47b57fad292df - path: output/controlfreec/versions.yml md5sum: 0aa42fed10d61e4570fe1e0e83ffe932 diff --git a/tests/modules/controlfreec/makegraph/main.nf b/tests/modules/controlfreec/makegraph/main.nf new file mode 100644 index 00000000..ffea3d99 --- /dev/null +++ b/tests/modules/controlfreec/makegraph/main.nf @@ -0,0 +1,42 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CONTROLFREEC_MAKEGRAPH } from '../../../../modules/controlfreec/makegraph/main.nf' +include { CONTROLFREEC_FREEC } from '../../../../modules/controlfreec/freec/main.nf' +include { UNTAR } from '../../../../modules/untar/main.nf' + +workflow test_controlfreec_makegraph { + + input = [ + [ id:'test', single_end:false, sex:'XX' ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_mpileup'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), + [],[],[],[] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) + + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz_tbi'], checkIfExists: true) + + chrfiles = [ [], file(params.test_data['homo_sapiens']['genome']['genome_21_chromosomes_dir'], checkIfExists: true) ] + target_bed = file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + + UNTAR(chrfiles) + CONTROLFREEC_FREEC (input, + fasta, + fai, + [], + dbsnp, + dbsnp_tbi, + UNTAR.out.untar.map{ it[1] }, + [], + target_bed, + [] + ) + + makegraph_in = CONTROLFREEC_FREEC.out.ratio.join(CONTROLFREEC_FREEC.out.BAF) + CONTROLFREEC_MAKEGRAPH ( makegraph_in ) +} diff --git a/tests/modules/controlfreec/makegraph/nextflow.config b/tests/modules/controlfreec/makegraph/nextflow.config new file mode 100644 index 00000000..f88fae50 --- /dev/null +++ b/tests/modules/controlfreec/makegraph/nextflow.config @@ -0,0 +1,30 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName:CONTROLFREEC_FREEC{ + ext.args = { [ + "sample":[ + inputformat: 'pileup', + mateorientation: 'FR' + ], + "general" :[ + bedgraphoutput: "TRUE", + noisydata: "TRUE", + minexpectedgc: "0", + readcountthreshold: "1", + sex: meta.sex, + window: "10", + ], + "control":[ + inputformat: "pileup", + mateorientation: "FR" + ] + ] + } + } + + withName:CONTROLFREEC_MAKEGRAPH { + ext.args = "2" + } +} diff --git a/tests/modules/controlfreec/makegraph/test.yml b/tests/modules/controlfreec/makegraph/test.yml new file mode 100644 index 00000000..21e78766 --- /dev/null +++ b/tests/modules/controlfreec/makegraph/test.yml @@ -0,0 +1,12 @@ +- name: controlfreec makegraph test_controlfreec_makegraph + command: nextflow run tests/modules/controlfreec/makegraph -entry test_controlfreec_makegraph -c tests/config/nextflow.config + tags: + - controlfreec + - controlfreec/makegraph + files: + - path: output/controlfreec/test_BAF.png + md5sum: f9d977839e09c7e2472d970bd4aa834c + - path: output/controlfreec/test_ratio.log2.png + md5sum: b3c7916b1b4951a0cc3da20d8e9e0262 + - path: output/controlfreec/test_ratio.png + md5sum: 1435b29536b3b1555b4c423f8f4fb000