diff --git a/modules/genrich/main.nf b/modules/genrich/main.nf index c947e9cf..f34f9cd2 100644 --- a/modules/genrich/main.nf +++ b/modules/genrich/main.nf @@ -22,6 +22,10 @@ process GENRICH { tuple val(meta), path(treatment_bam) path control_bam path blacklist_bed + val save_pvalues + val save_pileup + val save_bed + val save_duplicates output: tuple val(meta), path("*narrowPeak") , emit: peaks @@ -32,14 +36,14 @@ process GENRICH { path "versions.yml" , emit: versions script: - def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" - def control = params.control_bam ? "-c $control_bam" : '' - def pvalues = params.pvalues ? "-f ${prefix}.pvalues.bedGraph" : "" - def pileup = params.pileup ? "-k ${prefix}.pileup.bedGraph" : "" - def bed = params.bed ? "-b ${prefix}.intervals.bed" : "" - def blacklist = params.blacklist_bed ? "-E $blacklist_bed" : "" + def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" + def control = control_bam ? "-c $control_bam" : '' + def blacklist = blacklist_bed ? "-E $blacklist_bed" : "" + def pvalues = save_pvalues ? "-f ${prefix}.pvalues.bedGraph" : "" + def pileup = save_pileup ? "-k ${prefix}.pileup.bedGraph" : "" + def bed = save_bed ? "-b ${prefix}.intervals.bed" : "" def duplicates = "" - if (params.save_duplicates) { + if (save_duplicates) { if (options.args.contains('-r')) { duplicates = "-R ${prefix}.duplicates.txt" } else { @@ -58,7 +62,6 @@ process GENRICH { $pileup \\ $bed \\ $duplicates \\ - $blacklist \\ $control cat <<-END_VERSIONS > versions.yml diff --git a/modules/genrich/meta.yml b/modules/genrich/meta.yml index 8f7b004b..37184190 100644 --- a/modules/genrich/meta.yml +++ b/modules/genrich/meta.yml @@ -15,7 +15,6 @@ tools: tool_dev_url: https://github.com/jsh58/Genrich doi: "" licence: ['MIT'] - input: - meta: type: map @@ -34,7 +33,18 @@ input: type: file description: Bed file containing genomic intervals to exclude from the analysis pattern: "*.{bed}" - + - save_pvalues: + type: boolean + description: Create bedgraph-ish file for p/q-values file + - save_pileup: + type: boolean + description: Create bedgraph-ish file for pileups and p-values + - save_bed: + type: boolean + description: Create BED file for reads/fragments/intervals + - save_duplicates: + type: boolean + description: Create PCR duplicates file (only works if -r option is set) output: - meta: type: map @@ -65,7 +75,6 @@ output: type: file description: File containing software version pattern: "*.{version.txt}" - authors: - "@JoseEspinosa" diff --git a/tests/modules/genrich/main.nf b/tests/modules/genrich/main.nf index 654b38e5..aa1a2d49 100644 --- a/tests/modules/genrich/main.nf +++ b/tests/modules/genrich/main.nf @@ -2,10 +2,10 @@ nextflow.enable.dsl = 2 -include { GENRICH } from '../../../modules/genrich/main.nf' addParams( control_bam: false, pvalues: false, pileup:false, bed:false, blacklist_bed:false, save_duplicates:false, options: ["args": "-p 0.1"] ) -include { GENRICH as GENRICH_BLACKLIST } from '../../../modules/genrich/main.nf' addParams( control_bam: false, pvalues: false, pileup:false, bed:false, blacklist_bed:true, save_duplicates:false, options: ["args": "-p 0.1"] ) -include { GENRICH as GENRICH_ALL_OUTPUTS } from '../../../modules/genrich/main.nf' addParams( control_bam: false, pvalues: true, pileup:true, bed:true, blacklist_bed:false, save_duplicates:true, options: ["args": "-r -p 0.1"] ) -include { GENRICH as GENRICH_ATACSEQ } from '../../../modules/genrich/main.nf' addParams( control_bam: false, pvalues: false, pileup:false, bed:false, blacklist_bed:false, save_duplicates:false, options: ["args": "-j -p 0.1"] ) +include { GENRICH } from '../../../modules/genrich/main.nf' addParams( options: ["args": "-p 0.1"] ) +include { GENRICH as GENRICH_CTRL } from '../../../modules/genrich/main.nf' addParams( options: ["args": "-p 0.9"] ) +include { GENRICH as GENRICH_ALL } from '../../../modules/genrich/main.nf' addParams( options: ["args": "-r -p 0.1"] ) +include { GENRICH as GENRICH_ATACSEQ } from '../../../modules/genrich/main.nf' addParams( options: ["args": "-j -p 0.1"] ) workflow test_genrich { input = [ [ id:'test', single_end:false ], // meta map @@ -13,7 +13,12 @@ workflow test_genrich { control = [ ] blacklist = [ ] - GENRICH ( input, control, blacklist ) + save_pvalues = false + save_pileup = false + save_bed = false + save_duplicates = false + + GENRICH ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) } workflow test_genrich_ctrl { @@ -22,7 +27,12 @@ workflow test_genrich_ctrl { control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ] blacklist = [ ] - GENRICH ( input, control, blacklist ) + save_pvalues = false + save_pileup = false + save_bed = false + save_duplicates = false + + GENRICH_CTRL ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) } workflow test_genrich_all_outputs { @@ -31,14 +41,39 @@ workflow test_genrich_all_outputs { control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ] blacklist = [ ] - GENRICH_ALL_OUTPUTS ( input, control, blacklist ) + save_pvalues = true + save_pileup = true + save_bed = true + save_duplicates = true + + GENRICH_ALL ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) +} + +workflow test_genrich_blacklist { + input = [ [ id:'test', single_end:false ], // meta map + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] + control = [ ] + blacklist = [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)] + + save_pvalues = false + save_pileup = false + save_bed = false + save_duplicates = false + + GENRICH ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) } workflow test_genrich_atacseq { input = [ [ id:'test', single_end:false ], // meta map [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] - control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ] + control = [ ] blacklist = [ ] - GENRICH_ATACSEQ ( input, control, blacklist ) + save_pvalues = false + save_pileup = false + save_bed = false + save_duplicates = false + + GENRICH_ATACSEQ ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) } + diff --git a/tests/modules/genrich/test.yml b/tests/modules/genrich/test.yml index bd762f7c..63bf2927 100644 --- a/tests/modules/genrich/test.yml +++ b/tests/modules/genrich/test.yml @@ -12,7 +12,7 @@ - genrich files: - path: output/genrich/test.narrowPeak - md5sum: 6afabdd3f691c7c84c66ff8a23984681 + md5sum: 2fcc392360b317f5ebee88cdbc149e05 - name: genrich test_genrich_all_outputs command: nextflow run tests/modules/genrich -entry test_genrich_all_outputs -c tests/config/nextflow.config @@ -20,15 +20,23 @@ - genrich files: - path: output/genrich/test.duplicates.txt - md5sum: a92893f905fd8b3751bc6a960fbfe7ba + md5sum: 159d557af7c23bc3cfb802d87fa96c34 - path: output/genrich/test.intervals.bed - md5sum: 52edf47e6641c0cc03f9cca7324f7eaa + md5sum: 4bea65caa3f4043d703af4b57161112e - path: output/genrich/test.narrowPeak - md5sum: e45eb7d000387975050c2e85c164e5be + md5sum: d41d8cd98f00b204e9800998ecf8427e - path: output/genrich/test.pileup.bedGraph - md5sum: e4f7fa664cd4ed2cf3a1a3a9eb415e71 + md5sum: 03e53848de695b5794f32f15b2709203 - path: output/genrich/test.pvalues.bedGraph - md5sum: 564859953704983393d4b7d6317060cd + md5sum: b14feef34b6d2379a173a734ca963cde + +- name: genrich test_genrich_blacklist + command: nextflow run tests/modules/genrich -entry test_genrich_blacklist -c tests/config/nextflow.config + tags: + - genrich + files: + - path: output/genrich/test.narrowPeak + md5sum: 6afabdd3f691c7c84c66ff8a23984681 - name: genrich test_genrich_atacseq command: nextflow run tests/modules/genrich -entry test_genrich_atacseq -c tests/config/nextflow.config