From 4f981058f29dd679d36abf7a17a8fb18a3718109 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 21 Nov 2023 16:43:30 -0500 Subject: [PATCH 01/47] feat: add consensus peaks process [wip] --- modules/CCBR/custom/consensuspeaks/main.nf | 37 +++++++ modules/CCBR/custom/consensuspeaks/meta.yml | 55 +++++++++ .../templates/get_consensus_peaks.py | 104 ++++++++++++++++++ tests/config/pytest_modules.yml | 4 + .../CCBR/custom/consensuspeaks/main.nf | 15 +++ .../custom/consensuspeaks/nextflow.config | 5 + .../CCBR/custom/consensuspeaks/test.yml | 12 ++ 7 files changed, 232 insertions(+) create mode 100644 modules/CCBR/custom/consensuspeaks/main.nf create mode 100644 modules/CCBR/custom/consensuspeaks/meta.yml create mode 100755 modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py create mode 100644 tests/modules/CCBR/custom/consensuspeaks/main.nf create mode 100644 tests/modules/CCBR/custom/consensuspeaks/nextflow.config create mode 100644 tests/modules/CCBR/custom/consensuspeaks/test.yml diff --git a/modules/CCBR/custom/consensuspeaks/main.nf b/modules/CCBR/custom/consensuspeaks/main.nf new file mode 100644 index 0000000..345ca67 --- /dev/null +++ b/modules/CCBR/custom/consensuspeaks/main.nf @@ -0,0 +1,37 @@ +process CUSTOM_CONSENSUSPEAKS { + tag "${meta.id}.${meta.group}" + label 'process_single' + + container 'nciccbr/ccbr_ucsc:v1' + + input: + tuple val(meta), path(peaks) + + output: + // TODO nf-core: Named file extensions MUST be emitted for ALL output channels + tuple val(meta), path("*.consensus_peaks.bed"), emit: peaks + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + peakfiles = "${peaks.join(' ')}" + outbed = "${meta.id}.${meta.group}.consensus_peaks.bed" + filter = 0.5 + nofilter = false + if (peaks.size() > 1) { + template 'get_consensus_peaks.py' + } else { // just copy the input if there's only one peak file + """ + cp ${peakfiles} ${outbed} + """ + } + + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.bed versions.yml + """ +} diff --git a/modules/CCBR/custom/consensuspeaks/meta.yml b/modules/CCBR/custom/consensuspeaks/meta.yml new file mode 100644 index 0000000..8477c5a --- /dev/null +++ b/modules/CCBR/custom/consensuspeaks/meta.yml @@ -0,0 +1,55 @@ +--- +name: "custom_consensuspeaks" +## TODO nf-core: Add a description of the module and list keywords +description: write your description here +keywords: + - peaks + - chipseq + - normalization + - consensus +tools: + - "custom": + ## TODO nf-core: Add a description and other details for the software below + description: "" + homepage: "" + documentation: "" + tool_dev_url: "" + doi: "" + licence: "" + +## TODO nf-core: Add a description of all of the variables used as input +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + ## TODO nf-core: Delete / customise this example input + - bam: + type: file + description: Sorted BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +## TODO nf-core: Add a description of all of the variables used as output +output: + #Only when we have meta + - 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" + ## TODO nf-core: Delete / customise this example output + - bam: + type: file + description: Sorted BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +authors: + - "@kelly-sovacool" diff --git a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py new file mode 100755 index 0000000..c0edf28 --- /dev/null +++ b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +""" +adapted from https://github.com/CCBR/ASPEN/blob/55f909d76500c3502c1c397ef3000908649b0284/workflow/scripts/ccbr_get_consensus_peaks.py +""" +import os +import uuid +import pandas + + +def main(peakfiles, outbed, filter, nofilter): + deleteFiles = [] + + rand_name = str(uuid.uuid4()) + + # concat + cmd = "cat" + for p in peakfiles: + cmd += " " + p + cmd += " | cut -f1-3 > " + rand_name + ".concat.bed" + + deleteFiles.append(rand_name + ".concat.bed") + print(cmd) + os.system(cmd) + + # sort and merge + cmd = ( + "bedSort " + + rand_name + + ".concat.bed " + + rand_name + + ".concat.bed && bedtools merge -i " + + rand_name + + ".concat.bed > " + + rand_name + + ".merged.bed" + ) + + deleteFiles.append(rand_name + ".merged.bed") + print(cmd) + os.system(cmd) + + # check merged count + npeaks = len(open(rand_name + ".merged.bed").readlines()) + if npeaks == 0: + exit("Number of merged peaks = 0") + + count = 0 + for p in peakfiles: + count += 1 + sortedfile = p + ".sorted." + rand_name + countfile = p + ".counts." + rand_name + cmd = ( + "cut -f1-3 " + + p + + " > " + + sortedfile + + " && bedSort " + + sortedfile + + " " + + sortedfile + ) + print(cmd) + os.system(cmd) + cmd = ( + "bedmap --delim '\t' --echo-ref-name --count " + + rand_name + + ".merged.bed " + + sortedfile + + "|awk -F'\t' -v OFS='\t' '{if ($2>1){$2=1}{print}}' > " + + countfile + ) + print(cmd) + os.system(cmd) + deleteFiles.append(countfile) + deleteFiles.append(sortedfile) + if count == 1: + df = pandas.read_csv(countfile, delimiter="\t") + df.columns = ["peakid", countfile] + else: + dfx = pandas.read_csv(countfile, delimiter="\t") + dfx.columns = ["peakid", countfile] + df = df.merge(dfx, on="peakid") + + df = df.set_index("peakid") + df = df.sum(axis=1) / len(df.columns) + df = pandas.DataFrame({"peakid": df.index, "score": df.values}) + + with open(outbed, "w") as out: + for index, row in df.iterrows(): + chrom, coords = row["peakid"].split(":") + start, end = coords.split("-") + if nofilter or float(row["score"]) > filter: + out.write( + "%s\t%s\t%s\t%s\t%.3f\t.\tNA\tNA\tNA\n" + % (chrom, start, end, row["peakid"], float(row["score"])) + ) + + for f in deleteFiles: + os.remove(f) + + +if __name__ == "__main__": + # arguments filled in via nextflow template + main("${peakfiles}".split(), "${outbed}", float("${filter}"), bool("${nofilter}")) diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 773b44c..682aafe 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -10,6 +10,10 @@ custom/bam2fastq: - modules/CCBR/custom/bam2fastq/** - tests/modules/CCBR/custom/bam2fastq/** +custom/consensuspeaks: + - modules/CCBR/custom/consensuspeaks/** + - tests/modules/CCBR/custom/consensuspeaks/** + custom/countfastq: - modules/CCBR/custom/countfastq/** - tests/modules/CCBR/custom/countfastq/** diff --git a/tests/modules/CCBR/custom/consensuspeaks/main.nf b/tests/modules/CCBR/custom/consensuspeaks/main.nf new file mode 100644 index 0000000..f7bbbf9 --- /dev/null +++ b/tests/modules/CCBR/custom/consensuspeaks/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CUSTOM_CONSENSUSPEAKS } from '../../../../../modules/CCBR/custom/consensuspeaks/main.nf' + +workflow test_custom_consensuspeaks { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + + CUSTOM_CONSENSUSPEAKS ( input ) +} diff --git a/tests/modules/CCBR/custom/consensuspeaks/nextflow.config b/tests/modules/CCBR/custom/consensuspeaks/nextflow.config new file mode 100644 index 0000000..8730f1c --- /dev/null +++ b/tests/modules/CCBR/custom/consensuspeaks/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/CCBR/custom/consensuspeaks/test.yml b/tests/modules/CCBR/custom/consensuspeaks/test.yml new file mode 100644 index 0000000..72f775d --- /dev/null +++ b/tests/modules/CCBR/custom/consensuspeaks/test.yml @@ -0,0 +1,12 @@ +## TODO nf-core: Please run the following command to build this file: +# nf-core modules create-test-yml /consensuspeaks +- name: "custom consensuspeaks" + command: nextflow run ./tests/modules/CCBR/custom/consensuspeaks -entry test_custom_consensuspeaks -c ./tests/config/nextflow.config + tags: + - "custom" + - "custom/consensuspeaks" + files: + - path: "output/custom/test.bam" + md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: "output/custom/versions.yml" + md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b From f0360dd446053cd05cb9ca9cf56e8db1f9f6ca7e Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 09:47:16 -0500 Subject: [PATCH 02/47] fix: escape backslashes for nextflow template script --- .../consensuspeaks/templates/get_consensus_peaks.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py index c0edf28..4a6dc18 100755 --- a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py +++ b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py @@ -62,11 +62,11 @@ def main(peakfiles, outbed, filter, nofilter): print(cmd) os.system(cmd) cmd = ( - "bedmap --delim '\t' --echo-ref-name --count " + "bedmap --delim '\\t' --echo-ref-name --count " + rand_name + ".merged.bed " + sortedfile - + "|awk -F'\t' -v OFS='\t' '{if ($2>1){$2=1}{print}}' > " + + "|awk -F'\\t' -v OFS='\\t' '{if ($2>1){$2=1}{print}}' > " + countfile ) print(cmd) @@ -74,10 +74,10 @@ def main(peakfiles, outbed, filter, nofilter): deleteFiles.append(countfile) deleteFiles.append(sortedfile) if count == 1: - df = pandas.read_csv(countfile, delimiter="\t") + df = pandas.read_csv(countfile, delimiter="\\t") df.columns = ["peakid", countfile] else: - dfx = pandas.read_csv(countfile, delimiter="\t") + dfx = pandas.read_csv(countfile, delimiter="\\t") dfx.columns = ["peakid", countfile] df = df.merge(dfx, on="peakid") @@ -91,7 +91,7 @@ def main(peakfiles, outbed, filter, nofilter): start, end = coords.split("-") if nofilter or float(row["score"]) > filter: out.write( - "%s\t%s\t%s\t%s\t%.3f\t.\tNA\tNA\tNA\n" + "%s\\t%s\\t%s\\t%s\\t%.3f\\t.\\tNA\\tNA\\tNA\\n" % (chrom, start, end, row["peakid"], float(row["score"])) ) From 18ff6af698973fd6013796e5d25edb6c2a075524 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 10:36:37 -0500 Subject: [PATCH 03/47] fix: escape dollar signs for nf template --- .../CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py index 4a6dc18..8ca5034 100755 --- a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py +++ b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py @@ -66,7 +66,7 @@ def main(peakfiles, outbed, filter, nofilter): + rand_name + ".merged.bed " + sortedfile - + "|awk -F'\\t' -v OFS='\\t' '{if ($2>1){$2=1}{print}}' > " + + "|awk -F'\\t' -v OFS='\\t' '{if (\$2>1){\$2=1}{print}}' > " + countfile ) print(cmd) From 5e6f65dd40e2b1e08eca366eec2988efa1795ed0 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 10:37:20 -0500 Subject: [PATCH 04/47] test: use macs2 peaks as test data --- tests/modules/CCBR/custom/consensuspeaks/main.nf | 6 ++++-- tests/modules/CCBR/custom/consensuspeaks/nextflow.config | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/modules/CCBR/custom/consensuspeaks/main.nf b/tests/modules/CCBR/custom/consensuspeaks/main.nf index f7bbbf9..0b33660 100644 --- a/tests/modules/CCBR/custom/consensuspeaks/main.nf +++ b/tests/modules/CCBR/custom/consensuspeaks/main.nf @@ -7,8 +7,10 @@ include { CUSTOM_CONSENSUSPEAKS } from '../../../../../modules/CCBR/custom/conse workflow test_custom_consensuspeaks { input = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + [ id: 'test', group: 'macs_broad' ], // meta map + [ file(params.test_data['macs_peaks_1'], checkIfExists: true), + file(params.test_data['macs_peaks_2'], checkIfExists: true), + ] ] CUSTOM_CONSENSUSPEAKS ( input ) diff --git a/tests/modules/CCBR/custom/consensuspeaks/nextflow.config b/tests/modules/CCBR/custom/consensuspeaks/nextflow.config index 8730f1c..a652b2d 100644 --- a/tests/modules/CCBR/custom/consensuspeaks/nextflow.config +++ b/tests/modules/CCBR/custom/consensuspeaks/nextflow.config @@ -3,3 +3,5 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } } + +includeConfig '../../../../config/test_data_CCBR.config' From d7b2f07577cdbe200cdc0f3dc01a715432974e0b Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 10:53:23 -0500 Subject: [PATCH 05/47] fix: metadata for consensuspeaks --- modules/CCBR/custom/consensuspeaks/main.nf | 2 +- modules/CCBR/custom/consensuspeaks/meta.yml | 55 ++++++++++++--------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/modules/CCBR/custom/consensuspeaks/main.nf b/modules/CCBR/custom/consensuspeaks/main.nf index 345ca67..3a08bad 100644 --- a/modules/CCBR/custom/consensuspeaks/main.nf +++ b/modules/CCBR/custom/consensuspeaks/main.nf @@ -8,7 +8,6 @@ process CUSTOM_CONSENSUSPEAKS { tuple val(meta), path(peaks) output: - // TODO nf-core: Named file extensions MUST be emitted for ALL output channels tuple val(meta), path("*.consensus_peaks.bed"), emit: peaks path "versions.yml" , emit: versions @@ -25,6 +24,7 @@ process CUSTOM_CONSENSUSPEAKS { } else { // just copy the input if there's only one peak file """ cp ${peakfiles} ${outbed} + touch versions.yml """ } diff --git a/modules/CCBR/custom/consensuspeaks/meta.yml b/modules/CCBR/custom/consensuspeaks/meta.yml index 8477c5a..4c86fa5 100644 --- a/modules/CCBR/custom/consensuspeaks/meta.yml +++ b/modules/CCBR/custom/consensuspeaks/meta.yml @@ -1,55 +1,62 @@ --- name: "custom_consensuspeaks" -## TODO nf-core: Add a description of the module and list keywords -description: write your description here +description: Find consensus peaks from two or more peak files. keywords: - peaks - chipseq - normalization - consensus tools: - - "custom": - ## TODO nf-core: Add a description and other details for the software below - description: "" - homepage: "" - documentation: "" - tool_dev_url: "" - doi: "" - licence: "" + - Python: + description: | + The Python Programming Language + homepage: https://www.python.org/ + licence: ["Python License 2.0"] + - bedtools: + description: | + A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types. + documentation: https://bedtools.readthedocs.io/ + licence: ["MIT"] + - bedops: + description: | + fast, highly scalable and easily-parallelizable genome analysis toolkit + documentation: https://bedops.readthedocs.io/ + tool_dev_url: https://github.com/bedops/bedops + licence: ["GPLv2"] + doi: 10.1093/bioinformatics/bts277 + - bedSort: + description: | + UCSC Genome Browser tool for sorting .bed files by chrom,chromStart. + documentation: https://www.encodeproject.org/software/bedsort/ -## TODO nf-core: Add a description of all of the variables used as input input: - # Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - ## TODO nf-core: Delete / customise this example input - - bam: + - peaks: type: file - description: Sorted BAM/CRAM/SAM file - pattern: "*.{bam,cram,sam}" + description: Peak files + pattern: "*.{broadPeak,narrowPeak,bed}" -## TODO nf-core: Add a description of all of the variables used as output output: - #Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - + - peaks: + type: file + description: A single consensus peak file + pattern: "*.{broadPeak,narrowPeak,bed}" - versions: type: file description: File containing software versions pattern: "versions.yml" - ## TODO nf-core: Delete / customise this example output - - bam: - type: file - description: Sorted BAM/CRAM/SAM file - pattern: "*.{bam,cram,sam}" authors: - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" From 1a5554b1b8e8638f0b9ab181285bd269cd5d85b9 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 11:28:19 -0500 Subject: [PATCH 06/47] test: add real md5sums for custom/consensuspeaks --- tests/modules/CCBR/custom/consensuspeaks/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/modules/CCBR/custom/consensuspeaks/test.yml b/tests/modules/CCBR/custom/consensuspeaks/test.yml index 72f775d..4161ee4 100644 --- a/tests/modules/CCBR/custom/consensuspeaks/test.yml +++ b/tests/modules/CCBR/custom/consensuspeaks/test.yml @@ -6,7 +6,6 @@ - "custom" - "custom/consensuspeaks" files: - - path: "output/custom/test.bam" - md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: "output/custom/test.macs_broad.consensus_peaks.bed" + md5sum: 4d684a948335bbed948704e4be9f1abe - path: "output/custom/versions.yml" - md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b From 3aca9c5126cf0113ba4cbe1d6927d1d845fda40f Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 11:39:44 -0500 Subject: [PATCH 07/47] fix: meta syntax --- modules/CCBR/custom/consensuspeaks/meta.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/CCBR/custom/consensuspeaks/meta.yml b/modules/CCBR/custom/consensuspeaks/meta.yml index 4c86fa5..52fa43e 100644 --- a/modules/CCBR/custom/consensuspeaks/meta.yml +++ b/modules/CCBR/custom/consensuspeaks/meta.yml @@ -25,9 +25,9 @@ tools: licence: ["GPLv2"] doi: 10.1093/bioinformatics/bts277 - bedSort: - description: | - UCSC Genome Browser tool for sorting .bed files by chrom,chromStart. - documentation: https://www.encodeproject.org/software/bedsort/ + description: | + UCSC Genome Browser tool for sorting .bed files by chrom,chromStart. + documentation: https://www.encodeproject.org/software/bedsort/ input: - meta: From c538767391c3cea4bb3f4c4a0bbe746f3af0fc29 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 11:41:31 -0500 Subject: [PATCH 08/47] fix: write versions --- .../custom/consensuspeaks/templates/get_consensus_peaks.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py index 8ca5034..1a0ee4b 100755 --- a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py +++ b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py @@ -99,6 +99,13 @@ def main(peakfiles, outbed, filter, nofilter): os.remove(f) +def write_versions(): + with open("versions.yml", "w") as outfile: + outfile.write('"${task.process}":\\n') + outfile.write(f' Python: "{platform.python_version()}"\\n') + + if __name__ == "__main__": + write_versions() # arguments filled in via nextflow template main("${peakfiles}".split(), "${outbed}", float("${filter}"), bool("${nofilter}")) From 861460f9ccbc0f6a262018545327c6a5fd74e664 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 11:54:03 -0500 Subject: [PATCH 09/47] feat: adapt bedtools modules from nf-core --- modules/CCBR/bedtools/map/main.nf | 58 +++++++++++++++++++ modules/CCBR/bedtools/map/meta.yml | 53 +++++++++++++++++ modules/CCBR/bedtools/merge/main.nf | 47 +++++++++++++++ modules/CCBR/bedtools/merge/meta.yml | 41 +++++++++++++ modules/CCBR/bedtools/sort/main.nf | 54 +++++++++++++++++ modules/CCBR/bedtools/sort/meta.yml | 50 ++++++++++++++++ tests/config/pytest_modules.yml | 12 ++++ tests/modules/CCBR/bedtools/map/main.nf | 27 +++++++++ .../modules/CCBR/bedtools/map/nextflow.config | 13 +++++ tests/modules/CCBR/bedtools/map/test.yml | 21 +++++++ tests/modules/CCBR/bedtools/merge/main.nf | 13 +++++ .../CCBR/bedtools/merge/nextflow.config | 9 +++ tests/modules/CCBR/bedtools/merge/test.yml | 8 +++ tests/modules/CCBR/bedtools/sort/main.nf | 22 +++++++ .../CCBR/bedtools/sort/nextflow.config | 10 ++++ tests/modules/CCBR/bedtools/sort/test.yml | 19 ++++++ 16 files changed, 457 insertions(+) create mode 100644 modules/CCBR/bedtools/map/main.nf create mode 100644 modules/CCBR/bedtools/map/meta.yml create mode 100644 modules/CCBR/bedtools/merge/main.nf create mode 100644 modules/CCBR/bedtools/merge/meta.yml create mode 100644 modules/CCBR/bedtools/sort/main.nf create mode 100644 modules/CCBR/bedtools/sort/meta.yml create mode 100644 tests/modules/CCBR/bedtools/map/main.nf create mode 100644 tests/modules/CCBR/bedtools/map/nextflow.config create mode 100644 tests/modules/CCBR/bedtools/map/test.yml create mode 100644 tests/modules/CCBR/bedtools/merge/main.nf create mode 100644 tests/modules/CCBR/bedtools/merge/nextflow.config create mode 100644 tests/modules/CCBR/bedtools/merge/test.yml create mode 100644 tests/modules/CCBR/bedtools/sort/main.nf create mode 100644 tests/modules/CCBR/bedtools/sort/nextflow.config create mode 100644 tests/modules/CCBR/bedtools/sort/test.yml diff --git a/modules/CCBR/bedtools/map/main.nf b/modules/CCBR/bedtools/map/main.nf new file mode 100644 index 0000000..846d5ba --- /dev/null +++ b/modules/CCBR/bedtools/map/main.nf @@ -0,0 +1,58 @@ +process BEDTOOLS_MAP { + tag "$meta.id" + label 'process_single' + + conda "bioconda::bedtools=2.31.0" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bedtools:2.31.0--hf5e1c6e_2' : + 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' }" + + input: + tuple val(meta), path(intervals1), path(intervals2) + tuple val(meta2), path(chrom_sizes) + + output: + tuple val(meta), path("*.${extension}"), emit: map + 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}" + extension = intervals1.getExtension() + def sizes = chrom_sizes ? "-g ${chrom_sizes}" : '' + if ("$intervals1" == "${prefix}.${extension}" || + "$intervals2" == "${prefix}.${extension}") + error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + bedtools \\ + map \\ + -a $intervals1 \\ + -b $intervals2 \\ + $args \\ + $sizes \\ + > ${prefix}.${extension} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + extension = intervals1.getExtension() + if ("$intervals1" == "${prefix}.${extension}" || + "$intervals2" == "${prefix}.${extension}") + error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + touch ${prefix}.${extension} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ +} diff --git a/modules/CCBR/bedtools/map/meta.yml b/modules/CCBR/bedtools/map/meta.yml new file mode 100644 index 0000000..51f4fdc --- /dev/null +++ b/modules/CCBR/bedtools/map/meta.yml @@ -0,0 +1,53 @@ +name: bedtools_map +description: Allows one to screen for overlaps between two sets of genomic features. Adapted from https://github.com/nf-core/modules/tree/fff2c3fc7cdcb81a2a37c3263b8ace9b353af407/modules/nf-core/bedtools +keywords: + - bed + - vcf + - gff + - map + - bedtools +tools: + - bedtools: + description: | + A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types. + documentation: https://bedtools.readthedocs.io/en/latest/content/tools/map.html + licence: ["MIT"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - intervals1: + type: file + description: BAM/BED/GFF/VCF + pattern: "*.{bed|gff|vcf}" + - intervals2: + type: file + description: BAM/BED/GFF/VCF + pattern: "*.{bed|gff|vcf}" + - meta2: + type: map + description: | + Groovy Map containing reference chromosome sizes + e.g. [ id:'test' ] + - chrom_sizes: + type: file + description: Chromosome sizes file + pattern: "*{.sizes,.txt}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - map: + type: file + description: File containing the description of overlaps found between the features in A and the features in B, with statistics + pattern: "*.${extension}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@ekushele" diff --git a/modules/CCBR/bedtools/merge/main.nf b/modules/CCBR/bedtools/merge/main.nf new file mode 100644 index 0000000..6868d39 --- /dev/null +++ b/modules/CCBR/bedtools/merge/main.nf @@ -0,0 +1,47 @@ +process BEDTOOLS_MERGE { + tag "$meta.id" + label 'process_single' + + conda "bioconda::bedtools=2.31.0" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bedtools:2.31.0--hf5e1c6e_2' : + 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' }" + + input: + tuple val(meta), path(bed) + + output: + tuple val(meta), path('*.bed'), emit: bed + 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}" + if ("$bed" == "${prefix}.bed") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + """ + bedtools \\ + merge \\ + -i $bed \\ + $args \\ + > ${prefix}.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ +} diff --git a/modules/CCBR/bedtools/merge/meta.yml b/modules/CCBR/bedtools/merge/meta.yml new file mode 100644 index 0000000..ee8e165 --- /dev/null +++ b/modules/CCBR/bedtools/merge/meta.yml @@ -0,0 +1,41 @@ +name: bedtools_merge +description: combines overlapping or “book-ended” features in an interval file into a single feature which spans all of the combined features. Adapted from https://github.com/nf-core/modules/tree/fff2c3fc7cdcb81a2a37c3263b8ace9b353af407/modules/nf-core/bedtools +keywords: + - bed + - merge + - bedtools + - overlapped bed +tools: + - bedtools: + description: | + A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types. + documentation: https://bedtools.readthedocs.io/en/latest/content/tools/merge.html + licence: ["MIT"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bed: + type: file + description: Input BED file + pattern: "*.{bed}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - bed: + type: file + description: Overlapped bed file with combined features + pattern: "*.{bed}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@Emiller88" + - "@sruthipsuresh" + - "@drpatelh" diff --git a/modules/CCBR/bedtools/sort/main.nf b/modules/CCBR/bedtools/sort/main.nf new file mode 100644 index 0000000..df372bc --- /dev/null +++ b/modules/CCBR/bedtools/sort/main.nf @@ -0,0 +1,54 @@ +process BEDTOOLS_SORT { + tag "$meta.id" + label 'process_single' + + conda "bioconda::bedtools=2.31.0" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bedtools:2.31.0--hf5e1c6e_2' : + 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' }" + + input: + tuple val(meta), path(intervals) + path genome_file + + output: + tuple val(meta), path("*.${extension}"), emit: sorted + 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 genome_cmd = genome_file ? "-g $genome_file" : "" + extension = task.ext.suffix ?: intervals.extension + if ("$intervals" == "${prefix}.${extension}") { + error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" + } + """ + bedtools \\ + sort \\ + -i $intervals \\ + $genome_cmd \\ + $args \\ + > ${prefix}.${extension} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + extension = task.ext.suffix ?: intervals.extension + """ + touch ${prefix}.${extension} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedtools: \$(bedtools --version | sed -e "s/bedtools v//g") + END_VERSIONS + """ +} diff --git a/modules/CCBR/bedtools/sort/meta.yml b/modules/CCBR/bedtools/sort/meta.yml new file mode 100644 index 0000000..80c16f3 --- /dev/null +++ b/modules/CCBR/bedtools/sort/meta.yml @@ -0,0 +1,50 @@ +name: bedtools_sort +description: Sorts a feature file by chromosome and other criteria. Adapted from https://github.com/nf-core/modules/tree/fff2c3fc7cdcb81a2a37c3263b8ace9b353af407/modules/nf-core/bedtools +keywords: + - bed + - sort + - bedtools + - chromosome +tools: + - bedtools: + description: | + A set of tools for genomic analysis tasks, specifically enabling genome arithmetic (merge, count, complement) on various file types. + documentation: https://bedtools.readthedocs.io/en/latest/content/tools/sort.html + licence: ["MIT"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - intervals: + type: file + description: BED/BEDGRAPH + pattern: "*.{bed|bedGraph}" + - genome_file: + type: file + description: | + Optional reference genome 2 column file that defines the expected chromosome order. + pattern: "*.{fai,txt,chromsizes}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + + - sorted: + type: file + description: Sorted output file + pattern: "*.${extension}" + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@Emiller88" + - "@sruthipsuresh" + - "@drpatelh" + - "@chris-cheshire" + - "@adamrtalbot" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index b866f18..05d3f2f 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1,3 +1,15 @@ +bedtools/map: + - modules/CCBR/bedtools/map/** + - tests/modules/CCBR/bedtools/map/** + +bedtools/merge: + - modules/CCBR/bedtools/merge/** + - tests/modules/CCBR/bedtools/merge/** + +bedtools/sort: + - modules/CCBR/bedtools/sort/** + - tests/modules/CCBR/bedtools/sort/** + bwa/index: - modules/CCBR/bwa/index/** - tests/modules/CCBR/bwa/index/** diff --git a/tests/modules/CCBR/bedtools/map/main.nf b/tests/modules/CCBR/bedtools/map/main.nf new file mode 100644 index 0000000..0d42cac --- /dev/null +++ b/tests/modules/CCBR/bedtools/map/main.nf @@ -0,0 +1,27 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BEDTOOLS_MAP } from '../../../../../modules/nf-core/bedtools/map/main.nf' +include { BEDTOOLS_MAP as BEDTOOLS_MAP_VCF } from '../../../../../modules/nf-core/bedtools/map/main.nf' + +workflow test_bedtools_map { + input = [ + [ id:'test' ], + file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true), + file(params.test_data['sarscov2']['genome']['test2_bed'], checkIfExists: true) + ] + + + BEDTOOLS_MAP ( input, [[:],[]] ) +} + +workflow test_bedtools_map_vcf { + input = [ + [ id:'test' ], + file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_vcf'], checkIfExists: true) + ] + + BEDTOOLS_MAP_VCF ( input, [[:],[]] ) +} diff --git a/tests/modules/CCBR/bedtools/map/nextflow.config b/tests/modules/CCBR/bedtools/map/nextflow.config new file mode 100644 index 0000000..730638c --- /dev/null +++ b/tests/modules/CCBR/bedtools/map/nextflow.config @@ -0,0 +1,13 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: BEDTOOLS_MAP { + ext.prefix = { "${meta.id}_out" } + } + + withName: BEDTOOLS_MAP_VCF { + ext.prefix = { "${meta.id}_out" } + } + +} diff --git a/tests/modules/CCBR/bedtools/map/test.yml b/tests/modules/CCBR/bedtools/map/test.yml new file mode 100644 index 0000000..e06ddc3 --- /dev/null +++ b/tests/modules/CCBR/bedtools/map/test.yml @@ -0,0 +1,21 @@ +- name: bedtools map test_bedtools_map + command: nextflow run ./tests/modules/nf-core/bedtools/map -entry test_bedtools_map -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/map/nextflow.config + tags: + - bedtools + - bedtools/map + files: + - path: output/bedtools/test_out.bed + md5sum: d3aeb1ec7b90e0d5a6d1b9a4614ab96a + - path: output/bedtools/versions.yml + md5sum: 6c219404bf848cd4bd672a934dd4ed56 + +- name: bedtools map test_bedtools_map_vcf + command: nextflow run ./tests/modules/nf-core/bedtools/map -entry test_bedtools_map_vcf -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/map/nextflow.config + tags: + - bedtools + - bedtools/map + files: + - path: output/bedtools/test_out.bed + md5sum: cabd34d1132834581e31f53dfa66ec03 + - path: output/bedtools/versions.yml + md5sum: ab927c219959af17dc370b0b8eda78bd diff --git a/tests/modules/CCBR/bedtools/merge/main.nf b/tests/modules/CCBR/bedtools/merge/main.nf new file mode 100644 index 0000000..4941193 --- /dev/null +++ b/tests/modules/CCBR/bedtools/merge/main.nf @@ -0,0 +1,13 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BEDTOOLS_MERGE } from '../../../../../modules/nf-core/bedtools/merge/main.nf' + +workflow test_bedtools_merge { + input = [ [ id:'test'], + file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) + ] + + BEDTOOLS_MERGE ( input ) +} diff --git a/tests/modules/CCBR/bedtools/merge/nextflow.config b/tests/modules/CCBR/bedtools/merge/nextflow.config new file mode 100644 index 0000000..545a523 --- /dev/null +++ b/tests/modules/CCBR/bedtools/merge/nextflow.config @@ -0,0 +1,9 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: BEDTOOLS_MERGE { + ext.prefix = { "${meta.id}_out" } + } + +} diff --git a/tests/modules/CCBR/bedtools/merge/test.yml b/tests/modules/CCBR/bedtools/merge/test.yml new file mode 100644 index 0000000..bee9b75 --- /dev/null +++ b/tests/modules/CCBR/bedtools/merge/test.yml @@ -0,0 +1,8 @@ +- name: bedtools merge + command: nextflow run ./tests/modules/nf-core/bedtools/merge -entry test_bedtools_merge -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/merge/nextflow.config + tags: + - bedtools + - bedtools/merge + files: + - path: ./output/bedtools/test_out.bed + md5sum: 0cf6ed2b6f470cd44a247da74ca4fe4e diff --git a/tests/modules/CCBR/bedtools/sort/main.nf b/tests/modules/CCBR/bedtools/sort/main.nf new file mode 100644 index 0000000..0cf0daf --- /dev/null +++ b/tests/modules/CCBR/bedtools/sort/main.nf @@ -0,0 +1,22 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BEDTOOLS_SORT } from '../../../../../modules/nf-core/bedtools/sort/main.nf' + +workflow test_bedtools_sort { + input = [ [ id:'test'], + file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) + ] + + BEDTOOLS_SORT ( input, [] ) +} + +workflow test_bedtools_sort_with_genome { + input = [ [ id:'test'], + file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) + ] + fai = Channel.of(file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)) + + BEDTOOLS_SORT ( input, [] ) +} diff --git a/tests/modules/CCBR/bedtools/sort/nextflow.config b/tests/modules/CCBR/bedtools/sort/nextflow.config new file mode 100644 index 0000000..27b09ba --- /dev/null +++ b/tests/modules/CCBR/bedtools/sort/nextflow.config @@ -0,0 +1,10 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: BEDTOOLS_SORT { + ext.prefix = { "${meta.id}_out" } + ext.suffix = "testtext" + } + +} diff --git a/tests/modules/CCBR/bedtools/sort/test.yml b/tests/modules/CCBR/bedtools/sort/test.yml new file mode 100644 index 0000000..8a96bbb --- /dev/null +++ b/tests/modules/CCBR/bedtools/sort/test.yml @@ -0,0 +1,19 @@ +- name: bedtools sort test_bedtools_sort + command: nextflow run ./tests/modules/nf-core/bedtools/sort -entry test_bedtools_sort -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/sort/nextflow.config + tags: + - bedtools + - bedtools/sort + files: + - path: output/bedtools/test_out.testtext + md5sum: fe4053cf4de3aebbdfc3be2efb125a74 + - path: output/bedtools/versions.yml + +- name: bedtools sort test_bedtools_sort_with_genome + command: nextflow run ./tests/modules/nf-core/bedtools/sort -entry test_bedtools_sort_with_genome -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/sort/nextflow.config + tags: + - bedtools + - bedtools/sort + files: + - path: output/bedtools/test_out.testtext + md5sum: fe4053cf4de3aebbdfc3be2efb125a74 + - path: output/bedtools/versions.yml From 4f0e5a2794701cee145e5823cbd50608fcb1e46f Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 11:58:13 -0500 Subject: [PATCH 10/47] refactor: minor cosmetic changes --- modules/CCBR/bedtools/map/main.nf | 18 ++++++++---------- modules/CCBR/bedtools/map/meta.yml | 4 +++- modules/CCBR/bedtools/merge/main.nf | 10 ++++------ modules/CCBR/bedtools/merge/meta.yml | 6 +++--- modules/CCBR/bedtools/sort/main.nf | 12 +++++------- modules/CCBR/bedtools/sort/meta.yml | 8 +++----- 6 files changed, 26 insertions(+), 32 deletions(-) diff --git a/modules/CCBR/bedtools/map/main.nf b/modules/CCBR/bedtools/map/main.nf index 846d5ba..5f09d6a 100644 --- a/modules/CCBR/bedtools/map/main.nf +++ b/modules/CCBR/bedtools/map/main.nf @@ -1,11 +1,9 @@ process BEDTOOLS_MAP { - tag "$meta.id" + tag { meta.id } label 'process_single' conda "bioconda::bedtools=2.31.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/bedtools:2.31.0--hf5e1c6e_2' : - 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' }" + container 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' input: tuple val(meta), path(intervals1), path(intervals2) @@ -29,10 +27,10 @@ process BEDTOOLS_MAP { """ bedtools \\ map \\ - -a $intervals1 \\ - -b $intervals2 \\ - $args \\ - $sizes \\ + -a ${intervals1} \\ + -b ${intervals2} \\ + ${args} \\ + ${sizes} \\ > ${prefix}.${extension} cat <<-END_VERSIONS > versions.yml @@ -44,8 +42,8 @@ process BEDTOOLS_MAP { stub: def prefix = task.ext.prefix ?: "${meta.id}" extension = intervals1.getExtension() - if ("$intervals1" == "${prefix}.${extension}" || - "$intervals2" == "${prefix}.${extension}") + if ("${intervals1}" == "${prefix}.${extension}" || + "${intervals2}" == "${prefix}.${extension}") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" """ touch ${prefix}.${extension} diff --git a/modules/CCBR/bedtools/map/meta.yml b/modules/CCBR/bedtools/map/meta.yml index 51f4fdc..0eb2581 100644 --- a/modules/CCBR/bedtools/map/meta.yml +++ b/modules/CCBR/bedtools/map/meta.yml @@ -50,4 +50,6 @@ output: description: File containing software versions pattern: "versions.yml" authors: - - "@ekushele" + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/modules/CCBR/bedtools/merge/main.nf b/modules/CCBR/bedtools/merge/main.nf index 6868d39..5ef567c 100644 --- a/modules/CCBR/bedtools/merge/main.nf +++ b/modules/CCBR/bedtools/merge/main.nf @@ -1,11 +1,9 @@ process BEDTOOLS_MERGE { - tag "$meta.id" + tag { meta.id } label 'process_single' conda "bioconda::bedtools=2.31.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/bedtools:2.31.0--hf5e1c6e_2' : - 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' }" + container 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' input: tuple val(meta), path(bed) @@ -24,8 +22,8 @@ process BEDTOOLS_MERGE { """ bedtools \\ merge \\ - -i $bed \\ - $args \\ + -i ${bed} \\ + ${args} \\ > ${prefix}.bed cat <<-END_VERSIONS > versions.yml diff --git a/modules/CCBR/bedtools/merge/meta.yml b/modules/CCBR/bedtools/merge/meta.yml index ee8e165..cec9bf6 100644 --- a/modules/CCBR/bedtools/merge/meta.yml +++ b/modules/CCBR/bedtools/merge/meta.yml @@ -36,6 +36,6 @@ output: description: File containing software versions pattern: "versions.yml" authors: - - "@Emiller88" - - "@sruthipsuresh" - - "@drpatelh" + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/modules/CCBR/bedtools/sort/main.nf b/modules/CCBR/bedtools/sort/main.nf index df372bc..677e328 100644 --- a/modules/CCBR/bedtools/sort/main.nf +++ b/modules/CCBR/bedtools/sort/main.nf @@ -1,11 +1,9 @@ process BEDTOOLS_SORT { - tag "$meta.id" + tag { meta.id } label 'process_single' conda "bioconda::bedtools=2.31.0" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/bedtools:2.31.0--hf5e1c6e_2' : - 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' }" + container 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' input: tuple val(meta), path(intervals) @@ -29,9 +27,9 @@ process BEDTOOLS_SORT { """ bedtools \\ sort \\ - -i $intervals \\ - $genome_cmd \\ - $args \\ + -i ${intervals} \\ + ${genome_cmd} \\ + ${args} \\ > ${prefix}.${extension} cat <<-END_VERSIONS > versions.yml diff --git a/modules/CCBR/bedtools/sort/meta.yml b/modules/CCBR/bedtools/sort/meta.yml index 80c16f3..d19a88b 100644 --- a/modules/CCBR/bedtools/sort/meta.yml +++ b/modules/CCBR/bedtools/sort/meta.yml @@ -43,8 +43,6 @@ output: description: File containing software versions pattern: "versions.yml" authors: - - "@Emiller88" - - "@sruthipsuresh" - - "@drpatelh" - - "@chris-cheshire" - - "@adamrtalbot" + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" From 01855f7f07cfc9d03c5ed3e8bef69922f064b4a5 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 22 Nov 2023 17:04:44 -0500 Subject: [PATCH 11/47] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b9831e..710c83b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Our documentation website is now live: (#16 - bwa/mem - also runs samtools sort & outputs index in bai format. (#12) - custom/bam2fastq (#14,#22) +- custom/consensuspeaks (#37) - custom/convertsicer (#36) - custom/countfastq (#32) - cutadapt (#11) From 514ebfd0dc9f45a2702803dccc0ad14e8d8d0aab Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 12:55:03 -0500 Subject: [PATCH 12/47] fix: import platform --- .../CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py index 1a0ee4b..089f213 100755 --- a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py +++ b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py @@ -5,6 +5,7 @@ import os import uuid import pandas +import platform def main(peakfiles, outbed, filter, nofilter): From 2d0ddb3292893caa02be96dea4e1cf07a18b5266 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 12:55:17 -0500 Subject: [PATCH 13/47] fix: switch nf-core -> ccbr --- tests/modules/CCBR/bedtools/map/main.nf | 4 ++-- tests/modules/CCBR/bedtools/map/test.yml | 4 ++-- tests/modules/CCBR/bedtools/merge/main.nf | 2 +- tests/modules/CCBR/bedtools/merge/test.yml | 2 +- tests/modules/CCBR/bedtools/sort/main.nf | 2 +- tests/modules/CCBR/bedtools/sort/test.yml | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/modules/CCBR/bedtools/map/main.nf b/tests/modules/CCBR/bedtools/map/main.nf index 0d42cac..cb81d1d 100644 --- a/tests/modules/CCBR/bedtools/map/main.nf +++ b/tests/modules/CCBR/bedtools/map/main.nf @@ -2,8 +2,8 @@ nextflow.enable.dsl = 2 -include { BEDTOOLS_MAP } from '../../../../../modules/nf-core/bedtools/map/main.nf' -include { BEDTOOLS_MAP as BEDTOOLS_MAP_VCF } from '../../../../../modules/nf-core/bedtools/map/main.nf' +include { BEDTOOLS_MAP } from '../../../../../modules/CCBR/bedtools/map/main.nf' +include { BEDTOOLS_MAP as BEDTOOLS_MAP_VCF } from '../../../../../modules/CCBR/bedtools/map/main.nf' workflow test_bedtools_map { input = [ diff --git a/tests/modules/CCBR/bedtools/map/test.yml b/tests/modules/CCBR/bedtools/map/test.yml index e06ddc3..0e5f78a 100644 --- a/tests/modules/CCBR/bedtools/map/test.yml +++ b/tests/modules/CCBR/bedtools/map/test.yml @@ -1,5 +1,5 @@ - name: bedtools map test_bedtools_map - command: nextflow run ./tests/modules/nf-core/bedtools/map -entry test_bedtools_map -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/map/nextflow.config + command: nextflow run ./tests/modules/CCBR/bedtools/map -entry test_bedtools_map -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/bedtools/map/nextflow.config tags: - bedtools - bedtools/map @@ -10,7 +10,7 @@ md5sum: 6c219404bf848cd4bd672a934dd4ed56 - name: bedtools map test_bedtools_map_vcf - command: nextflow run ./tests/modules/nf-core/bedtools/map -entry test_bedtools_map_vcf -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/map/nextflow.config + command: nextflow run ./tests/modules/CCBR/bedtools/map -entry test_bedtools_map_vcf -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/bedtools/map/nextflow.config tags: - bedtools - bedtools/map diff --git a/tests/modules/CCBR/bedtools/merge/main.nf b/tests/modules/CCBR/bedtools/merge/main.nf index 4941193..e0576e2 100644 --- a/tests/modules/CCBR/bedtools/merge/main.nf +++ b/tests/modules/CCBR/bedtools/merge/main.nf @@ -2,7 +2,7 @@ nextflow.enable.dsl = 2 -include { BEDTOOLS_MERGE } from '../../../../../modules/nf-core/bedtools/merge/main.nf' +include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf' workflow test_bedtools_merge { input = [ [ id:'test'], diff --git a/tests/modules/CCBR/bedtools/merge/test.yml b/tests/modules/CCBR/bedtools/merge/test.yml index bee9b75..63d2aa9 100644 --- a/tests/modules/CCBR/bedtools/merge/test.yml +++ b/tests/modules/CCBR/bedtools/merge/test.yml @@ -1,5 +1,5 @@ - name: bedtools merge - command: nextflow run ./tests/modules/nf-core/bedtools/merge -entry test_bedtools_merge -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/merge/nextflow.config + command: nextflow run ./tests/modules/CCBR/bedtools/merge -entry test_bedtools_merge -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/bedtools/merge/nextflow.config tags: - bedtools - bedtools/merge diff --git a/tests/modules/CCBR/bedtools/sort/main.nf b/tests/modules/CCBR/bedtools/sort/main.nf index 0cf0daf..c03bc98 100644 --- a/tests/modules/CCBR/bedtools/sort/main.nf +++ b/tests/modules/CCBR/bedtools/sort/main.nf @@ -2,7 +2,7 @@ nextflow.enable.dsl = 2 -include { BEDTOOLS_SORT } from '../../../../../modules/nf-core/bedtools/sort/main.nf' +include { BEDTOOLS_SORT } from '../../../../../modules/CCBR/bedtools/sort/main.nf' workflow test_bedtools_sort { input = [ [ id:'test'], diff --git a/tests/modules/CCBR/bedtools/sort/test.yml b/tests/modules/CCBR/bedtools/sort/test.yml index 8a96bbb..a40820b 100644 --- a/tests/modules/CCBR/bedtools/sort/test.yml +++ b/tests/modules/CCBR/bedtools/sort/test.yml @@ -1,5 +1,5 @@ - name: bedtools sort test_bedtools_sort - command: nextflow run ./tests/modules/nf-core/bedtools/sort -entry test_bedtools_sort -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/sort/nextflow.config + command: nextflow run ./tests/modules/CCBR/bedtools/sort -entry test_bedtools_sort -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/bedtools/sort/nextflow.config tags: - bedtools - bedtools/sort @@ -9,7 +9,7 @@ - path: output/bedtools/versions.yml - name: bedtools sort test_bedtools_sort_with_genome - command: nextflow run ./tests/modules/nf-core/bedtools/sort -entry test_bedtools_sort_with_genome -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/bedtools/sort/nextflow.config + command: nextflow run ./tests/modules/CCBR/bedtools/sort -entry test_bedtools_sort_with_genome -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/bedtools/sort/nextflow.config tags: - bedtools - bedtools/sort From 73a74a6f34f880c6c4dfb303ead85cba9d4b96d3 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 13:15:31 -0500 Subject: [PATCH 14/47] fix: use ccbr base docker --- modules/CCBR/bedtools/map/main.nf | 3 +-- modules/CCBR/bedtools/merge/main.nf | 3 +-- modules/CCBR/bedtools/sort/main.nf | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/CCBR/bedtools/map/main.nf b/modules/CCBR/bedtools/map/main.nf index 5f09d6a..6f457ac 100644 --- a/modules/CCBR/bedtools/map/main.nf +++ b/modules/CCBR/bedtools/map/main.nf @@ -2,8 +2,7 @@ process BEDTOOLS_MAP { tag { meta.id } label 'process_single' - conda "bioconda::bedtools=2.31.0" - container 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' + container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' input: tuple val(meta), path(intervals1), path(intervals2) diff --git a/modules/CCBR/bedtools/merge/main.nf b/modules/CCBR/bedtools/merge/main.nf index 5ef567c..ecb4dda 100644 --- a/modules/CCBR/bedtools/merge/main.nf +++ b/modules/CCBR/bedtools/merge/main.nf @@ -2,8 +2,7 @@ process BEDTOOLS_MERGE { tag { meta.id } label 'process_single' - conda "bioconda::bedtools=2.31.0" - container 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' + container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' input: tuple val(meta), path(bed) diff --git a/modules/CCBR/bedtools/sort/main.nf b/modules/CCBR/bedtools/sort/main.nf index 677e328..0b1a49e 100644 --- a/modules/CCBR/bedtools/sort/main.nf +++ b/modules/CCBR/bedtools/sort/main.nf @@ -2,8 +2,7 @@ process BEDTOOLS_SORT { tag { meta.id } label 'process_single' - conda "bioconda::bedtools=2.31.0" - container 'biocontainers/bedtools:2.31.0--hf5e1c6e_2' + container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' input: tuple val(meta), path(intervals) From 707b09361c46e75926d481d41a37d6f9e7a49415 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 13:16:43 -0500 Subject: [PATCH 15/47] test: don't check md5sum of versions file --- tests/modules/CCBR/bedtools/map/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/modules/CCBR/bedtools/map/test.yml b/tests/modules/CCBR/bedtools/map/test.yml index 0e5f78a..9f94eba 100644 --- a/tests/modules/CCBR/bedtools/map/test.yml +++ b/tests/modules/CCBR/bedtools/map/test.yml @@ -7,7 +7,6 @@ - path: output/bedtools/test_out.bed md5sum: d3aeb1ec7b90e0d5a6d1b9a4614ab96a - path: output/bedtools/versions.yml - md5sum: 6c219404bf848cd4bd672a934dd4ed56 - name: bedtools map test_bedtools_map_vcf command: nextflow run ./tests/modules/CCBR/bedtools/map -entry test_bedtools_map_vcf -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/bedtools/map/nextflow.config @@ -18,4 +17,3 @@ - path: output/bedtools/test_out.bed md5sum: cabd34d1132834581e31f53dfa66ec03 - path: output/bedtools/versions.yml - md5sum: ab927c219959af17dc370b0b8eda78bd From 73705dbfa3462472489317d2468bc80f7d961a8d Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 13:29:28 -0500 Subject: [PATCH 16/47] test: stub for custom/consensuspeaks module --- modules/CCBR/custom/consensuspeaks/main.nf | 3 +-- tests/modules/CCBR/custom/consensuspeaks/test.yml | 10 +++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/CCBR/custom/consensuspeaks/main.nf b/modules/CCBR/custom/consensuspeaks/main.nf index 3a08bad..9b7d1c7 100644 --- a/modules/CCBR/custom/consensuspeaks/main.nf +++ b/modules/CCBR/custom/consensuspeaks/main.nf @@ -30,8 +30,7 @@ process CUSTOM_CONSENSUSPEAKS { stub: - def prefix = task.ext.prefix ?: "${meta.id}" """ - touch ${prefix}.bed versions.yml + touch ${meta.id}.${meta.group}.consensus_peaks.bed versions.yml """ } diff --git a/tests/modules/CCBR/custom/consensuspeaks/test.yml b/tests/modules/CCBR/custom/consensuspeaks/test.yml index 4161ee4..0ecb8eb 100644 --- a/tests/modules/CCBR/custom/consensuspeaks/test.yml +++ b/tests/modules/CCBR/custom/consensuspeaks/test.yml @@ -7,5 +7,13 @@ - "custom/consensuspeaks" files: - path: "output/custom/test.macs_broad.consensus_peaks.bed" - md5sum: 4d684a948335bbed948704e4be9f1abe + md5sum: 417447a3080df9d4ffa294b876dde640 + - path: "output/custom/versions.yml" +- name: "custom consensuspeaks stub" + command: nextflow run ./tests/modules/CCBR/custom/consensuspeaks -entry test_custom_consensuspeaks -c ./tests/config/nextflow.config -stub + tags: + - "custom" + - "custom/consensuspeaks" + files: + - path: "output/custom/test.macs_broad.consensus_peaks.bed" - path: "output/custom/versions.yml" From b716bcad88d7cf470c3d2a54711ab5c9c285f14e Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 13:31:01 -0500 Subject: [PATCH 17/47] docs: add bedtools modules --- CHANGELOG.md | 3 +++ README.md | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 710c83b..5e1f550 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Our documentation website is now live: (#16 ### New modules +- bedtools/map (#37) +- bedtools/merge (#37) +- bedtools/sort (#37) - bwa/index - bwa/mem - also runs samtools sort & outputs index in bai format. (#12) diff --git a/README.md b/README.md index a8dc88d..d5df77d 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Want to **contribute** to this project? Check out the [contributing guidelines]( Many of the modules and subworkflows in this project reuse and adapt code from [nf-core/modules](https://github.com/nf-core/modules). In those cases, credit is noted in the `meta.yml` file of the module/subworkflow and also listed here: +- [bedtools](modules/CCBR/bedtools) adapts the [nf-core bedtools module](https://github.com/nf-core/modules/tree/fff2c3fc7cdcb81a2a37c3263b8ace9b353af407/modules/nf-core/bedtools) - [bwa](modules/CCBR/bwa) adapts the [nf-core bwa module](https://github.com/nf-core/chipseq/tree/51eba00b32885c4d0bec60db3cb0a45eb61e34c5/modules/nf-core/modules/bwa) - [cutadapt](modules/CCBR/cutadapt) adapts the [nf-core cutadapt module](https://github.com/nf-core/modules/tree/ef007b1ce5316506b8c27c3e7a62482409c6153c/modules/nf-core/cutadapt) - [khmer](modules/CCBR/khmer) adapts the [nf-core khmer module](https://github.com/nf-core/modules/tree/b48a1efc8e067502e1a9bafbac788c1e0abdfc6a/modules/nf-core/khmer) From cbf2d59570be6c2cdc35502c2ab4756ec3fbb422 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Mon, 27 Nov 2023 14:19:03 -0500 Subject: [PATCH 18/47] feat: add cat modules --- CHANGELOG.md | 2 + README.md | 1 + modules/CCBR/cat/cat/main.nf | 59 ++++++++++++++ modules/CCBR/cat/cat/meta.yml | 38 +++++++++ modules/CCBR/cat/fastq/main.nf | 77 ++++++++++++++++++ modules/CCBR/cat/fastq/meta.yml | 41 ++++++++++ tests/config/pytest_modules.yml | 8 ++ tests/modules/CCBR/cat/cat/main.nf | 61 +++++++++++++++ tests/modules/CCBR/cat/cat/nextflow.config | 12 +++ tests/modules/CCBR/cat/cat/test.yml | 81 +++++++++++++++++++ tests/modules/CCBR/cat/fastq/main.nf | 58 ++++++++++++++ tests/modules/CCBR/cat/fastq/nextflow.config | 5 ++ tests/modules/CCBR/cat/fastq/test.yml | 82 ++++++++++++++++++++ 13 files changed, 525 insertions(+) create mode 100644 modules/CCBR/cat/cat/main.nf create mode 100644 modules/CCBR/cat/cat/meta.yml create mode 100644 modules/CCBR/cat/fastq/main.nf create mode 100644 modules/CCBR/cat/fastq/meta.yml create mode 100644 tests/modules/CCBR/cat/cat/main.nf create mode 100644 tests/modules/CCBR/cat/cat/nextflow.config create mode 100644 tests/modules/CCBR/cat/cat/test.yml create mode 100644 tests/modules/CCBR/cat/fastq/main.nf create mode 100644 tests/modules/CCBR/cat/fastq/nextflow.config create mode 100644 tests/modules/CCBR/cat/fastq/test.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e1f550..31c3aff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Our documentation website is now live: (#16 - bwa/index - bwa/mem - also runs samtools sort & outputs index in bai format. (#12) +- cat/cat (#37) +- cat/fastq (#37) - custom/bam2fastq (#14,#22) - custom/consensuspeaks (#37) - custom/convertsicer (#36) diff --git a/README.md b/README.md index d5df77d..bfa7051 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ In those cases, credit is noted in the `meta.yml` file of the module/subworkflow - [bedtools](modules/CCBR/bedtools) adapts the [nf-core bedtools module](https://github.com/nf-core/modules/tree/fff2c3fc7cdcb81a2a37c3263b8ace9b353af407/modules/nf-core/bedtools) - [bwa](modules/CCBR/bwa) adapts the [nf-core bwa module](https://github.com/nf-core/chipseq/tree/51eba00b32885c4d0bec60db3cb0a45eb61e34c5/modules/nf-core/modules/bwa) +- [cat](modules/cat) adapts the [nf-core cat module](https://github.com/nf-core/modules/tree/9326d73af3fbe2ee90d9ce0a737461a727c5118e/modules/nf-core/cat) - [cutadapt](modules/CCBR/cutadapt) adapts the [nf-core cutadapt module](https://github.com/nf-core/modules/tree/ef007b1ce5316506b8c27c3e7a62482409c6153c/modules/nf-core/cutadapt) - [khmer](modules/CCBR/khmer) adapts the [nf-core khmer module](https://github.com/nf-core/modules/tree/b48a1efc8e067502e1a9bafbac788c1e0abdfc6a/modules/nf-core/khmer) - [picard/samtofastq](modules/picard/samtofastq) adapts the [nf-core gatk4 samtofastq module](https://github.com/nf-core/modules/tree/ef007b1ce5316506b8c27c3e7a62482409c6153c/modules/nf-core/gatk4/samtofastq) diff --git a/modules/CCBR/cat/cat/main.nf b/modules/CCBR/cat/cat/main.nf new file mode 100644 index 0000000..57cf950 --- /dev/null +++ b/modules/CCBR/cat/cat/main.nf @@ -0,0 +1,59 @@ +process CAT_CAT { + tag { meta.id } + label 'process_low' + + container 'nciccbr/ccbr_ubuntu_base_20.04:v5' + + input: + tuple val(meta), path(files_in) + + output: + tuple val(meta), path("${prefix}"), emit: file_out + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def args2 = task.ext.args2 ?: '' + def file_list = files_in.collect { it.toString() } + + // | input | output | command1 | command2 | + // |-----------|------------|----------|----------| + // | gzipped | gzipped | cat | | + // | ungzipped | ungzipped | cat | | + // | gzipped | ungzipped | zcat | | + // | ungzipped | gzipped | cat | pigz | + + // Use input file ending as default + prefix = task.ext.prefix ?: "${meta.id}${file_list[0].substring(file_list[0].lastIndexOf('.'))}" + out_zip = prefix.endsWith('.gz') + in_zip = file_list[0].endsWith('.gz') + command1 = (in_zip && !out_zip) ? 'zcat' : 'cat' + command2 = (!in_zip && out_zip) ? "| pigz -c -p $task.cpus $args2" : '' + """ + $command1 \\ + $args \\ + ${file_list.join(' ')} \\ + $command2 \\ + > ${prefix} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) + END_VERSIONS + """ + + stub: + def file_list = files_in.collect { it.toString() } + prefix = task.ext.prefix ?: "${meta.id}${file_list[0].substring(file_list[0].lastIndexOf('.'))}" + """ + touch $prefix + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' ) + END_VERSIONS + """ +} diff --git a/modules/CCBR/cat/cat/meta.yml b/modules/CCBR/cat/cat/meta.yml new file mode 100644 index 0000000..320d5c0 --- /dev/null +++ b/modules/CCBR/cat/cat/meta.yml @@ -0,0 +1,38 @@ +name: cat_cat +description: A module for concatenation of gzipped or uncompressed files. Adapted from the nf-core cat module https://github.com/nf-core/modules/tree/9326d73af3fbe2ee90d9ce0a737461a727c5118e/modules/nf-core/cat +keywords: + - concatenate + - gzip + - cat +tools: + - cat: + description: Just concatenation + + documentation: https://man7.org/linux/man-pages/man1/cat.1.html + + licence: ["GPL-3.0-or-later"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - files_in: + type: file + description: List of compressed / uncompressed files + pattern: "*" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - file_out: + type: file + description: Concatenated file. Will be gzipped if file_out ends with ".gz" + pattern: "${file_out}" + +authors: + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/modules/CCBR/cat/fastq/main.nf b/modules/CCBR/cat/fastq/main.nf new file mode 100644 index 0000000..0f7ee10 --- /dev/null +++ b/modules/CCBR/cat/fastq/main.nf @@ -0,0 +1,77 @@ +process CAT_FASTQ { + tag { meta.id } + label 'process_single' + + container 'nciccbr/ccbr_ubuntu_base_20.04:v5' + + input: + tuple val(meta), path(reads, stageAs: "input*/*") + + output: + tuple val(meta), path("*.merged.fastq.gz"), emit: reads + 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 readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()] + if (meta.single_end) { + if (readList.size >= 1) { + """ + cat ${readList.join(' ')} > ${prefix}.merged.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//') + END_VERSIONS + """ + } + } else { + if (readList.size >= 2) { + def read1 = [] + def read2 = [] + readList.eachWithIndex{ v, ix -> ( ix & 1 ? read2 : read1 ) << v } + """ + cat ${read1.join(' ')} > ${prefix}_1.merged.fastq.gz + cat ${read2.join(' ')} > ${prefix}_2.merged.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//') + END_VERSIONS + """ + } + } + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + def readList = reads instanceof List ? reads.collect{ it.toString() } : [reads.toString()] + if (meta.single_end) { + if (readList.size > 1) { + """ + touch ${prefix}.merged.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//') + END_VERSIONS + """ + } + } else { + if (readList.size > 2) { + """ + touch ${prefix}_1.merged.fastq.gz + touch ${prefix}_2.merged.fastq.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cat: \$(echo \$(cat --version 2>&1) | sed 's/^.*coreutils) //; s/ .*\$//') + END_VERSIONS + """ + } + } + +} diff --git a/modules/CCBR/cat/fastq/meta.yml b/modules/CCBR/cat/fastq/meta.yml new file mode 100644 index 0000000..d2546af --- /dev/null +++ b/modules/CCBR/cat/fastq/meta.yml @@ -0,0 +1,41 @@ +name: cat_fastq +description: Concatenates fastq files. Adapted from the nf-core cat module https://github.com/nf-core/modules/tree/9326d73af3fbe2ee90d9ce0a737461a727c5118e/modules/nf-core/cat +keywords: + - cat + - fastq + - concatenate +tools: + - cat: + description: | + The cat utility reads files sequentially, writing them to the standard output. + documentation: https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html + licence: ["GPL-3.0-or-later"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: | + List of input FastQ files to be concatenated. +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - reads: + type: file + description: Merged fastq file + pattern: "*.{merged.fastq.gz}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 05d3f2f..e47b8fd 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -18,6 +18,14 @@ bwa/mem: - modules/CCBR/bwa/mem/** - tests/modules/CCBR/bwa/mem/** +cat/cat: + - modules/CCBR/cat/cat/** + - tests/modules/CCBR/cat/cat/** + +cat/fastq: + - modules/CCBR/cat/fastq/** + - tests/modules/CCBR/cat/fastq/** + custom/bam2fastq: - modules/CCBR/custom/bam2fastq/** - tests/modules/CCBR/custom/bam2fastq/** diff --git a/tests/modules/CCBR/cat/cat/main.nf b/tests/modules/CCBR/cat/cat/main.nf new file mode 100644 index 0000000..e490b9b --- /dev/null +++ b/tests/modules/CCBR/cat/cat/main.nf @@ -0,0 +1,61 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CAT_CAT } from '../../../../../modules/CCBR/cat/cat/main.nf' +include { CAT_CAT as CAT_UNZIPPED_ZIPPED } from '../../../../../modules/CCBR/cat/cat/main.nf' +include { CAT_CAT as CAT_ZIPPED_UNZIPPED } from '../../../../../modules/CCBR/cat/cat/main.nf' + +workflow test_cat_unzipped_unzipped { + + input = [ + [ id:'test', single_end:true ], // meta map + [ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true), + file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true) ] + ] + + CAT_CAT ( input ) +} + +workflow test_cat_zipped_zipped { + + input = [ + [ id:'test', single_end:true ], // meta map + [file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)] + ] + + CAT_CAT ( input ) +} + +workflow test_cat_zipped_unzipped { + + input = [ + [ id:'test', single_end:true ], // meta map + [file(params.test_data['sarscov2']['genome']['genome_gff3_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['genome']['contigs_genome_maf_gz'], checkIfExists: true)] + ] + + CAT_ZIPPED_UNZIPPED ( input ) +} + +workflow test_cat_unzipped_zipped { + + input = [ + [ id:'test', single_end:true ], // meta map + [file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true), + file(params.test_data['sarscov2']['genome']['genome_sizes'], checkIfExists: true)] + ] + + CAT_UNZIPPED_ZIPPED ( input ) +} + +workflow test_cat_one_file_unzipped_zipped { + + input = [ + [ id:'test', single_end:true ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) + ] + + CAT_UNZIPPED_ZIPPED ( input ) +} diff --git a/tests/modules/CCBR/cat/cat/nextflow.config b/tests/modules/CCBR/cat/cat/nextflow.config new file mode 100644 index 0000000..8916a29 --- /dev/null +++ b/tests/modules/CCBR/cat/cat/nextflow.config @@ -0,0 +1,12 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: CAT_UNZIPPED_ZIPPED { + ext.prefix = 'cat.txt.gz' + } + + withName: CAT_ZIPPED_UNZIPPED { + ext.prefix = 'cat.txt' + } +} diff --git a/tests/modules/CCBR/cat/cat/test.yml b/tests/modules/CCBR/cat/cat/test.yml new file mode 100644 index 0000000..6567048 --- /dev/null +++ b/tests/modules/CCBR/cat/cat/test.yml @@ -0,0 +1,81 @@ +- name: cat unzipped unzipped + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_unzipped_unzipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config + tags: + - cat + - cat/cat + files: + - path: output/cat/test.fasta + md5sum: f44b33a0e441ad58b2d3700270e2dbe2 + +- name: cat unzipped unzipped stub + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_unzipped_unzipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config -stub-run + tags: + - cat + - cat/cat + files: + - path: output/cat/test.fasta + +- name: cat zipped zipped + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_zipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config + tags: + - cat + - cat/cat + files: + - path: output/cat/test.gz + +- name: cat zipped zipped stub + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_zipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config -stub-run + tags: + - cat + - cat/cat + files: + - path: output/cat/test.gz + +- name: cat zipped unzipped + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_zipped_unzipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt + md5sum: c439d3b60e7bc03e8802a451a0d9a5d9 + +- name: cat zipped unzipped stub + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_zipped_unzipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config -stub-run + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt + +- name: cat unzipped zipped + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_unzipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt.gz + +- name: cat unzipped zipped stub + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_unzipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config -stub-run + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt.gz + +- name: cat one file unzipped zipped + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_one_file_unzipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt.gz + +- name: cat one file unzipped zipped stub + command: nextflow run ./tests/modules/CCBR/cat/cat -entry test_cat_one_file_unzipped_zipped -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/cat/nextflow.config -stub-run + tags: + - cat + - cat/cat + files: + - path: output/cat/cat.txt.gz diff --git a/tests/modules/CCBR/cat/fastq/main.nf b/tests/modules/CCBR/cat/fastq/main.nf new file mode 100644 index 0000000..48582e5 --- /dev/null +++ b/tests/modules/CCBR/cat/fastq/main.nf @@ -0,0 +1,58 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CAT_FASTQ } from '../../../../../modules/CCBR/cat/fastq/main.nf' + +workflow test_cat_fastq_single_end { + input = [ + [ id:'test', single_end:true ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test2_1_fastq_gz'], checkIfExists: true) ] + ] + + CAT_FASTQ ( input ) +} + +workflow test_cat_fastq_paired_end { + input = [ + [ id:'test', single_end:false ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test2_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test2_2_fastq_gz'], checkIfExists: true) ] + ] + + CAT_FASTQ ( input ) +} + +workflow test_cat_fastq_single_end_same_name { + input = [ + [ id:'test', single_end:true ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ] + ] + + CAT_FASTQ ( input ) +} + +workflow test_cat_fastq_paired_end_same_name { + input = [ + [ id:'test', single_end:false ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ] + ] + + CAT_FASTQ ( input ) +} + +workflow test_cat_fastq_single_end_single_file { + input = [ + [ id:'test', single_end:true ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)] + ] + + CAT_FASTQ ( input ) +} diff --git a/tests/modules/CCBR/cat/fastq/nextflow.config b/tests/modules/CCBR/cat/fastq/nextflow.config new file mode 100644 index 0000000..8730f1c --- /dev/null +++ b/tests/modules/CCBR/cat/fastq/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/CCBR/cat/fastq/test.yml b/tests/modules/CCBR/cat/fastq/test.yml new file mode 100644 index 0000000..28d206d --- /dev/null +++ b/tests/modules/CCBR/cat/fastq/test.yml @@ -0,0 +1,82 @@ +- name: cat fastq single-end + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_single_end -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test.merged.fastq.gz + md5sum: f9cf5e375f7de81a406144a2c70cc64d + +- name: cat fastq fastqc_paired_end + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_paired_end -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test_2.merged.fastq.gz + md5sum: 77c8e966e130d8c6b6ec9be52fcb2bda + - path: ./output/cat/test_1.merged.fastq.gz + md5sum: f9cf5e375f7de81a406144a2c70cc64d + +- name: cat fastq single-end-same-name + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_single_end_same_name -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test.merged.fastq.gz + md5sum: 63f817db7a29a03eb538104495556f66 + +- name: cat fastq fastqc_paired_end_same_name + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_paired_end_same_name -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test_1.merged.fastq.gz + md5sum: 63f817db7a29a03eb538104495556f66 + - path: ./output/cat/test_2.merged.fastq.gz + md5sum: fe9f266f43a6fc3dcab690a18419a56e + +- name: cat fastq single-end-single-file + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_single_end_single_file -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test.merged.fastq.gz + md5sum: e325ef7deb4023447a1f074e285761af + +- name: cat fastq single-end stub + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_single_end -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config -stub-run + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test.merged.fastq.gz + +- name: cat fastq fastqc_paired_end stub + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_paired_end -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config -stub-run + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test_2.merged.fastq.gz + - path: ./output/cat/test_1.merged.fastq.gz + +- name: cat fastq single-end-same-name stub + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_single_end_same_name -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config -stub-run + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test.merged.fastq.gz + +- name: cat fastq fastqc_paired_end_same_name stub + command: nextflow run ./tests/modules/CCBR/cat/fastq -entry test_cat_fastq_paired_end_same_name -c ./tests/config/nextflow.config -c ./tests/modules/CCBR/cat/fastq/nextflow.config -stub-run + tags: + - cat + - cat/fastq + files: + - path: ./output/cat/test_1.merged.fastq.gz + - path: ./output/cat/test_2.merged.fastq.gz From 075450e8744d0056e0cec3dae23487e1cfff71c0 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 09:12:37 -0500 Subject: [PATCH 19/47] feat: add bedops/bedmap module --- CHANGELOG.md | 1 + modules/CCBR/bedops/bedmap/main.nf | 37 +++++++++++++ modules/CCBR/bedops/bedmap/meta.yml | 55 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/CCBR/bedops/bedmap/main.nf | 26 +++++++++ .../CCBR/bedops/bedmap/nextflow.config | 7 +++ tests/modules/CCBR/bedops/bedmap/test.yml | 12 ++++ 7 files changed, 142 insertions(+) create mode 100644 modules/CCBR/bedops/bedmap/main.nf create mode 100644 modules/CCBR/bedops/bedmap/meta.yml create mode 100644 tests/modules/CCBR/bedops/bedmap/main.nf create mode 100644 tests/modules/CCBR/bedops/bedmap/nextflow.config create mode 100644 tests/modules/CCBR/bedops/bedmap/test.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c3aff..af92ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Our documentation website is now live: (#16 ### New modules +- bedops/bedmap (#37) - bedtools/map (#37) - bedtools/merge (#37) - bedtools/sort (#37) diff --git a/modules/CCBR/bedops/bedmap/main.nf b/modules/CCBR/bedops/bedmap/main.nf new file mode 100644 index 0000000..e58b63e --- /dev/null +++ b/modules/CCBR/bedops/bedmap/main.nf @@ -0,0 +1,37 @@ +process BEDOPS_BEDMAP { + tag { meta.id } + label 'process_single' + container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' + + input: + tuple val(meta1), path(refbed) + tuple val(meta2), path(mapbed) + + output: + tuple val(meta2), path("*.mapped.bed"), emit: bed + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + """ + bedmap \\ + --delim '\t' \\ + --echo-ref-name \\ + --count \\ + ${refbed} \\ + ${mapbed} \\ + > ${meta2.id}.mapped.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedops: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + END_VERSIONS + """ + + stub: + """ + touch ${meta2.id}.mapped.bed versions.yml + """ +} diff --git a/modules/CCBR/bedops/bedmap/meta.yml b/modules/CCBR/bedops/bedmap/meta.yml new file mode 100644 index 0000000..de83591 --- /dev/null +++ b/modules/CCBR/bedops/bedmap/meta.yml @@ -0,0 +1,55 @@ +--- +name: "bedops_bedmap" +description: The bedmap program is used to retrieve and process signal or other features over regions of interest in BED files +keywords: + - bedops + - bedmap + - bed + - intervals +tools: + - bedops: + description: | + fast, highly scalable and easily-parallelizable genome analysis toolkit + documentation: https://bedops.readthedocs.io/ + tool_dev_url: https://github.com/bedops/bedops + licence: ["GPLv2"] + doi: 10.1093/bioinformatics/bts277 + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - refbed: + type: file + description: BED file + pattern: "*.bed" + - mapbed: + type: file + description: BED file + pattern: "*.bed" + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - mapped_bed: + type: file + description: BED file + pattern: "*.bed" + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index e47b8fd..1475144 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1,3 +1,7 @@ +bedops/bedmap: + - modules/CCBR/bedops/bedmap/** + - tests/modules/CCBR/bedops/bedmap/** + bedtools/map: - modules/CCBR/bedtools/map/** - tests/modules/CCBR/bedtools/map/** diff --git a/tests/modules/CCBR/bedops/bedmap/main.nf b/tests/modules/CCBR/bedops/bedmap/main.nf new file mode 100644 index 0000000..e0d321d --- /dev/null +++ b/tests/modules/CCBR/bedops/bedmap/main.nf @@ -0,0 +1,26 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CAT_CAT } from '../../../../../modules/CCBR/cat/cat/main.nf' +include { BEDOPS_BEDMAP } from '../../../../../modules/CCBR/bedops/bedmap/main.nf' +include { BEDTOOLS_SORT as SORT_CAT + BEDTOOLS_SORT as SORT_PEAK } from '../../../../../modules/CCBR/bedtools/sort/main.nf' +include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf' + +workflow test_bedops_bedmap { + + ch_peaks = [ + [ id: 'test', group: 'macs_broad' ], // meta map + [ file(params.test_data['macs_peaks_1'], checkIfExists: true), + file(params.test_data['macs_peaks_2'], checkIfExists: true), + ] + ] + + ch_peaks.collect() | CAT_CAT + CAT_CAT.out.file_out | SORT_CAT + SORT_CAT.out.sorted | BEDTOOLS_MERGE + + ch_peaks | SORT_PEAK + BEDOPS_BEDMAP( BEDTOOLS_MERGE.out.bed, SORT_PEAK.out.sorted ) +} diff --git a/tests/modules/CCBR/bedops/bedmap/nextflow.config b/tests/modules/CCBR/bedops/bedmap/nextflow.config new file mode 100644 index 0000000..a652b2d --- /dev/null +++ b/tests/modules/CCBR/bedops/bedmap/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} + +includeConfig '../../../../config/test_data_CCBR.config' diff --git a/tests/modules/CCBR/bedops/bedmap/test.yml b/tests/modules/CCBR/bedops/bedmap/test.yml new file mode 100644 index 0000000..3c4418a --- /dev/null +++ b/tests/modules/CCBR/bedops/bedmap/test.yml @@ -0,0 +1,12 @@ +## TODO nf-core: Please run the following command to build this file: +# nf-core modules create-test-yml /bedmap +- name: "bedops bedmap" + command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config + tags: + - "bedops" + - "bedops/bedmap" + files: + - path: "output/bedops/test.bam" + md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: "output/bedops/versions.yml" + md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b From 624f56ce1f6cfd9d4577acb96cbab94f1f1fb7d6 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 10:26:45 -0500 Subject: [PATCH 20/47] style: align includes --- tests/modules/CCBR/bedtools/map/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/CCBR/bedtools/map/main.nf b/tests/modules/CCBR/bedtools/map/main.nf index cb81d1d..f1cf128 100644 --- a/tests/modules/CCBR/bedtools/map/main.nf +++ b/tests/modules/CCBR/bedtools/map/main.nf @@ -2,7 +2,7 @@ nextflow.enable.dsl = 2 -include { BEDTOOLS_MAP } from '../../../../../modules/CCBR/bedtools/map/main.nf' +include { BEDTOOLS_MAP } from '../../../../../modules/CCBR/bedtools/map/main.nf' include { BEDTOOLS_MAP as BEDTOOLS_MAP_VCF } from '../../../../../modules/CCBR/bedtools/map/main.nf' workflow test_bedtools_map { From dff08c96430770edab6e097c5c2ab864494ceac2 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 10:31:55 -0500 Subject: [PATCH 21/47] test: add test for bedops/bedmap --- modules/CCBR/bedops/bedmap/main.nf | 2 +- tests/modules/CCBR/bedops/bedmap/main.nf | 20 +++++----- .../CCBR/bedops/bedmap/nextflow.config | 5 +++ tests/modules/CCBR/bedops/bedmap/test.yml | 40 ++++++++++++++----- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/modules/CCBR/bedops/bedmap/main.nf b/modules/CCBR/bedops/bedmap/main.nf index e58b63e..c592a82 100644 --- a/modules/CCBR/bedops/bedmap/main.nf +++ b/modules/CCBR/bedops/bedmap/main.nf @@ -1,5 +1,5 @@ process BEDOPS_BEDMAP { - tag { meta.id } + tag { meta2.id } label 'process_single' container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' diff --git a/tests/modules/CCBR/bedops/bedmap/main.nf b/tests/modules/CCBR/bedops/bedmap/main.nf index e0d321d..a6ac739 100644 --- a/tests/modules/CCBR/bedops/bedmap/main.nf +++ b/tests/modules/CCBR/bedops/bedmap/main.nf @@ -10,17 +10,17 @@ include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtool workflow test_bedops_bedmap { - ch_peaks = [ - [ id: 'test', group: 'macs_broad' ], // meta map - [ file(params.test_data['macs_peaks_1'], checkIfExists: true), - file(params.test_data['macs_peaks_2'], checkIfExists: true), - ] - ] - - ch_peaks.collect() | CAT_CAT - CAT_CAT.out.file_out | SORT_CAT + ch_peaks = Channel.fromPath([file(params.test_data['macs_peaks_1'], checkIfExists: true), + file(params.test_data['macs_peaks_2'], checkIfExists: true)]) + .map { peak -> + [ [ id: 'test', group: 'macs_broad' ], peak ] + } + // prepare reference + CAT_CAT(ch_peaks.groupTuple()) + SORT_CAT(CAT_CAT.out.file_out, []) SORT_CAT.out.sorted | BEDTOOLS_MERGE - ch_peaks | SORT_PEAK + // map peaks to reference + SORT_PEAK(ch_peaks, []) BEDOPS_BEDMAP( BEDTOOLS_MERGE.out.bed, SORT_PEAK.out.sorted ) } diff --git a/tests/modules/CCBR/bedops/bedmap/nextflow.config b/tests/modules/CCBR/bedops/bedmap/nextflow.config index a652b2d..8e6be37 100644 --- a/tests/modules/CCBR/bedops/bedmap/nextflow.config +++ b/tests/modules/CCBR/bedops/bedmap/nextflow.config @@ -2,6 +2,11 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: BEDTOOLS_SORT { + ext.prefix = { "${meta.id}_out" } + ext.suffix = "testtext" + } + } includeConfig '../../../../config/test_data_CCBR.config' diff --git a/tests/modules/CCBR/bedops/bedmap/test.yml b/tests/modules/CCBR/bedops/bedmap/test.yml index 3c4418a..fbf48ad 100644 --- a/tests/modules/CCBR/bedops/bedmap/test.yml +++ b/tests/modules/CCBR/bedops/bedmap/test.yml @@ -1,12 +1,34 @@ -## TODO nf-core: Please run the following command to build this file: -# nf-core modules create-test-yml /bedmap -- name: "bedops bedmap" +- name: bedops bedmap test_bedops_bedmap command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config tags: - - "bedops" - - "bedops/bedmap" + - bedops/bedmap + - bedops files: - - path: "output/bedops/test.bam" - md5sum: e667c7caad0bc4b7ac383fd023c654fc - - path: "output/bedops/versions.yml" - md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b + - path: output/bedops/test.mapped.bed + contains: + - "chrI:229492-230276" + - path: output/bedops/versions.yml + - path: output/bedtools/test.bed + md5sum: d67c8c15b99b310ec5aa0ec363dcd147 + - path: output/bedtools/versions.yml + - path: output/cat/test.broadPeak + md5sum: c5d73e727a10d2a32b139efcdd369f59 + - path: output/cat/versions.yml + - path: output/sort/test_out.testtext + md5sum: b412285368f1698634177087e7ea4103 + - path: output/sort/versions.yml + +- name: bedops bedmap test_bedops_bedmap stub + command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config -stub + tags: + - bedops/bedmap + - bedops + files: + - path: output/bedops/test.mapped.bed + - path: output/bedops/versions.yml + - path: output/bedtools/test.bed + - path: output/bedtools/versions.yml + - path: output/cat/test.broadPeak + - path: output/cat/versions.yml + - path: output/sort/test_out.testtext + - path: output/sort/versions.yml From b45f529cfecd73abd67e770fa9736a21816fb60c Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 10:39:03 -0500 Subject: [PATCH 22/47] feat: set default prefixes for bedtools processes prevent the need to set task.ext.prefix in most cases --- modules/CCBR/bedtools/map/main.nf | 4 ++-- modules/CCBR/bedtools/merge/main.nf | 4 ++-- modules/CCBR/bedtools/sort/main.nf | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/CCBR/bedtools/map/main.nf b/modules/CCBR/bedtools/map/main.nf index 6f457ac..7ebb336 100644 --- a/modules/CCBR/bedtools/map/main.nf +++ b/modules/CCBR/bedtools/map/main.nf @@ -17,7 +17,7 @@ process BEDTOOLS_MAP { script: def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta.id}.mapped" extension = intervals1.getExtension() def sizes = chrom_sizes ? "-g ${chrom_sizes}" : '' if ("$intervals1" == "${prefix}.${extension}" || @@ -39,7 +39,7 @@ process BEDTOOLS_MAP { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta.id}.mapped" extension = intervals1.getExtension() if ("${intervals1}" == "${prefix}.${extension}" || "${intervals2}" == "${prefix}.${extension}") diff --git a/modules/CCBR/bedtools/merge/main.nf b/modules/CCBR/bedtools/merge/main.nf index ecb4dda..bdeb79b 100644 --- a/modules/CCBR/bedtools/merge/main.nf +++ b/modules/CCBR/bedtools/merge/main.nf @@ -16,7 +16,7 @@ process BEDTOOLS_MERGE { script: def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta.id}.merged" if ("$bed" == "${prefix}.bed") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!" """ bedtools \\ @@ -32,7 +32,7 @@ process BEDTOOLS_MERGE { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta.id}.merged" """ touch ${prefix}.bed diff --git a/modules/CCBR/bedtools/sort/main.nf b/modules/CCBR/bedtools/sort/main.nf index 0b1a49e..90b2b70 100644 --- a/modules/CCBR/bedtools/sort/main.nf +++ b/modules/CCBR/bedtools/sort/main.nf @@ -17,7 +17,7 @@ process BEDTOOLS_SORT { script: def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta.id}.sorted" def genome_cmd = genome_file ? "-g $genome_file" : "" extension = task.ext.suffix ?: intervals.extension if ("$intervals" == "${prefix}.${extension}") { @@ -38,8 +38,8 @@ process BEDTOOLS_SORT { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" - extension = task.ext.suffix ?: intervals.extension + def prefix = task.ext.prefix ?: "${meta.id}.sorted" + extension = task.ext.suffix ?: intervals.extension """ touch ${prefix}.${extension} From 35157e01e16c8410160cb52abc141e5bbb7f4e74 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 11:05:39 -0500 Subject: [PATCH 23/47] fix: propagate metadata correctly --- modules/CCBR/bedops/bedmap/main.nf | 20 +++++--- tests/modules/CCBR/bedops/bedmap/main.nf | 12 +++-- .../CCBR/bedops/bedmap/nextflow.config | 7 +-- tests/modules/CCBR/bedops/bedmap/test.yml | 50 +++++++++++-------- 4 files changed, 52 insertions(+), 37 deletions(-) diff --git a/modules/CCBR/bedops/bedmap/main.nf b/modules/CCBR/bedops/bedmap/main.nf index c592a82..102529a 100644 --- a/modules/CCBR/bedops/bedmap/main.nf +++ b/modules/CCBR/bedops/bedmap/main.nf @@ -1,15 +1,14 @@ process BEDOPS_BEDMAP { - tag { meta2.id } + tag { meta.id } label 'process_single' container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' input: - tuple val(meta1), path(refbed) - tuple val(meta2), path(mapbed) + tuple val(meta), path(mapbed), path(refbed) output: - tuple val(meta2), path("*.mapped.bed"), emit: bed - path "versions.yml" , emit: versions + tuple val(meta), path("*.mapped.bed"), emit: bed + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -22,16 +21,21 @@ process BEDOPS_BEDMAP { --count \\ ${refbed} \\ ${mapbed} \\ - > ${meta2.id}.mapped.bed + > ${meta.id}.mapped.bed cat <<-END_VERSIONS > versions.yml "${task.process}": - bedops: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + bedops: \$(echo \$(bedops --version 2>&1 | grep version | sed 's/version: //')) END_VERSIONS """ stub: """ - touch ${meta2.id}.mapped.bed versions.yml + touch ${meta.id}.mapped.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + bedops: \$(echo \$(bedops --version 2>&1 | grep version | sed 's/version: //')) + END_VERSIONS """ } diff --git a/tests/modules/CCBR/bedops/bedmap/main.nf b/tests/modules/CCBR/bedops/bedmap/main.nf index a6ac739..b35406b 100644 --- a/tests/modules/CCBR/bedops/bedmap/main.nf +++ b/tests/modules/CCBR/bedops/bedmap/main.nf @@ -13,14 +13,20 @@ workflow test_bedops_bedmap { ch_peaks = Channel.fromPath([file(params.test_data['macs_peaks_1'], checkIfExists: true), file(params.test_data['macs_peaks_2'], checkIfExists: true)]) .map { peak -> - [ [ id: 'test', group: 'macs_broad' ], peak ] + [ [id: peak.baseName, group: 'macs_broad'], peak ] } // prepare reference - CAT_CAT(ch_peaks.groupTuple()) + ch_peaks + .map{ meta, peak -> + [ [id: 'test', group: 'macs_broad'], peak ] + } + .groupTuple() | CAT_CAT SORT_CAT(CAT_CAT.out.file_out, []) SORT_CAT.out.sorted | BEDTOOLS_MERGE + map_bed = BEDTOOLS_MERGE.out.bed.map{ meta, bed -> bed } // map peaks to reference SORT_PEAK(ch_peaks, []) - BEDOPS_BEDMAP( BEDTOOLS_MERGE.out.bed, SORT_PEAK.out.sorted ) + SORT_PEAK.out.sorted | view + BEDOPS_BEDMAP( SORT_PEAK.out.sorted.combine(map_bed) ) } diff --git a/tests/modules/CCBR/bedops/bedmap/nextflow.config b/tests/modules/CCBR/bedops/bedmap/nextflow.config index 8e6be37..e942eb5 100644 --- a/tests/modules/CCBR/bedops/bedmap/nextflow.config +++ b/tests/modules/CCBR/bedops/bedmap/nextflow.config @@ -1,11 +1,6 @@ process { - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: BEDTOOLS_SORT { - ext.prefix = { "${meta.id}_out" } - ext.suffix = "testtext" - } + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].toLowerCase()}" } } diff --git a/tests/modules/CCBR/bedops/bedmap/test.yml b/tests/modules/CCBR/bedops/bedmap/test.yml index fbf48ad..8e039b4 100644 --- a/tests/modules/CCBR/bedops/bedmap/test.yml +++ b/tests/modules/CCBR/bedops/bedmap/test.yml @@ -1,34 +1,44 @@ -- name: bedops bedmap test_bedops_bedmap +- name: test_bedops_bedmap command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config tags: - bedops/bedmap - bedops files: - - path: output/bedops/test.mapped.bed - contains: - - "chrI:229492-230276" - - path: output/bedops/versions.yml - - path: output/bedtools/test.bed + - path: output/bedops_bedmap/SPT5_T0_1_peaks.mapped.bed + md5sum: a46e2f78e8534ecdc882fff22f0baa87 + - path: output/bedops_bedmap/SPT5_T0_2_peaks.mapped.bed + md5sum: c58be7ebe1f63c1cdf9eef66a41e23c1 + - path: output/bedops_bedmap/versions.yml + - path: output/bedtools_merge/test.merged.bed md5sum: d67c8c15b99b310ec5aa0ec363dcd147 - - path: output/bedtools/versions.yml - - path: output/cat/test.broadPeak + - path: output/bedtools_merge/versions.yml + - path: output/cat_cat/test.broadPeak md5sum: c5d73e727a10d2a32b139efcdd369f59 - - path: output/cat/versions.yml - - path: output/sort/test_out.testtext + - path: output/cat_cat/versions.yml + - path: output/sort_cat/test.sorted.broadPeak md5sum: b412285368f1698634177087e7ea4103 - - path: output/sort/versions.yml + - path: output/sort_cat/versions.yml + - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak + md5sum: 03b87e9021f85db1c8e07f5c0b4d7347 + - path: output/sort_peak/SPT5_T0_2_peaks.sorted.broadPeak + md5sum: d3216918f24ced4b76b8eed6e38aa5c6 + - path: output/sort_peak/versions.yml -- name: bedops bedmap test_bedops_bedmap stub +- name: test_bedops_bedmap stub command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config -stub tags: - bedops/bedmap - bedops files: - - path: output/bedops/test.mapped.bed - - path: output/bedops/versions.yml - - path: output/bedtools/test.bed - - path: output/bedtools/versions.yml - - path: output/cat/test.broadPeak - - path: output/cat/versions.yml - - path: output/sort/test_out.testtext - - path: output/sort/versions.yml + - path: output/bedops_bedmap/SPT5_T0_1_peaks.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_2_peaks.mapped.bed + - path: output/bedops_bedmap/versions.yml + - path: output/bedtools_merge/test.merged.bed + - path: output/bedtools_merge/versions.yml + - path: output/cat_cat/test.broadPeak + - path: output/cat_cat/versions.yml + - path: output/sort_cat/test.sorted.broadPeak + - path: output/sort_cat/versions.yml + - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak + - path: output/sort_peak/SPT5_T0_2_peaks.sorted.broadPeak + - path: output/sort_peak/versions.yml From 8664362d5177cda16a632a6cc64da6d84306c15d Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 12:13:32 -0500 Subject: [PATCH 24/47] test: update test data config paths --- tests/modules/CCBR/bedops/bedmap/main.nf | 4 ++-- tests/modules/CCBR/custom/consensuspeaks/main.nf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/modules/CCBR/bedops/bedmap/main.nf b/tests/modules/CCBR/bedops/bedmap/main.nf index b35406b..6f14a23 100644 --- a/tests/modules/CCBR/bedops/bedmap/main.nf +++ b/tests/modules/CCBR/bedops/bedmap/main.nf @@ -10,8 +10,8 @@ include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtool workflow test_bedops_bedmap { - ch_peaks = Channel.fromPath([file(params.test_data['macs_peaks_1'], checkIfExists: true), - file(params.test_data['macs_peaks_2'], checkIfExists: true)]) + ch_peaks = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true)]) .map { peak -> [ [id: peak.baseName, group: 'macs_broad'], peak ] } diff --git a/tests/modules/CCBR/custom/consensuspeaks/main.nf b/tests/modules/CCBR/custom/consensuspeaks/main.nf index 0b33660..5288576 100644 --- a/tests/modules/CCBR/custom/consensuspeaks/main.nf +++ b/tests/modules/CCBR/custom/consensuspeaks/main.nf @@ -8,8 +8,8 @@ workflow test_custom_consensuspeaks { input = [ [ id: 'test', group: 'macs_broad' ], // meta map - [ file(params.test_data['macs_peaks_1'], checkIfExists: true), - file(params.test_data['macs_peaks_2'], checkIfExists: true), + [ file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true), ] ] From d46e529b8ca9232c9964814f54d3d302d7bf57a8 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 12:38:16 -0500 Subject: [PATCH 25/47] refactor: fix ref bed name --- tests/modules/CCBR/bedops/bedmap/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/CCBR/bedops/bedmap/main.nf b/tests/modules/CCBR/bedops/bedmap/main.nf index 6f14a23..f1f13d2 100644 --- a/tests/modules/CCBR/bedops/bedmap/main.nf +++ b/tests/modules/CCBR/bedops/bedmap/main.nf @@ -23,10 +23,10 @@ workflow test_bedops_bedmap { .groupTuple() | CAT_CAT SORT_CAT(CAT_CAT.out.file_out, []) SORT_CAT.out.sorted | BEDTOOLS_MERGE - map_bed = BEDTOOLS_MERGE.out.bed.map{ meta, bed -> bed } + ref_bed = BEDTOOLS_MERGE.out.bed.map{ meta, bed -> bed } // map peaks to reference SORT_PEAK(ch_peaks, []) SORT_PEAK.out.sorted | view - BEDOPS_BEDMAP( SORT_PEAK.out.sorted.combine(map_bed) ) + BEDOPS_BEDMAP( SORT_PEAK.out.sorted.combine(ref_bed) ) } From 8e31f3432b8c0a2caff472f556fe752927d6b908 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 28 Nov 2023 15:23:43 -0500 Subject: [PATCH 26/47] refactor: don't delete intermediate files --- .../custom/consensuspeaks/templates/get_consensus_peaks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py index 089f213..cec8a0e 100755 --- a/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py +++ b/modules/CCBR/custom/consensuspeaks/templates/get_consensus_peaks.py @@ -11,7 +11,7 @@ def main(peakfiles, outbed, filter, nofilter): deleteFiles = [] - rand_name = str(uuid.uuid4()) + rand_name = "" # str(uuid.uuid4()) # concat cmd = "cat" @@ -96,8 +96,8 @@ def main(peakfiles, outbed, filter, nofilter): % (chrom, start, end, row["peakid"], float(row["score"])) ) - for f in deleteFiles: - os.remove(f) + # for f in deleteFiles: + # os.remove(f) def write_versions(): From dbc2219505802630bc7012d1dc74950cea972b13 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 10:46:02 -0500 Subject: [PATCH 27/47] feat: keep ref meta.id in bedmap outfiles --- modules/CCBR/bedops/bedmap/main.nf | 8 ++++---- tests/modules/CCBR/bedops/bedmap/main.nf | 4 +--- tests/modules/CCBR/bedops/bedmap/test.yml | 16 ++++++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/modules/CCBR/bedops/bedmap/main.nf b/modules/CCBR/bedops/bedmap/main.nf index 102529a..84289be 100644 --- a/modules/CCBR/bedops/bedmap/main.nf +++ b/modules/CCBR/bedops/bedmap/main.nf @@ -1,10 +1,10 @@ process BEDOPS_BEDMAP { - tag { meta.id } + tag "${meta.id}.${refmeta.id}" label 'process_single' container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' input: - tuple val(meta), path(mapbed), path(refbed) + tuple val(meta), path(mapbed), val(refmeta), path(refbed) output: tuple val(meta), path("*.mapped.bed"), emit: bed @@ -21,7 +21,7 @@ process BEDOPS_BEDMAP { --count \\ ${refbed} \\ ${mapbed} \\ - > ${meta.id}.mapped.bed + > ${meta.id}.${refmeta.id}.mapped.bed cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -31,7 +31,7 @@ process BEDOPS_BEDMAP { stub: """ - touch ${meta.id}.mapped.bed + touch ${meta.id}.${refmeta.id}.mapped.bed cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/tests/modules/CCBR/bedops/bedmap/main.nf b/tests/modules/CCBR/bedops/bedmap/main.nf index f1f13d2..f04badd 100644 --- a/tests/modules/CCBR/bedops/bedmap/main.nf +++ b/tests/modules/CCBR/bedops/bedmap/main.nf @@ -23,10 +23,8 @@ workflow test_bedops_bedmap { .groupTuple() | CAT_CAT SORT_CAT(CAT_CAT.out.file_out, []) SORT_CAT.out.sorted | BEDTOOLS_MERGE - ref_bed = BEDTOOLS_MERGE.out.bed.map{ meta, bed -> bed } // map peaks to reference SORT_PEAK(ch_peaks, []) - SORT_PEAK.out.sorted | view - BEDOPS_BEDMAP( SORT_PEAK.out.sorted.combine(ref_bed) ) + SORT_PEAK.out.sorted.combine(BEDTOOLS_MERGE.out.bed) | BEDOPS_BEDMAP } diff --git a/tests/modules/CCBR/bedops/bedmap/test.yml b/tests/modules/CCBR/bedops/bedmap/test.yml index 8e039b4..9965749 100644 --- a/tests/modules/CCBR/bedops/bedmap/test.yml +++ b/tests/modules/CCBR/bedops/bedmap/test.yml @@ -1,12 +1,12 @@ -- name: test_bedops_bedmap +- name: bedops bedmap test_bedops_bedmap command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config tags: - - bedops/bedmap - bedops + - bedops/bedmap files: - - path: output/bedops_bedmap/SPT5_T0_1_peaks.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_1_peaks.test.mapped.bed md5sum: a46e2f78e8534ecdc882fff22f0baa87 - - path: output/bedops_bedmap/SPT5_T0_2_peaks.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_2_peaks.test.mapped.bed md5sum: c58be7ebe1f63c1cdf9eef66a41e23c1 - path: output/bedops_bedmap/versions.yml - path: output/bedtools_merge/test.merged.bed @@ -24,14 +24,14 @@ md5sum: d3216918f24ced4b76b8eed6e38aa5c6 - path: output/sort_peak/versions.yml -- name: test_bedops_bedmap stub +- name: bedops bedmap test_bedops_bedmap stub command: nextflow run ./tests/modules/CCBR/bedops/bedmap -entry test_bedops_bedmap -c ./tests/config/nextflow.config -stub tags: - - bedops/bedmap - bedops + - bedops/bedmap files: - - path: output/bedops_bedmap/SPT5_T0_1_peaks.mapped.bed - - path: output/bedops_bedmap/SPT5_T0_2_peaks.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_1_peaks.test.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_2_peaks.test.mapped.bed - path: output/bedops_bedmap/versions.yml - path: output/bedtools_merge/test.merged.bed - path: output/bedtools_merge/versions.yml From e11988dbe754e1ddd208a988f2caf2f06f3dd05f Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 11:48:06 -0500 Subject: [PATCH 28/47] feat: create custom/combinepeaks module for consensus subwf --- modules/CCBR/custom/combinepeaks/main.nf | 43 +++++++++++++++ modules/CCBR/custom/combinepeaks/meta.yml | 55 +++++++++++++++++++ .../combinepeaks/templates/combine_peaks.R | 28 ++++++++++ tests/config/pytest_modules.yml | 4 ++ .../modules/CCBR/custom/combinepeaks/main.nf | 38 +++++++++++++ .../CCBR/custom/combinepeaks/nextflow.config | 7 +++ .../modules/CCBR/custom/combinepeaks/test.yml | 0 7 files changed, 175 insertions(+) create mode 100644 modules/CCBR/custom/combinepeaks/main.nf create mode 100644 modules/CCBR/custom/combinepeaks/meta.yml create mode 100644 modules/CCBR/custom/combinepeaks/templates/combine_peaks.R create mode 100644 tests/modules/CCBR/custom/combinepeaks/main.nf create mode 100644 tests/modules/CCBR/custom/combinepeaks/nextflow.config create mode 100644 tests/modules/CCBR/custom/combinepeaks/test.yml diff --git a/modules/CCBR/custom/combinepeaks/main.nf b/modules/CCBR/custom/combinepeaks/main.nf new file mode 100644 index 0000000..a8c95bb --- /dev/null +++ b/modules/CCBR/custom/combinepeaks/main.nf @@ -0,0 +1,43 @@ +process CUSTOM_COMBINEPEAKS { + """ + A helper script for the consensus_peaks subworkflow + """ + tag { meta.id } + label 'process_single' + + container 'nciccbr/spacesavers2:0.1.1' + + input: + tuple val(meta), path(peakcounts) + + output: + tuple val(meta), path("*.consensus.bed"), emit: bed + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + def outfile = "${prefix}.consensus.bed" + def count_files = peakcounts.join(' ') + """ + template 'combine_peaks.R' + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + : \$(echo \$(R --version | grep 'R version' | sed 's/R version //; s/ (.*//')) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.consensus.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + : \$(echo \$(R --version | grep 'R version' | sed 's/R version //; s/ (.*//')) + END_VERSIONS + """ +} diff --git a/modules/CCBR/custom/combinepeaks/meta.yml b/modules/CCBR/custom/combinepeaks/meta.yml new file mode 100644 index 0000000..3df21a4 --- /dev/null +++ b/modules/CCBR/custom/combinepeaks/meta.yml @@ -0,0 +1,55 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json +name: "custom_combinepeaks" +## TODO nf-core: Add a description of the module and list keywords +description: write your description here +keywords: + - sort + - example + - genomics +tools: + - "custom": + ## TODO nf-core: Add a description and other details for the software below + description: "" + homepage: "" + documentation: "" + tool_dev_url: "" + doi: "" + licence: "" + +## TODO nf-core: Add a description of all of the variables used as input +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + ## TODO nf-core: Delete / customise this example input + - bam: + type: file + description: Sorted BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +## TODO nf-core: Add a description of all of the variables used as output +output: + #Only when we have meta + - 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" + ## TODO nf-core: Delete / customise this example output + - bam: + type: file + description: Sorted BAM/CRAM/SAM file + pattern: "*.{bam,cram,sam}" + +authors: + - "@kelly-sovacool" diff --git a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R b/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R new file mode 100644 index 0000000..ae3e7fa --- /dev/null +++ b/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R @@ -0,0 +1,28 @@ +library(dplyr) +library(purrr) +library(stringr) +library(readr) +library(tidyr) + +main <- function() { + dat <- combine_peaks(unlist(str_split("${count_files}", " "))) + write_tsv(dat, "${outfile}", col_names = FALSE) +} + +combine_peaks <- function(count_files) { + count_dat <- count_files %>% + map(function(file) { + dat <- read_tsv(file, col_names = FALSE) + colnames(dat) <- c("peakID", "count") + return(dat %>% mutate(file = file)) + }) %>% + list_rbind() %>% + group_by(peakID) %>% + summarize(score = sum(count) / length(count_files)) %>% + separate_wider_delim(peakID, ":", names = c("chrom", "coords"), cols_remove = FALSE) %>% + separate_wider_delim(coords, "-", names = c("start", "end")) %>% + mutate(strand = ".", signal = NA, pvalue = NA, qvalue = NA) + return(count_dat) +} + +main() diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 1475144..21b2cf8 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -34,6 +34,10 @@ custom/bam2fastq: - modules/CCBR/custom/bam2fastq/** - tests/modules/CCBR/custom/bam2fastq/** +custom/combinepeaks: + - modules/CCBR/custom/combinepeaks/** + - tests/modules/CCBR/custom/combinepeaks/** + custom/consensuspeaks: - modules/CCBR/custom/consensuspeaks/** - tests/modules/CCBR/custom/consensuspeaks/** diff --git a/tests/modules/CCBR/custom/combinepeaks/main.nf b/tests/modules/CCBR/custom/combinepeaks/main.nf new file mode 100644 index 0000000..f40cebf --- /dev/null +++ b/tests/modules/CCBR/custom/combinepeaks/main.nf @@ -0,0 +1,38 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CAT_CAT } from '../../../../../modules/CCBR/cat/cat/main.nf' +include { BEDOPS_BEDMAP } from '../../../../../modules/CCBR/bedops/bedmap/main.nf' +include { BEDTOOLS_SORT as SORT_CAT + BEDTOOLS_SORT as SORT_PEAK } from '../../../../../modules/CCBR/bedtools/sort/main.nf' +include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf' +include { CUSTOM_COMBINEPEAKS } from '../../../../../modules/CCBR/custom/combinepeaks/main.nf' + +workflow test_custom_combinepeaks { + + ch_peaks = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true)]) + .map { peak -> + [ [id: peak.baseName, group: 'macs_broad'], peak ] + } + // prepare reference + ch_peaks + .map{ meta, peak -> + [ [id: 'test', group: 'macs_broad'], peak ] + } + .groupTuple() | CAT_CAT + SORT_CAT(CAT_CAT.out.file_out, []) + SORT_CAT.out.sorted | BEDTOOLS_MERGE + + // map peaks to reference + SORT_PEAK(ch_peaks, []) + SORT_PEAK.out.sorted.combine(BEDTOOLS_MERGE.out.bed) | BEDOPS_BEDMAP + + BEDOPS_BEDMAP.out.bed + .map { meta, bed -> + [ [id: meta.group], bed ] + } + .groupTuple() | + CUSTOM_COMBINEPEAKS +} diff --git a/tests/modules/CCBR/custom/combinepeaks/nextflow.config b/tests/modules/CCBR/custom/combinepeaks/nextflow.config new file mode 100644 index 0000000..e942eb5 --- /dev/null +++ b/tests/modules/CCBR/custom/combinepeaks/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].toLowerCase()}" } + +} + +includeConfig '../../../../config/test_data_CCBR.config' diff --git a/tests/modules/CCBR/custom/combinepeaks/test.yml b/tests/modules/CCBR/custom/combinepeaks/test.yml new file mode 100644 index 0000000..e69de29 From ed45eb8ba032d943a2071e230b8b8fdb7a6323c5 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 12:11:52 -0500 Subject: [PATCH 29/47] fix: template is nxf command, not bash --- modules/CCBR/custom/combinepeaks/main.nf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/CCBR/custom/combinepeaks/main.nf b/modules/CCBR/custom/combinepeaks/main.nf index a8c95bb..391c207 100644 --- a/modules/CCBR/custom/combinepeaks/main.nf +++ b/modules/CCBR/custom/combinepeaks/main.nf @@ -21,9 +21,8 @@ process CUSTOM_COMBINEPEAKS { def prefix = task.ext.prefix ?: "${meta.id}" def outfile = "${prefix}.consensus.bed" def count_files = peakcounts.join(' ') - """ template 'combine_peaks.R' - + """ cat <<-END_VERSIONS > versions.yml "${task.process}": : \$(echo \$(R --version | grep 'R version' | sed 's/R version //; s/ (.*//')) From 09f789824136aa5c4cdb6537ae5217f8b6d1c13e Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 12:37:35 -0500 Subject: [PATCH 30/47] fix: define vars for Rscript template --- modules/CCBR/custom/combinepeaks/main.nf | 12 +++--------- .../custom/combinepeaks/templates/combine_peaks.R | 9 ++++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/CCBR/custom/combinepeaks/main.nf b/modules/CCBR/custom/combinepeaks/main.nf index 391c207..334688e 100644 --- a/modules/CCBR/custom/combinepeaks/main.nf +++ b/modules/CCBR/custom/combinepeaks/main.nf @@ -18,16 +18,10 @@ process CUSTOM_COMBINEPEAKS { task.ext.when == null || task.ext.when script: - def prefix = task.ext.prefix ?: "${meta.id}" - def outfile = "${prefix}.consensus.bed" - def count_files = peakcounts.join(' ') + prefix = task.ext.prefix ?: "${meta.id}" + outfile = "${prefix}.consensus.bed" + count_files = "${peakcounts.join(',')}" template 'combine_peaks.R' - """ - cat <<-END_VERSIONS > versions.yml - "${task.process}": - : \$(echo \$(R --version | grep 'R version' | sed 's/R version //; s/ (.*//')) - END_VERSIONS - """ stub: def prefix = task.ext.prefix ?: "${meta.id}" diff --git a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R b/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R index ae3e7fa..c0b387e 100644 --- a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R +++ b/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R @@ -1,3 +1,4 @@ +#!/usr/bin/env Rscript library(dplyr) library(purrr) library(stringr) @@ -5,10 +6,16 @@ library(readr) library(tidyr) main <- function() { - dat <- combine_peaks(unlist(str_split("${count_files}", " "))) + write_lines(get_version(), "versions.yml") + print("${peakcounts}") + dat <- combine_peaks(unlist(str_split("${count_files}", ","))) write_tsv(dat, "${outfile}", col_names = FALSE) } +get_version <- function() { + return(paste0(R.version[["major"]], ".", R.version[["minor"]])) +} + combine_peaks <- function(count_files) { count_dat <- count_files %>% map(function(file) { From 9f5040ae8938b0cc838f9afd10c9f320fcdc1edb Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 12:51:35 -0500 Subject: [PATCH 31/47] feat: sort bed file to match original custom/consensuspeaks.py --- .../CCBR/custom/combinepeaks/templates/combine_peaks.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R b/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R index c0b387e..8c23b96 100644 --- a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R +++ b/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R @@ -25,10 +25,14 @@ combine_peaks <- function(count_files) { }) %>% list_rbind() %>% group_by(peakID) %>% - summarize(score = sum(count) / length(count_files)) %>% + summarize(score = format(sum(count) / length(count_files), nsmall = 3)) %>% separate_wider_delim(peakID, ":", names = c("chrom", "coords"), cols_remove = FALSE) %>% separate_wider_delim(coords, "-", names = c("start", "end")) %>% - mutate(strand = ".", signal = NA, pvalue = NA, qvalue = NA) + mutate( + start = as.numeric(start), end = as.numeric(end), + strand = ".", signal = NA, pvalue = NA, qvalue = NA + ) %>% + arrange(chrom, start, end) return(count_dat) } From 9639bb7878df2a70142a83d3d1bdfe066d58182e Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 12:52:03 -0500 Subject: [PATCH 32/47] test: create test yml for custom/combinepeaks --- .../modules/CCBR/custom/combinepeaks/test.yml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/modules/CCBR/custom/combinepeaks/test.yml b/tests/modules/CCBR/custom/combinepeaks/test.yml index e69de29..62229de 100644 --- a/tests/modules/CCBR/custom/combinepeaks/test.yml +++ b/tests/modules/CCBR/custom/combinepeaks/test.yml @@ -0,0 +1,49 @@ +- name: custom combinepeaks test_custom_combinepeaks + command: nextflow run ./tests/modules/CCBR/custom/combinepeaks -entry test_custom_combinepeaks -c ./tests/config/nextflow.config + tags: + - custom + - custom/combinepeaks + files: + - path: output/bedops_bedmap/SPT5_T0_1_peaks.test.mapped.bed + md5sum: a46e2f78e8534ecdc882fff22f0baa87 + - path: output/bedops_bedmap/SPT5_T0_2_peaks.test.mapped.bed + md5sum: c58be7ebe1f63c1cdf9eef66a41e23c1 + - path: output/bedops_bedmap/versions.yml + - path: output/bedtools_merge/test.merged.bed + md5sum: d67c8c15b99b310ec5aa0ec363dcd147 + - path: output/bedtools_merge/versions.yml + - path: output/cat_cat/test.broadPeak + md5sum: c5d73e727a10d2a32b139efcdd369f59 + - path: output/cat_cat/versions.yml + - path: output/custom_combinepeaks/macs_broad.consensus.bed + md5sum: 600f5c2dfeae440ada8c412c153a677e + - path: output/custom_combinepeaks/versions.yml + - path: output/sort_cat/test.sorted.broadPeak + md5sum: b412285368f1698634177087e7ea4103 + - path: output/sort_cat/versions.yml + - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak + md5sum: 03b87e9021f85db1c8e07f5c0b4d7347 + - path: output/sort_peak/SPT5_T0_2_peaks.sorted.broadPeak + md5sum: d3216918f24ced4b76b8eed6e38aa5c6 + - path: output/sort_peak/versions.yml + +- name: custom combinepeaks test_custom_combinepeaks stub + command: nextflow run ./tests/modules/CCBR/custom/combinepeaks -entry test_custom_combinepeaks -c ./tests/config/nextflow.config -stub + tags: + - custom + - custom/combinepeaks + files: + - path: output/bedops_bedmap/SPT5_T0_1_peaks.test.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_2_peaks.test.mapped.bed + - path: output/bedops_bedmap/versions.yml + - path: output/bedtools_merge/test.merged.bed + - path: output/bedtools_merge/versions.yml + - path: output/cat_cat/test.broadPeak + - path: output/cat_cat/versions.yml + - path: output/custom_combinepeaks/macs_broad.consensus.bed + - path: output/custom_combinepeaks/versions.yml + - path: output/sort_cat/test.sorted.broadPeak + - path: output/sort_cat/versions.yml + - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak + - path: output/sort_peak/SPT5_T0_2_peaks.sorted.broadPeak + - path: output/sort_peak/versions.yml From 1d65a57f0f41b3af3d5beb5a4af6a631848448cf Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 13:09:23 -0500 Subject: [PATCH 33/47] refactor: rename 'combinepeaks' -> 'combinepeakcounts' --- CHANGELOG.md | 1 + .../main.nf | 6 +++--- .../meta.yml | 2 +- .../templates/combine_peaks.R | 9 ++++++++- tests/config/pytest_modules.yml | 6 +++--- .../main.nf | 4 ++-- .../nextflow.config | 0 .../test.yml | 20 +++++++++---------- 8 files changed, 28 insertions(+), 20 deletions(-) rename modules/CCBR/custom/{combinepeaks => combinepeakcounts}/main.nf (87%) rename modules/CCBR/custom/{combinepeaks => combinepeakcounts}/meta.yml (97%) rename modules/CCBR/custom/{combinepeaks => combinepeakcounts}/templates/combine_peaks.R (91%) rename tests/modules/CCBR/custom/{combinepeaks => combinepeakcounts}/main.nf (90%) rename tests/modules/CCBR/custom/{combinepeaks => combinepeakcounts}/nextflow.config (100%) rename tests/modules/CCBR/custom/{combinepeaks => combinepeakcounts}/test.yml (69%) diff --git a/CHANGELOG.md b/CHANGELOG.md index af92ebf..9f1a943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Our documentation website is now live: (#16 - cat/cat (#37) - cat/fastq (#37) - custom/bam2fastq (#14,#22) +- custom/combinepeakcounts (#37) - custom/consensuspeaks (#37) - custom/convertsicer (#36) - custom/countfastq (#32) diff --git a/modules/CCBR/custom/combinepeaks/main.nf b/modules/CCBR/custom/combinepeakcounts/main.nf similarity index 87% rename from modules/CCBR/custom/combinepeaks/main.nf rename to modules/CCBR/custom/combinepeakcounts/main.nf index 334688e..24fd80f 100644 --- a/modules/CCBR/custom/combinepeaks/main.nf +++ b/modules/CCBR/custom/combinepeakcounts/main.nf @@ -1,4 +1,4 @@ -process CUSTOM_COMBINEPEAKS { +process CUSTOM_COMBINEPEAKCOUNTS { """ A helper script for the consensus_peaks subworkflow """ @@ -8,7 +8,7 @@ process CUSTOM_COMBINEPEAKS { container 'nciccbr/spacesavers2:0.1.1' input: - tuple val(meta), path(peakcounts) + tuple val(meta), path(counts) output: tuple val(meta), path("*.consensus.bed"), emit: bed @@ -20,7 +20,7 @@ process CUSTOM_COMBINEPEAKS { script: prefix = task.ext.prefix ?: "${meta.id}" outfile = "${prefix}.consensus.bed" - count_files = "${peakcounts.join(',')}" + count_files = "${counts.join(',')}" template 'combine_peaks.R' stub: diff --git a/modules/CCBR/custom/combinepeaks/meta.yml b/modules/CCBR/custom/combinepeakcounts/meta.yml similarity index 97% rename from modules/CCBR/custom/combinepeaks/meta.yml rename to modules/CCBR/custom/combinepeakcounts/meta.yml index 3df21a4..4f870a5 100644 --- a/modules/CCBR/custom/combinepeaks/meta.yml +++ b/modules/CCBR/custom/combinepeakcounts/meta.yml @@ -1,6 +1,6 @@ --- # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json -name: "custom_combinepeaks" +name: "custom_combinepeakcounts" ## TODO nf-core: Add a description of the module and list keywords description: write your description here keywords: diff --git a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R b/modules/CCBR/custom/combinepeakcounts/templates/combine_peaks.R similarity index 91% rename from modules/CCBR/custom/combinepeaks/templates/combine_peaks.R rename to modules/CCBR/custom/combinepeakcounts/templates/combine_peaks.R index 8c23b96..657c6ef 100644 --- a/modules/CCBR/custom/combinepeaks/templates/combine_peaks.R +++ b/modules/CCBR/custom/combinepeakcounts/templates/combine_peaks.R @@ -7,7 +7,6 @@ library(tidyr) main <- function() { write_lines(get_version(), "versions.yml") - print("${peakcounts}") dat <- combine_peaks(unlist(str_split("${count_files}", ","))) write_tsv(dat, "${outfile}", col_names = FALSE) } @@ -36,4 +35,12 @@ combine_peaks <- function(count_files) { return(count_dat) } +join_peaks <- function(peakfiles) { + return() +} + +normalize_scores <- function(dat) { + return() +} + main() diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 21b2cf8..ee29009 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -34,9 +34,9 @@ custom/bam2fastq: - modules/CCBR/custom/bam2fastq/** - tests/modules/CCBR/custom/bam2fastq/** -custom/combinepeaks: - - modules/CCBR/custom/combinepeaks/** - - tests/modules/CCBR/custom/combinepeaks/** +custom/combinepeakcounts: + - modules/CCBR/custom/combinepeakcounts/** + - tests/modules/CCBR/custom/combinepeakcounts/** custom/consensuspeaks: - modules/CCBR/custom/consensuspeaks/** diff --git a/tests/modules/CCBR/custom/combinepeaks/main.nf b/tests/modules/CCBR/custom/combinepeakcounts/main.nf similarity index 90% rename from tests/modules/CCBR/custom/combinepeaks/main.nf rename to tests/modules/CCBR/custom/combinepeakcounts/main.nf index f40cebf..51a536f 100644 --- a/tests/modules/CCBR/custom/combinepeaks/main.nf +++ b/tests/modules/CCBR/custom/combinepeakcounts/main.nf @@ -7,7 +7,7 @@ include { BEDOPS_BEDMAP } from '../../../../../modules/CCBR/bedops/ include { BEDTOOLS_SORT as SORT_CAT BEDTOOLS_SORT as SORT_PEAK } from '../../../../../modules/CCBR/bedtools/sort/main.nf' include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf' -include { CUSTOM_COMBINEPEAKS } from '../../../../../modules/CCBR/custom/combinepeaks/main.nf' +include { CUSTOM_COMBINEPEAKCOUNTS } from '../../../../../modules/CCBR/custom/combinepeakcounts/main.nf' workflow test_custom_combinepeaks { @@ -34,5 +34,5 @@ workflow test_custom_combinepeaks { [ [id: meta.group], bed ] } .groupTuple() | - CUSTOM_COMBINEPEAKS + CUSTOM_COMBINEPEAKCOUNTS } diff --git a/tests/modules/CCBR/custom/combinepeaks/nextflow.config b/tests/modules/CCBR/custom/combinepeakcounts/nextflow.config similarity index 100% rename from tests/modules/CCBR/custom/combinepeaks/nextflow.config rename to tests/modules/CCBR/custom/combinepeakcounts/nextflow.config diff --git a/tests/modules/CCBR/custom/combinepeaks/test.yml b/tests/modules/CCBR/custom/combinepeakcounts/test.yml similarity index 69% rename from tests/modules/CCBR/custom/combinepeaks/test.yml rename to tests/modules/CCBR/custom/combinepeakcounts/test.yml index 62229de..3951d29 100644 --- a/tests/modules/CCBR/custom/combinepeaks/test.yml +++ b/tests/modules/CCBR/custom/combinepeakcounts/test.yml @@ -1,8 +1,8 @@ -- name: custom combinepeaks test_custom_combinepeaks - command: nextflow run ./tests/modules/CCBR/custom/combinepeaks -entry test_custom_combinepeaks -c ./tests/config/nextflow.config +- name: custom combinepeakcounts test_custom_combinepeakcounts + command: nextflow run ./tests/modules/CCBR/custom/combinepeakcounts -entry test_custom_combinepeakcounts -c ./tests/config/nextflow.config tags: - custom - - custom/combinepeaks + - custom/combinepeakcounts files: - path: output/bedops_bedmap/SPT5_T0_1_peaks.test.mapped.bed md5sum: a46e2f78e8534ecdc882fff22f0baa87 @@ -15,9 +15,9 @@ - path: output/cat_cat/test.broadPeak md5sum: c5d73e727a10d2a32b139efcdd369f59 - path: output/cat_cat/versions.yml - - path: output/custom_combinepeaks/macs_broad.consensus.bed + - path: output/custom_combinepeakcounts/macs_broad.consensus.bed md5sum: 600f5c2dfeae440ada8c412c153a677e - - path: output/custom_combinepeaks/versions.yml + - path: output/custom_combinepeakcounts/versions.yml - path: output/sort_cat/test.sorted.broadPeak md5sum: b412285368f1698634177087e7ea4103 - path: output/sort_cat/versions.yml @@ -27,11 +27,11 @@ md5sum: d3216918f24ced4b76b8eed6e38aa5c6 - path: output/sort_peak/versions.yml -- name: custom combinepeaks test_custom_combinepeaks stub - command: nextflow run ./tests/modules/CCBR/custom/combinepeaks -entry test_custom_combinepeaks -c ./tests/config/nextflow.config -stub +- name: custom combinepeakcounts test_custom_combinepeakcounts stub + command: nextflow run ./tests/modules/CCBR/custom/combinepeakcounts -entry test_custom_combinepeakcounts -c ./tests/config/nextflow.config -stub tags: - custom - - custom/combinepeaks + - custom/combinepeakcounts files: - path: output/bedops_bedmap/SPT5_T0_1_peaks.test.mapped.bed - path: output/bedops_bedmap/SPT5_T0_2_peaks.test.mapped.bed @@ -40,8 +40,8 @@ - path: output/bedtools_merge/versions.yml - path: output/cat_cat/test.broadPeak - path: output/cat_cat/versions.yml - - path: output/custom_combinepeaks/macs_broad.consensus.bed - - path: output/custom_combinepeaks/versions.yml + - path: output/custom_combinepeakcounts/macs_broad.consensus.bed + - path: output/custom_combinepeakcounts/versions.yml - path: output/sort_cat/test.sorted.broadPeak - path: output/sort_cat/versions.yml - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak From 2b5f3f7d0fb9d3986376d566bbf6f2eb2c9a818d Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:44:17 -0500 Subject: [PATCH 34/47] feat: create module to normalize consensus peaks --- modules/CCBR/custom/normalizepeaks/main.nf | 34 ++++++++++ modules/CCBR/custom/normalizepeaks/meta.yml | 50 +++++++++++++++ .../templates/normalize_peaks.R | 64 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ .../CCBR/custom/normalizepeaks/main.nf | 51 +++++++++++++++ .../custom/normalizepeaks/nextflow.config | 6 ++ .../CCBR/custom/normalizepeaks/test.yml | 54 ++++++++++++++++ 7 files changed, 263 insertions(+) create mode 100644 modules/CCBR/custom/normalizepeaks/main.nf create mode 100644 modules/CCBR/custom/normalizepeaks/meta.yml create mode 100644 modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R create mode 100644 tests/modules/CCBR/custom/normalizepeaks/main.nf create mode 100644 tests/modules/CCBR/custom/normalizepeaks/nextflow.config create mode 100644 tests/modules/CCBR/custom/normalizepeaks/test.yml diff --git a/modules/CCBR/custom/normalizepeaks/main.nf b/modules/CCBR/custom/normalizepeaks/main.nf new file mode 100644 index 0000000..3ce9693 --- /dev/null +++ b/modules/CCBR/custom/normalizepeaks/main.nf @@ -0,0 +1,34 @@ +process CUSTOM_NORMALIZEPEAKS { + """ + Normalize p-values and q-values for consensus peaks + """ + tag { meta.id } + label 'process_single' + + container 'nciccbr/spacesavers2:0.1.1' + + input: + tuple val(meta), path(count), path(peaks) + + output: + tuple val(meta), path("*norm.bed"), emit: bed + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + prefix = task.ext.prefix ?: "${meta.id}" + outfile = "${count.baseName}.norm.bed" + template 'normalize_peaks.R' + + stub: + """ + touch ${count.baseName}.norm.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + : \$(echo \$(R --version | grep 'R version' | sed 's/R version //; s/ (.*//')) + END_VERSIONS + """ +} diff --git a/modules/CCBR/custom/normalizepeaks/meta.yml b/modules/CCBR/custom/normalizepeaks/meta.yml new file mode 100644 index 0000000..65b1aab --- /dev/null +++ b/modules/CCBR/custom/normalizepeaks/meta.yml @@ -0,0 +1,50 @@ +--- +name: "custom_normalizepeaks" +description: normalize p-values and q-values of consensus peaks with the method from Corces et al. (https://doi.org/10.1126/science.aav1898) +keywords: + - chipseq + - peaks + - consensus + - normalization +tools: + - "R": + description: "R is a free software environment for statistical computing and graphics" + homepage: "https://www.r-project.org/" + licence: "GPL-3" + +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - count: + type: file + description: consensus peak file from custom/combinepeakcounts + pattern: "*.bed" + - peaks: + type: file + description: merged and sorted peak file + pattern: "*.bed" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - peaks: + type: file + description: | + consensus peak file with normalized p-values and q-values + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R b/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R new file mode 100644 index 0000000..a651f0e --- /dev/null +++ b/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R @@ -0,0 +1,64 @@ +#!/usr/bin/env Rscript +library(dplyr) +library(glue) +library(purrr) +library(stringr) +library(readr) +library(tidyr) + +main <- function() { + write_lines(get_version(), "versions.yml") + count_dat <- read_peaks("${count}") + peak_dat <- read_peaks("${peaks}") %>% + mutate(peakID = glue("{chrom}:{start}-{end}")) %>% + normalize() %>% + select(peakID, pvalue, qvalue) + count_dat %>% + select(-c(pvalue, qvalue)) %>% + left_join(peak_dat, by = "peakID") %>% + write_tsv("${outfile}", col_names = FALSE) +} + +get_version <- function() { + return(paste0(R.version[["major"]], ".", R.version[["minor"]])) +} + +read_peaks <- function(peak_file) { + peak_colnames <- c( + "chrom", + "start", + "end", + "peakID", + "score", + "strand", + "signal", + "pvalue", + "qvalue", + "peak" + ) + peaks <- read_tsv(peak_file, col_names = FALSE) + colnames(peaks) <- peak_colnames[seq_len(ncol(peaks))] + return(peaks) +} + +normalize <- function(peak_dat, norm_method = corces) { + return( + peak_dat %>% + group_by(peakID) %>% + mutate( + pvalue_norm = norm_method(pvalue), + qvalue_norm = 10^(-pvalue_norm) %>% p.adjust(method = "BH") %>% -log10(.) + ) %>% + slice_max(pvalue_norm) %>% + select(-c(pvalue, qvalue)) %>% + rename(pvalue = pvalue_norm, qvalue = qvalue_norm) + ) +} + +#' Normalize consensus peak values with the method from Corces et al. +#' https://doi.org/10.1126/science.aav1898 +corces <- function(x) { + return(x / sum(x) / 10^6) +} + +main() diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index ee29009..0010849 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -50,6 +50,10 @@ custom/countfastq: - modules/CCBR/custom/countfastq/** - tests/modules/CCBR/custom/countfastq/** +custom/normalizepeaks: + - modules/CCBR/custom/normalizepeaks/** + - tests/modules/CCBR/custom/normalizepeaks/** + cutadapt: - modules/CCBR/cutadapt/** - tests/modules/CCBR/cutadapt/** diff --git a/tests/modules/CCBR/custom/normalizepeaks/main.nf b/tests/modules/CCBR/custom/normalizepeaks/main.nf new file mode 100644 index 0000000..c2f0ec2 --- /dev/null +++ b/tests/modules/CCBR/custom/normalizepeaks/main.nf @@ -0,0 +1,51 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CAT_CAT } from '../../../../../modules/CCBR/cat/cat/main.nf' +include { BEDOPS_BEDMAP } from '../../../../../modules/CCBR/bedops/bedmap/main.nf' +include { BEDTOOLS_SORT as SORT_CAT + BEDTOOLS_SORT as SORT_PEAK } from '../../../../../modules/CCBR/bedtools/sort/main.nf' +include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf' +include { CUSTOM_COMBINEPEAKCOUNTS } from '../../../../../modules/CCBR/custom/combinepeakcounts/main.nf' +include { CUSTOM_NORMALIZEPEAKS } from '../../../../../modules/CCBR/custom/normalizepeaks/main.nf' + +workflow test_custom_normalizepeaks { + + ch_peaks = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true)]) + .map { peak -> + [ [id: peak.baseName, group: 'macs_broad'], peak ] + } + // prepare reference + peaks_grouped = ch_peaks + .map{ meta, peak -> + [ [id: meta.group], peak ] + } + .groupTuple() + peaks_grouped | CAT_CAT + SORT_CAT(CAT_CAT.out.file_out, []) + SORT_CAT.out.sorted | BEDTOOLS_MERGE + + // map peaks to reference + SORT_PEAK(ch_peaks, []) + SORT_PEAK.out.sorted.combine(BEDTOOLS_MERGE.out.bed) | BEDOPS_BEDMAP + + counts_grouped = BEDOPS_BEDMAP.out.bed + .map { meta, bed -> + [ [id: meta.group], bed ] + } + .groupTuple() + counts_grouped | CUSTOM_COMBINEPEAKCOUNTS + + ch_count_peak = CUSTOM_COMBINEPEAKCOUNTS.out.bed + .cross(SORT_CAT.out.sorted) + .map{ it -> + it.flatten() + } + .map{ meta1, count, meta2, peak -> + assert meta1.id == meta2.id + [ meta1, count, peak ] + } + ch_count_peak | CUSTOM_NORMALIZEPEAKS +} diff --git a/tests/modules/CCBR/custom/normalizepeaks/nextflow.config b/tests/modules/CCBR/custom/normalizepeaks/nextflow.config new file mode 100644 index 0000000..f6762c2 --- /dev/null +++ b/tests/modules/CCBR/custom/normalizepeaks/nextflow.config @@ -0,0 +1,6 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].toLowerCase()}" } + +} +includeConfig '../../../../config/test_data_CCBR.config' diff --git a/tests/modules/CCBR/custom/normalizepeaks/test.yml b/tests/modules/CCBR/custom/normalizepeaks/test.yml new file mode 100644 index 0000000..771d859 --- /dev/null +++ b/tests/modules/CCBR/custom/normalizepeaks/test.yml @@ -0,0 +1,54 @@ +- name: custom normalizepeaks test_custom_normalizepeaks + command: nextflow run ./tests/modules/CCBR/custom/normalizepeaks -entry test_custom_normalizepeaks -c ./tests/config/nextflow.config + tags: + - custom/normalizepeaks + - custom + files: + - path: output/bedops_bedmap/SPT5_T0_1_peaks.macs_broad.mapped.bed + md5sum: a46e2f78e8534ecdc882fff22f0baa87 + - path: output/bedops_bedmap/SPT5_T0_2_peaks.macs_broad.mapped.bed + md5sum: c58be7ebe1f63c1cdf9eef66a41e23c1 + - path: output/bedops_bedmap/versions.yml + - path: output/bedtools_merge/macs_broad.merged.bed + md5sum: d67c8c15b99b310ec5aa0ec363dcd147 + - path: output/bedtools_merge/versions.yml + - path: output/cat_cat/macs_broad.broadPeak + md5sum: c5d73e727a10d2a32b139efcdd369f59 + - path: output/cat_cat/versions.yml + - path: output/custom_combinepeakcounts/macs_broad.consensus.bed + md5sum: 600f5c2dfeae440ada8c412c153a677e + - path: output/custom_combinepeakcounts/versions.yml + - path: output/custom_normalizepeaks/macs_broad.consensus.norm.bed + md5sum: 91162a273adbde73bec3dfd0d87c16fd + - path: output/custom_normalizepeaks/versions.yml + - path: output/sort_cat/macs_broad.sorted.broadPeak + md5sum: b412285368f1698634177087e7ea4103 + - path: output/sort_cat/versions.yml + - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak + md5sum: 03b87e9021f85db1c8e07f5c0b4d7347 + - path: output/sort_peak/SPT5_T0_2_peaks.sorted.broadPeak + md5sum: d3216918f24ced4b76b8eed6e38aa5c6 + - path: output/sort_peak/versions.yml + +- name: custom normalizepeaks test_custom_normalizepeaks stub + command: nextflow run ./tests/modules/CCBR/custom/normalizepeaks -entry test_custom_normalizepeaks -c ./tests/config/nextflow.config -stub + tags: + - custom/normalizepeaks + - custom + files: + - path: output/bedops_bedmap/SPT5_T0_1_peaks.macs_broad.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_2_peaks.macs_broad.mapped.bed + - path: output/bedops_bedmap/versions.yml + - path: output/bedtools_merge/macs_broad.merged.bed + - path: output/bedtools_merge/versions.yml + - path: output/cat_cat/macs_broad.broadPeak + - path: output/cat_cat/versions.yml + - path: output/custom_combinepeakcounts/macs_broad.consensus.bed + - path: output/custom_combinepeakcounts/versions.yml + - path: output/custom_normalizepeaks/macs_broad.consensus.norm.bed + - path: output/custom_normalizepeaks/versions.yml + - path: output/sort_cat/macs_broad.sorted.broadPeak + - path: output/sort_cat/versions.yml + - path: output/sort_peak/SPT5_T0_1_peaks.sorted.broadPeak + - path: output/sort_peak/SPT5_T0_2_peaks.sorted.broadPeak + - path: output/sort_peak/versions.yml From 097db63978e11213a5bd7600881ae33baa907cd6 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:47:37 -0500 Subject: [PATCH 35/47] refactor: set nxf variables as defaults --- .../normalizepeaks/templates/normalize_peaks.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R b/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R index a651f0e..c0a6c0c 100644 --- a/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R +++ b/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R @@ -6,17 +6,17 @@ library(stringr) library(readr) library(tidyr) -main <- function() { - write_lines(get_version(), "versions.yml") - count_dat <- read_peaks("${count}") - peak_dat <- read_peaks("${peaks}") %>% +main <- function(versionfile = "versions.yml", counfile = "${count}", peakfile = "${peaks}", outfile = "${outfile}") { + write_lines(get_version(), versionfile) + count_dat <- read_peaks(countfile) + peak_dat <- read_peaks(peakfile) %>% mutate(peakID = glue("{chrom}:{start}-{end}")) %>% normalize() %>% select(peakID, pvalue, qvalue) count_dat %>% select(-c(pvalue, qvalue)) %>% left_join(peak_dat, by = "peakID") %>% - write_tsv("${outfile}", col_names = FALSE) + write_tsv(outfile, col_names = FALSE) } get_version <- function() { @@ -61,4 +61,4 @@ corces <- function(x) { return(x / sum(x) / 10^6) } -main() +main("versions.yml", "${count}", "${peaks}", "${outfile}") From 01f7c4d7e64e749145f41d637bb74b70c140be4e Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:50:37 -0500 Subject: [PATCH 36/47] docs: update metadata for peak-related modules --- .../CCBR/custom/combinepeakcounts/meta.yml | 44 ++++++++----------- modules/CCBR/custom/normalizepeaks/meta.yml | 2 +- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/modules/CCBR/custom/combinepeakcounts/meta.yml b/modules/CCBR/custom/combinepeakcounts/meta.yml index 4f870a5..e9f8576 100644 --- a/modules/CCBR/custom/combinepeakcounts/meta.yml +++ b/modules/CCBR/custom/combinepeakcounts/meta.yml @@ -1,23 +1,16 @@ --- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json name: "custom_combinepeakcounts" -## TODO nf-core: Add a description of the module and list keywords -description: write your description here +description: combine counts into consensus peaks keywords: - - sort - - example - - genomics + - chipseq + - peaks + - consensus tools: - - "custom": - ## TODO nf-core: Add a description and other details for the software below - description: "" - homepage: "" - documentation: "" - tool_dev_url: "" - doi: "" - licence: "" + - "R": + description: "R is a free software environment for statistical computing and graphics" + homepage: "https://www.r-project.org/" + licence: "GPL-3" -## TODO nf-core: Add a description of all of the variables used as input input: # Only when we have meta - meta: @@ -26,30 +19,29 @@ input: Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - ## TODO nf-core: Delete / customise this example input - - bam: + - counts: type: file - description: Sorted BAM/CRAM/SAM file - pattern: "*.{bam,cram,sam}" + description: peak file from bedtools/bedmap + pattern: "*.bed" -## TODO nf-core: Add a description of all of the variables used as output output: - #Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` + - bed: + type: file + description: | + consensus peak file + - versions: type: file description: File containing software versions pattern: "versions.yml" - ## TODO nf-core: Delete / customise this example output - - bam: - type: file - description: Sorted BAM/CRAM/SAM file - pattern: "*.{bam,cram,sam}" authors: - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/modules/CCBR/custom/normalizepeaks/meta.yml b/modules/CCBR/custom/normalizepeaks/meta.yml index 65b1aab..aea2b2c 100644 --- a/modules/CCBR/custom/normalizepeaks/meta.yml +++ b/modules/CCBR/custom/normalizepeaks/meta.yml @@ -34,7 +34,7 @@ output: description: | Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - - peaks: + - bed: type: file description: | consensus peak file with normalized p-values and q-values From 3e97ce24af9a98b09bc8095360381a111f6d19b4 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:53:53 -0500 Subject: [PATCH 37/47] docs: fix typo --- modules/CCBR/custom/combinepeakcounts/meta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/CCBR/custom/combinepeakcounts/meta.yml b/modules/CCBR/custom/combinepeakcounts/meta.yml index e9f8576..8990f07 100644 --- a/modules/CCBR/custom/combinepeakcounts/meta.yml +++ b/modules/CCBR/custom/combinepeakcounts/meta.yml @@ -21,7 +21,7 @@ input: - counts: type: file - description: peak file from bedtools/bedmap + description: peak file from bedops/bedmap pattern: "*.bed" output: From 80f9ac2ebff9df9c9ace2413f855991f039ab7ee Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:55:11 -0500 Subject: [PATCH 38/47] feat: create consensus_peaks subwf a replacement for the custom/consensuspeaks module --- subworkflows/CCBR/consensus_peaks/main.nf | 58 +++++++++++++++++++ subworkflows/CCBR/consensus_peaks/meta.yml | 48 +++++++++++++++ tests/config/pytest_modules.yml | 4 ++ .../subworkflows/CCBR/consensus_peaks/main.nf | 19 ++++++ .../CCBR/consensus_peaks/nextflow.config | 7 +++ .../CCBR/consensus_peaks/test.yml | 0 6 files changed, 136 insertions(+) create mode 100644 subworkflows/CCBR/consensus_peaks/main.nf create mode 100644 subworkflows/CCBR/consensus_peaks/meta.yml create mode 100644 tests/subworkflows/CCBR/consensus_peaks/main.nf create mode 100644 tests/subworkflows/CCBR/consensus_peaks/nextflow.config create mode 100644 tests/subworkflows/CCBR/consensus_peaks/test.yml diff --git a/subworkflows/CCBR/consensus_peaks/main.nf b/subworkflows/CCBR/consensus_peaks/main.nf new file mode 100644 index 0000000..f501931 --- /dev/null +++ b/subworkflows/CCBR/consensus_peaks/main.nf @@ -0,0 +1,58 @@ +include { CAT_CAT } from '../../../modules/CCBR/cat/cat/' +include { BEDTOOLS_SORT } from '../../../modules/CCBR/bedtools/sort/' // TODO use unix sort for better performance +include { BEDTOOLS_MERGE } from '../../../modules/CCBR/bedtools/merge/' +include { BEDOPS_BEDMAP } from '../../../modules/CCBR/bedops/bedmap/' +include { CUSTOM_COMBINEPEAKCOUNTS } from '../../../modules/CCBR/custom/combinepeakcounts/' +include { CUSTOM_NORMALIZEPEAKS } from '../../../modules/CCBR/custom/normalizepeaks/' + +workflow CONSENSUS_PEAKS { + + take: + // channel: [ val(meta), peak ] + // meta should contain a group variable by which the peaks will be grouped + // peaks should already be sorted by chromosome name then by start pos + ch_peaks + // whether to normalize p-values and q-values + normalize + + main: + + ch_versions = Channel.empty() + + peaks_grouped = ch_peaks + .map{ meta, peak -> + [ [id: meta.group], peak ] + } + .groupTuple() + peaks_grouped | CAT_CAT + BEDTOOLS_SORT( CAT_CAT.out.file_out, [] ) + peaks_cat_sorted = BEDTOOLS_SORT.out.sorted + peaks_cat_sorted | BEDTOOLS_MERGE + ch_peaks.combine(BEDTOOLS_MERGE.out.bed) | BEDOPS_BEDMAP + + counts_grouped = BEDOPS_BEDMAP.out.bed + .map { meta, bed -> + [ [id: meta.group], bed ] + } + .groupTuple() + counts_grouped | CUSTOM_COMBINEPEAKCOUNTS + consensus_peaks = CUSTOM_COMBINEPEAKCOUNTS.out.bed + + if (normalize) { + ch_count_peak = CUSTOM_COMBINEPEAKCOUNTS.out.bed + .cross(peaks_cat_sorted) + .map{ it -> + it.flatten() + } + .map{ meta1, count, meta2, peak -> + assert meta1.id == meta2.id + [ meta1, count, peak ] + } + ch_count_peak | CUSTOM_NORMALIZEPEAKS + consensus_peaks = CUSTOM_NORMALIZEPEAKS.out.bed + } + + emit: + peaks = consensus_peaks + versions = ch_versions +} diff --git a/subworkflows/CCBR/consensus_peaks/meta.yml b/subworkflows/CCBR/consensus_peaks/meta.yml new file mode 100644 index 0000000..4cfe660 --- /dev/null +++ b/subworkflows/CCBR/consensus_peaks/meta.yml @@ -0,0 +1,48 @@ +name: "consensus_peaks" +description: | + Find consensus peaks from peak files, and optionally perform normalization. + This is an alternative to the custom/consensuspeaks module. +keywords: + - peaks + - chipseq + - normalization + - consensus +components: + - bedtools/sort + - bedtools/merge + - bedops/bedmap + - cat/cat + - custom/combinepeakcounts + - custom/normalizepeaks +input: + - ch_peaks: + type: file + description: | + The input channel containing the peak files. + Structure: [ val(meta), path(peak) ]. + Meta must contain a `group` variable by which the peaks will be grouped for consensus calling. + pattern: "*.{bed/narrowPeak/broadPeak}" + - normalize: + type: boolean + description: | + Whether to normalize p-values and q-values for consensus peaks. +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - peaks: + type: file + description: A single consensus peak file for each meta.group + pattern: "*.{broadPeak,narrowPeak,bed}" + - versions: + type: file + description: | + File containing software versions + Structure: [ path(versions.yml) ] + pattern: "versions.yml" +authors: + - "@kelly-sovacool" +maintainers: + - "@kelly-sovacool" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 0010849..7a2669c 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -70,6 +70,10 @@ samtools/filteraligned: - modules/CCBR/samtools/filteraligned/** - tests/modules/CCBR/samtools/filteraligned/** +subworkflows/consensus_peaks: + - subworkflows/CCBR/consensus_peaks/** + - tests/subworkflows/CCBR/consensus_peaks/** + subworkflows/filter_blacklist: - subworkflows/CCBR/filter_blacklist/** - tests/subworkflows/CCBR/filter_blacklist/** diff --git a/tests/subworkflows/CCBR/consensus_peaks/main.nf b/tests/subworkflows/CCBR/consensus_peaks/main.nf new file mode 100644 index 0000000..0d7329e --- /dev/null +++ b/tests/subworkflows/CCBR/consensus_peaks/main.nf @@ -0,0 +1,19 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { BEDTOOLS_SORT } from '../../../modules/CCBR/bedtools/sort/' +include { CONSENSUS_PEAKS } from '../../../../subworkflows/CCBR/consensus_peaks' + +workflow test_consensus_peaks_broad { + + input = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true)]) + .map { peak -> + [ [id: peak.baseName, group: 'macs_broad'], peak ] + } + BEDTOOLS_SORT(input, []) + peaks = BEDTOOLS_SORT.out.sorted + + CONSENSUS_PEAKS( peaks, false ) +} diff --git a/tests/subworkflows/CCBR/consensus_peaks/nextflow.config b/tests/subworkflows/CCBR/consensus_peaks/nextflow.config new file mode 100644 index 0000000..ca7a499 --- /dev/null +++ b/tests/subworkflows/CCBR/consensus_peaks/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].toLowerCase()}" } + +} + +includeConfig '../../../config/test_data_CCBR.config' diff --git a/tests/subworkflows/CCBR/consensus_peaks/test.yml b/tests/subworkflows/CCBR/consensus_peaks/test.yml new file mode 100644 index 0000000..e69de29 From 76110b2616e615e1bc83ea6c52982e2d2a5c259c Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:58:19 -0500 Subject: [PATCH 39/47] docs: add consensus_peaks subwf to changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f1a943..fef76b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,4 +26,5 @@ Our documentation website is now live: (#16 ### New subworkflows -- custom/filter_blacklist (#17,#27) +- consensus_peaks (#37) +- filter_blacklist (#17,#27) From 8692e3370ebdd691ae2a2ab2ccb783bbf6e386a1 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 14:59:07 -0500 Subject: [PATCH 40/47] docs: point users to consensus_peaks subwf from legacy module --- modules/CCBR/custom/consensuspeaks/meta.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/CCBR/custom/consensuspeaks/meta.yml b/modules/CCBR/custom/consensuspeaks/meta.yml index 52fa43e..cafe661 100644 --- a/modules/CCBR/custom/consensuspeaks/meta.yml +++ b/modules/CCBR/custom/consensuspeaks/meta.yml @@ -1,6 +1,9 @@ --- name: "custom_consensuspeaks" -description: Find consensus peaks from two or more peak files. +description: | + Find consensus peaks from two or more peak files. + The consensus_peaks subworkflow is a re-implementation of this module; + new pipelines should use the subworkflow instead. keywords: - peaks - chipseq From fe9a7da7f1eb8e05623199281276e0b76c8690b6 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:03:30 -0500 Subject: [PATCH 41/47] docs: move new modules & subwfs for next dev version --- CHANGELOG.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6996d6..f81f5a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,26 +2,30 @@ ### New modules +- bedops/bedmap (#37) +- bedtools/map (#37) +- bedtools/merge (#37) +- bedtools/sort (#37) +- cat/cat (#37) +- cat/fastq (#37) +- custom/combinepeakcounts (#37) +- custom/consensuspeaks (#37) +- custom/normalizepeaks (#37) + ### New subworkflows +- consensus_peaks (#37) + ## nf-modules 0.1.0 Our documentation website is now live: (#16) ### New modules -- bedops/bedmap (#37) -- bedtools/map (#37) -- bedtools/merge (#37) -- bedtools/sort (#37) - bwa/index - bwa/mem - also runs samtools sort & outputs index in bai format. (#12) -- cat/cat (#37) -- cat/fastq (#37) - custom/bam2fastq (#14,#22) -- custom/combinepeakcounts (#37) -- custom/consensuspeaks (#37) - custom/convertsicer (#36) - custom/countfastq (#32) - cutadapt (#11) @@ -32,5 +36,4 @@ Our documentation website is now live: (#16 ### New subworkflows -- consensus_peaks (#37) - filter_blacklist (#17,#27) From f81e205c996a533cc8896ef2f7f5eb0465671ac2 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:04:59 -0500 Subject: [PATCH 42/47] docs: license must be an array --- modules/CCBR/custom/combinepeakcounts/meta.yml | 2 +- modules/CCBR/custom/normalizepeaks/meta.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/CCBR/custom/combinepeakcounts/meta.yml b/modules/CCBR/custom/combinepeakcounts/meta.yml index 8990f07..54fca8b 100644 --- a/modules/CCBR/custom/combinepeakcounts/meta.yml +++ b/modules/CCBR/custom/combinepeakcounts/meta.yml @@ -9,7 +9,7 @@ tools: - "R": description: "R is a free software environment for statistical computing and graphics" homepage: "https://www.r-project.org/" - licence: "GPL-3" + licence: ["GPL-3"] input: # Only when we have meta diff --git a/modules/CCBR/custom/normalizepeaks/meta.yml b/modules/CCBR/custom/normalizepeaks/meta.yml index aea2b2c..f237555 100644 --- a/modules/CCBR/custom/normalizepeaks/meta.yml +++ b/modules/CCBR/custom/normalizepeaks/meta.yml @@ -10,7 +10,7 @@ tools: - "R": description: "R is a free software environment for statistical computing and graphics" homepage: "https://www.r-project.org/" - licence: "GPL-3" + licence: ["GPL-3"] input: # Only when we have meta From 7cbeb705bd891117af331b0728aeb9095baef784 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:11:58 -0500 Subject: [PATCH 43/47] test: creat test yml for consensus_peaks subwf --- .../CCBR/consensus_peaks/test.yml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/subworkflows/CCBR/consensus_peaks/test.yml b/tests/subworkflows/CCBR/consensus_peaks/test.yml index e69de29..09563f7 100644 --- a/tests/subworkflows/CCBR/consensus_peaks/test.yml +++ b/tests/subworkflows/CCBR/consensus_peaks/test.yml @@ -0,0 +1,57 @@ +- name: consensus_peaks test_consensus_peaks_broad + command: nextflow run ./tests/subworkflows/CCBR/consensus_peaks -entry test_consensus_peaks_broad -c ./tests/config/nextflow.config + tags: + - bedops + - bedops/bedmap + - bedtools + - bedtools/merge + - bedtools/sort + - cat + - cat/cat + - custom + - custom/combinepeakcounts + - custom/normalizepeaks + - subworkflows + - subworkflows/consensus_peaks + files: + - path: output/bedops_bedmap/SPT5_T0_1_peaks.macs_broad.mapped.bed + md5sum: a46e2f78e8534ecdc882fff22f0baa87 + - path: output/bedops_bedmap/SPT5_T0_2_peaks.macs_broad.mapped.bed + md5sum: c58be7ebe1f63c1cdf9eef66a41e23c1 + - path: output/bedtools_merge/macs_broad.merged.bed + md5sum: d67c8c15b99b310ec5aa0ec363dcd147 + - path: output/bedtools_sort/SPT5_T0_1_peaks.sorted.broadPeak + md5sum: 03b87e9021f85db1c8e07f5c0b4d7347 + - path: output/bedtools_sort/SPT5_T0_2_peaks.sorted.broadPeak + md5sum: d3216918f24ced4b76b8eed6e38aa5c6 + - path: output/bedtools_sort/macs_broad.sorted.broadPeak + md5sum: 2541c1a79171d255fd0582bd7ea80493 + - path: output/cat_cat/macs_broad.broadPeak + md5sum: 4c8d04c85c4782bf667297ecb23b6703 + - path: output/custom_combinepeakcounts/macs_broad.consensus.bed + md5sum: 600f5c2dfeae440ada8c412c153a677e + +- name: consensus_peaks test_consensus_peaks_broad stub + command: nextflow run ./tests/subworkflows/CCBR/consensus_peaks -entry test_consensus_peaks_broad -c ./tests/config/nextflow.config -stub + tags: + - bedops + - bedops/bedmap + - bedtools + - bedtools/merge + - bedtools/sort + - cat + - cat/cat + - custom + - custom/combinepeakcounts + - custom/normalizepeaks + - subworkflows + - subworkflows/consensus_peaks + files: + - path: output/bedops_bedmap/SPT5_T0_1_peaks.macs_broad.mapped.bed + - path: output/bedops_bedmap/SPT5_T0_2_peaks.macs_broad.mapped.bed + - path: output/bedtools_merge/macs_broad.merged.bed + - path: output/bedtools_sort/SPT5_T0_1_peaks.sorted.broadPeak + - path: output/bedtools_sort/SPT5_T0_2_peaks.sorted.broadPeak + - path: output/bedtools_sort/macs_broad.sorted.broadPeak + - path: output/cat_cat/macs_broad.broadPeak + - path: output/custom_combinepeakcounts/macs_broad.consensus.bed From 0773762b3d46cb809b62bb2bbc4d6d534e9a70d2 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:24:58 -0500 Subject: [PATCH 44/47] fix: typo in param name --- .../CCBR/custom/normalizepeaks/templates/normalize_peaks.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R b/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R index c0a6c0c..8981494 100644 --- a/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R +++ b/modules/CCBR/custom/normalizepeaks/templates/normalize_peaks.R @@ -6,7 +6,10 @@ library(stringr) library(readr) library(tidyr) -main <- function(versionfile = "versions.yml", counfile = "${count}", peakfile = "${peaks}", outfile = "${outfile}") { +main <- function(versionfile = "versions.yml", + countfile = "${count}", + peakfile = "${peaks}", + outfile = "${outfile}") { write_lines(get_version(), versionfile) count_dat <- read_peaks(countfile) peak_dat <- read_peaks(peakfile) %>% From 5dea69aa2583ba12d915f0b8c6ebe0ab3191ea6b Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:27:33 -0500 Subject: [PATCH 45/47] test: add test for normalized & mixed consensus groups --- .../subworkflows/CCBR/consensus_peaks/main.nf | 20 +++++++++++ .../CCBR/consensus_peaks/test.yml | 35 +++++++++++-------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/tests/subworkflows/CCBR/consensus_peaks/main.nf b/tests/subworkflows/CCBR/consensus_peaks/main.nf index 0d7329e..c1b1d08 100644 --- a/tests/subworkflows/CCBR/consensus_peaks/main.nf +++ b/tests/subworkflows/CCBR/consensus_peaks/main.nf @@ -5,6 +5,7 @@ nextflow.enable.dsl = 2 include { BEDTOOLS_SORT } from '../../../modules/CCBR/bedtools/sort/' include { CONSENSUS_PEAKS } from '../../../../subworkflows/CCBR/consensus_peaks' + workflow test_consensus_peaks_broad { input = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), @@ -17,3 +18,22 @@ workflow test_consensus_peaks_broad { CONSENSUS_PEAKS( peaks, false ) } + +workflow test_consensus_peaks_mix_norm { + + broad = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true)]) + .map { peak -> + [ [id: peak.baseName, group: 'macs_broad'], peak ] + } + narrow = Channel.fromPath([file(params.test_data.macs.narrow.peaks_T0_1, checkIfExists: true), + file(params.test_data.macs.narrow.peaks_T0_2, checkIfExists: true)]) + .map { peak -> + [ [id: peak.baseName, group: 'macs_narrow'], peak ] + } + input = broad.mix(narrow) + BEDTOOLS_SORT(input, []) + peaks = BEDTOOLS_SORT.out.sorted + + CONSENSUS_PEAKS( peaks, true ) +} diff --git a/tests/subworkflows/CCBR/consensus_peaks/test.yml b/tests/subworkflows/CCBR/consensus_peaks/test.yml index 09563f7..0ae0da3 100644 --- a/tests/subworkflows/CCBR/consensus_peaks/test.yml +++ b/tests/subworkflows/CCBR/consensus_peaks/test.yml @@ -14,20 +14,6 @@ - subworkflows - subworkflows/consensus_peaks files: - - path: output/bedops_bedmap/SPT5_T0_1_peaks.macs_broad.mapped.bed - md5sum: a46e2f78e8534ecdc882fff22f0baa87 - - path: output/bedops_bedmap/SPT5_T0_2_peaks.macs_broad.mapped.bed - md5sum: c58be7ebe1f63c1cdf9eef66a41e23c1 - - path: output/bedtools_merge/macs_broad.merged.bed - md5sum: d67c8c15b99b310ec5aa0ec363dcd147 - - path: output/bedtools_sort/SPT5_T0_1_peaks.sorted.broadPeak - md5sum: 03b87e9021f85db1c8e07f5c0b4d7347 - - path: output/bedtools_sort/SPT5_T0_2_peaks.sorted.broadPeak - md5sum: d3216918f24ced4b76b8eed6e38aa5c6 - - path: output/bedtools_sort/macs_broad.sorted.broadPeak - md5sum: 2541c1a79171d255fd0582bd7ea80493 - - path: output/cat_cat/macs_broad.broadPeak - md5sum: 4c8d04c85c4782bf667297ecb23b6703 - path: output/custom_combinepeakcounts/macs_broad.consensus.bed md5sum: 600f5c2dfeae440ada8c412c153a677e @@ -55,3 +41,24 @@ - path: output/bedtools_sort/macs_broad.sorted.broadPeak - path: output/cat_cat/macs_broad.broadPeak - path: output/custom_combinepeakcounts/macs_broad.consensus.bed + +- name: consensus_peaks test_consensus_peaks_mix_norm + command: nextflow run ./tests/subworkflows/CCBR/consensus_peaks -entry test_consensus_peaks_mix_norm -c ./tests/config/nextflow.config + tags: + - bedops + - bedops/bedmap + - bedtools + - bedtools/merge + - bedtools/sort + - cat + - cat/cat + - custom + - custom/combinepeakcounts + - custom/normalizepeaks + - subworkflows + - subworkflows/consensus_peaks + files: + - path: output/custom_normalizepeaks/macs_broad.consensus.norm.bed + md5sum: 9b133bf0d129a51491c9d722a7d577c0 + - path: output/custom_normalizepeaks/macs_narrow.consensus.norm.bed + md5sum: 29d222c145ef196b2cc11b304c3ed2ed From 74d899dcad73a710e522a51dad41850e2f2e8295 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:32:03 -0500 Subject: [PATCH 46/47] fix: mix process versions channel --- subworkflows/CCBR/consensus_peaks/main.nf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subworkflows/CCBR/consensus_peaks/main.nf b/subworkflows/CCBR/consensus_peaks/main.nf index f501931..8b37b03 100644 --- a/subworkflows/CCBR/consensus_peaks/main.nf +++ b/subworkflows/CCBR/consensus_peaks/main.nf @@ -50,8 +50,17 @@ workflow CONSENSUS_PEAKS { } ch_count_peak | CUSTOM_NORMALIZEPEAKS consensus_peaks = CUSTOM_NORMALIZEPEAKS.out.bed + ch_versions = ch_versions.mix(CUSTOM_NORMALIZEPEAKS.out.versions) } + ch_versions = ch_versions.mix( + CAT_CAT.out.versions, + BEDTOOLS_SORT.out.versions, + BEDTOOLS_MERGE.out.versions, + BEDOPS_BEDMAP.out.versions, + CUSTOM_COMBINEPEAKCOUNTS.out.versions + ) + emit: peaks = consensus_peaks versions = ch_versions From 8917fd9e6d5f1d2d9431cb8e9e36e4d8ac9ab994 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 29 Nov 2023 15:35:29 -0500 Subject: [PATCH 47/47] test: fix workflow entry name to mirrow new module name --- tests/modules/CCBR/custom/combinepeakcounts/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/CCBR/custom/combinepeakcounts/main.nf b/tests/modules/CCBR/custom/combinepeakcounts/main.nf index 51a536f..c93ba65 100644 --- a/tests/modules/CCBR/custom/combinepeakcounts/main.nf +++ b/tests/modules/CCBR/custom/combinepeakcounts/main.nf @@ -9,7 +9,7 @@ include { BEDTOOLS_SORT as SORT_CAT include { BEDTOOLS_MERGE } from '../../../../../modules/CCBR/bedtools/merge/main.nf' include { CUSTOM_COMBINEPEAKCOUNTS } from '../../../../../modules/CCBR/custom/combinepeakcounts/main.nf' -workflow test_custom_combinepeaks { +workflow test_custom_combinepeakcounts { ch_peaks = Channel.fromPath([file(params.test_data.macs.broad.peaks_T0_1, checkIfExists: true), file(params.test_data.macs.broad.peaks_T0_2, checkIfExists: true)])