From 86ac223916613d77f8a611d3f19dfd314409fd4c Mon Sep 17 00:00:00 2001 From: Sima Rahimi Date: Tue, 15 Mar 2022 10:20:46 +0100 Subject: [PATCH] Cnvpytor (#1297) * Added cnvpytor/importreaddepth module * Corrected process name in meta.yml file * added -chrom argument * space correction * Added complementary info * fixed typo * md5sum added * modified the module to work on cram files as well * Added cnvpytor/histogram module and test files * Added cnvpytor/partition module and test files * added cnvpytor/callcnvs module and tests * modified by new modules * Added test file and fixed input path in modules * added when block * little fixes * skip tracking test.yml * removed changes to test if conflicts get resolved * updated outfile name * corrected the version.yml content --- modules/cnvpytor/callcnvs/main.nf | 33 +++++++++++ modules/cnvpytor/callcnvs/meta.yml | 40 ++++++++++++++ modules/cnvpytor/histogram/main.nf | 32 +++++++++++ modules/cnvpytor/histogram/meta.yml | 42 ++++++++++++++ modules/cnvpytor/importreaddepth/main.nf | 38 +++++++++++++ modules/cnvpytor/importreaddepth/meta.yml | 55 +++++++++++++++++++ modules/cnvpytor/partition/main.nf | 32 +++++++++++ modules/cnvpytor/partition/meta.yml | 42 ++++++++++++++ tests/config/test_data.config | 2 + tests/modules/cnvpytor/callcnvs/main.nf | 15 +++++ .../modules/cnvpytor/callcnvs/nextflow.config | 7 +++ tests/modules/cnvpytor/callcnvs/test.yml | 10 ++++ tests/modules/cnvpytor/histogram/main.nf | 15 +++++ .../cnvpytor/histogram/nextflow.config | 7 +++ tests/modules/cnvpytor/histogram/test.yml | 10 ++++ .../modules/cnvpytor/importreaddepth/main.nf | 32 +++++++++++ .../cnvpytor/importreaddepth/nextflow.config | 12 ++++ tests/modules/cnvpytor/partition/main.nf | 15 +++++ .../cnvpytor/partition/nextflow.config | 7 +++ tests/modules/cnvpytor/partition/test.yml | 10 ++++ 20 files changed, 456 insertions(+) create mode 100644 modules/cnvpytor/callcnvs/main.nf create mode 100644 modules/cnvpytor/callcnvs/meta.yml create mode 100644 modules/cnvpytor/histogram/main.nf create mode 100644 modules/cnvpytor/histogram/meta.yml create mode 100644 modules/cnvpytor/importreaddepth/main.nf create mode 100644 modules/cnvpytor/importreaddepth/meta.yml create mode 100644 modules/cnvpytor/partition/main.nf create mode 100644 modules/cnvpytor/partition/meta.yml create mode 100644 tests/modules/cnvpytor/callcnvs/main.nf create mode 100644 tests/modules/cnvpytor/callcnvs/nextflow.config create mode 100644 tests/modules/cnvpytor/callcnvs/test.yml create mode 100644 tests/modules/cnvpytor/histogram/main.nf create mode 100644 tests/modules/cnvpytor/histogram/nextflow.config create mode 100644 tests/modules/cnvpytor/histogram/test.yml create mode 100644 tests/modules/cnvpytor/importreaddepth/main.nf create mode 100644 tests/modules/cnvpytor/importreaddepth/nextflow.config create mode 100644 tests/modules/cnvpytor/partition/main.nf create mode 100644 tests/modules/cnvpytor/partition/nextflow.config create mode 100644 tests/modules/cnvpytor/partition/test.yml diff --git a/modules/cnvpytor/callcnvs/main.nf b/modules/cnvpytor/callcnvs/main.nf new file mode 100644 index 00000000..1d47ce16 --- /dev/null +++ b/modules/cnvpytor/callcnvs/main.nf @@ -0,0 +1,33 @@ +process CNVPYTOR_CALLCNVS { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::cnvpytor=1.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/cnvpytor:A1.0--py39h6a678da_2': + 'quay.io/biocontainers/cnvpytor:1.0--py39h6a678da_2' }" + + input: + tuple val(meta), path(pytor) + + output: + tuple val(meta), path("*.tsv"), emit: cnvs + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '1000' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + cnvpytor \\ + -root $pytor \\ + -call $args > ${prefix}.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cnvpytor: \$(echo \$(cnvpytor --version 2>&1) | sed 's/^.*pyCNVnator //; s/Using.*\$//' )) + END_VERSIONS + """ +} diff --git a/modules/cnvpytor/callcnvs/meta.yml b/modules/cnvpytor/callcnvs/meta.yml new file mode 100644 index 00000000..c153b949 --- /dev/null +++ b/modules/cnvpytor/callcnvs/meta.yml @@ -0,0 +1,40 @@ +name: cnvpytor_callcnvs +description: command line tool for calling CNVs in whole genome sequencing data + - CNV calling +tools: + - cnvpytor: + description: calling CNVs using read depth + homepage: https://github.com/abyzovlab/CNVpytor + documentation: https://github.com/abyzovlab/CNVpytor + tool_dev_url: https://github.com/abyzovlab/CNVpytor + doi: "10.1101/2021.01.27.428472v1" + licence: ['MIT'] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test'] + - pytor: + type: file + description: cnvpytor root file + pattern: "*.{pytor}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - cnvs: + type: file + description: file containing identified copy numer variations + pattern: "*.{tsv}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + + +authors: + - "@sima-r" diff --git a/modules/cnvpytor/histogram/main.nf b/modules/cnvpytor/histogram/main.nf new file mode 100644 index 00000000..29dc1bff --- /dev/null +++ b/modules/cnvpytor/histogram/main.nf @@ -0,0 +1,32 @@ +process CNVPYTOR_HISTOGRAM { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::cnvpytor=1.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/cnvpytor:A1.0--py39h6a678da_2': + 'quay.io/biocontainers/cnvpytor:1.0--py39h6a678da_2' }" + + input: + tuple val(meta), path(pytor) + + output: + tuple val(meta), path("${pytor.baseName}.pytor") , emit: pytor + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '1000' + """ + cnvpytor \\ + -root $pytor \\ + -his $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cnvpytor: \$(echo \$(cnvpytor --version 2>&1) | sed 's/^.*pyCNVnator //; s/Using.*\$//' )) + END_VERSIONS + """ +} diff --git a/modules/cnvpytor/histogram/meta.yml b/modules/cnvpytor/histogram/meta.yml new file mode 100644 index 00000000..8484ddd4 --- /dev/null +++ b/modules/cnvpytor/histogram/meta.yml @@ -0,0 +1,42 @@ +name: cnvpytor_histogram +description: calculates read depth histograms +keywords: + - cnv calling + - histogram +tools: + - cnvpytor: + description: calling CNVs using read depth + homepage: https://github.com/abyzovlab/CNVpytor + documentation: https://github.com/abyzovlab/CNVpytor + tool_dev_url: https://github.com/abyzovlab/CNVpytor + doi: "10.1101/2021.01.27.428472v1" + licence: ['MIT'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - pytor: + type: file + description: pytor file containing read depth data + pattern: "*.{pytor}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - pytor: + type: file + description: pytor file containing read depth histograms binned based on given bin size(s) + pattern: "*.{pytor}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@sima-r" diff --git a/modules/cnvpytor/importreaddepth/main.nf b/modules/cnvpytor/importreaddepth/main.nf new file mode 100644 index 00000000..9fc7db08 --- /dev/null +++ b/modules/cnvpytor/importreaddepth/main.nf @@ -0,0 +1,38 @@ +process CNVPYTOR_IMPORTREADDEPTH { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::cnvpytor=1.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/cnvpytor:A1.0--py39h6a678da_2': + 'quay.io/biocontainers/cnvpytor:1.0--py39h6a678da_2' }" + + input: + tuple val(meta), path(input_file), path(index) + path fasta + path fai + + output: + tuple val(meta), path("*.pytor") , emit: pytor + 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 reference = fasta ? "-T ${fasta}" : '' + """ + cnvpytor \\ + -root ${prefix}.pytor \\ + -rd $input_file \\ + $args \\ + $reference + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cnvpytor: \$(echo \$(cnvpytor --version 2>&1) | sed 's/^.*pyCNVnator //; s/Using.*\$//' )) + END_VERSIONS + """ +} diff --git a/modules/cnvpytor/importreaddepth/meta.yml b/modules/cnvpytor/importreaddepth/meta.yml new file mode 100644 index 00000000..908c3a74 --- /dev/null +++ b/modules/cnvpytor/importreaddepth/meta.yml @@ -0,0 +1,55 @@ +name: cnvpytor_importreaddepth +description: command line tool for CNV/CNA analysis. This step imports the read depth data into a root pytor file. +keywords: + - read depth + - cnv calling +tools: + - cnvpytor -rd: + description: calling CNVs using read depth + homepage: https://github.com/abyzovlab/CNVpytor + documentation: https://github.com/abyzovlab/CNVpytor + tool_dev_url: https://github.com/abyzovlab/CNVpytor + doi: "10.1101/2021.01.27.428472v1" + licence: ['MIT'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - input_file: + type: file + description: BAM/CRAM/SAM file + pattern: "*.{bam,cram}" + - index: + type: file + description: bam file index + pattern: "*.{bai,crai}" + - fasta: + type: file + description: specifies reference genome file (only for cram file without reference genome) + pattern: "*.{fasta,fasta.gz,fa,fa.gz}" + - fai: + type: file + description: Index of reference fasta file + pattern: "*.fai" + + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - pytor: + type: file + description: read depth root file in which read depth data binned to 100 base pair bins will be stored. + pattern: "*.{pytor}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@sima-r" diff --git a/modules/cnvpytor/partition/main.nf b/modules/cnvpytor/partition/main.nf new file mode 100644 index 00000000..e3f73955 --- /dev/null +++ b/modules/cnvpytor/partition/main.nf @@ -0,0 +1,32 @@ +process CNVPYTOR_PARTITION { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::cnvpytor=1.0" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/cnvpytor:A1.0--py39h6a678da_2': + 'quay.io/biocontainers/cnvpytor:1.0--py39h6a678da_2' }" + + input: + tuple val(meta), path(pytor) + + output: + tuple val(meta), path("${pytor.baseName}.pytor"), emit: pytor + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '1000' + """ + cnvpytor \\ + -root $pytor \\ + -partition $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cnvpytor: \$(echo \$(cnvpytor --version 2>&1) | sed 's/^.*pyCNVnator //; s/Using.*\$//' )) + END_VERSIONS + """ +} diff --git a/modules/cnvpytor/partition/meta.yml b/modules/cnvpytor/partition/meta.yml new file mode 100644 index 00000000..3f0a3e21 --- /dev/null +++ b/modules/cnvpytor/partition/meta.yml @@ -0,0 +1,42 @@ +name: cnvpytor_partition +description: partitioning read depth histograms +keywords: + - cnv calling + - partition histograms +tools: + - cnvpytor: + description: calling CNVs using read depth + homepage: https://github.com/abyzovlab/CNVpytor + documentation: https://github.com/abyzovlab/CNVpytor + tool_dev_url: https://github.com/abyzovlab/CNVpytor + doi: "10.1101/2021.01.27.428472v1" + licence: ['MIT'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - pytor: + type: file + description: pytor file containing read depth data + pattern: "*.{pytor}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - partitions: + type: file + description: pytor file containing partitions of read depth histograms using mean-shift method + pattern: "*.{pytor}" + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@sima-r" diff --git a/tests/config/test_data.config b/tests/config/test_data.config index ce4f7ae8..ed1e2861 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -295,6 +295,8 @@ params { test_rnaseq_vcf = "${test_data_dir}/genomics/homo_sapiens/illumina/vcf/test.rnaseq.vcf" test_sv_vcf = "${test_data_dir}/genomics/homo_sapiens/illumina/vcf/sv_query.vcf.gz" + + test_pytor = "${test_data_dir}/genomics/homo_sapiens/illumina/pytor/test.pytor" } 'pacbio' { primers = "${test_data_dir}/genomics/homo_sapiens/pacbio/fasta/primers.fasta" diff --git a/tests/modules/cnvpytor/callcnvs/main.nf b/tests/modules/cnvpytor/callcnvs/main.nf new file mode 100644 index 00000000..96d33250 --- /dev/null +++ b/tests/modules/cnvpytor/callcnvs/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CNVPYTOR_CALLCNVS } from '../../../../modules/cnvpytor/callcnvs/main.nf' + +workflow test_cnvpytor_callcnvs { + + input = [ + [ id:'test'], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_pytor'], checkIfExists: true) + ] + + CNVPYTOR_CALLCNVS ( input ) +} diff --git a/tests/modules/cnvpytor/callcnvs/nextflow.config b/tests/modules/cnvpytor/callcnvs/nextflow.config new file mode 100644 index 00000000..9d132b77 --- /dev/null +++ b/tests/modules/cnvpytor/callcnvs/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: CNVPYTOR_CALLCNVS { + ext.args = '10000' + } +} diff --git a/tests/modules/cnvpytor/callcnvs/test.yml b/tests/modules/cnvpytor/callcnvs/test.yml new file mode 100644 index 00000000..85bfcc7a --- /dev/null +++ b/tests/modules/cnvpytor/callcnvs/test.yml @@ -0,0 +1,10 @@ +- name: cnvpytor callcnvs test_cnvpytor_callcnvs + command: nextflow run tests/modules/cnvpytor/callcnvs -entry test_cnvpytor_callcnvs -c tests/config/nextflow.config + tags: + - cnvpytor + - cnvpytor/callcnvs + files: + - path: output/cnvpytor/calls.10000.tsv + md5sum: d41d8cd98f00b204e9800998ecf8427e + - path: output/cnvpytor/versions.yml + md5sum: 5fe6ca3ef5c40f9dbf487f28db237821 diff --git a/tests/modules/cnvpytor/histogram/main.nf b/tests/modules/cnvpytor/histogram/main.nf new file mode 100644 index 00000000..2178dee1 --- /dev/null +++ b/tests/modules/cnvpytor/histogram/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CNVPYTOR_HISTOGRAM } from '../../../../modules/cnvpytor/histogram/main.nf' + +workflow test_cnvpytor_histogram { + + input = [ + [ id:'test'], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_pytor'], checkIfExists: true), + ] + + CNVPYTOR_HISTOGRAM ( input ) +} diff --git a/tests/modules/cnvpytor/histogram/nextflow.config b/tests/modules/cnvpytor/histogram/nextflow.config new file mode 100644 index 00000000..de8cfccf --- /dev/null +++ b/tests/modules/cnvpytor/histogram/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: CNVPYTOR_HISTOGRAM { + ext.args = '10000 100000' + } +} diff --git a/tests/modules/cnvpytor/histogram/test.yml b/tests/modules/cnvpytor/histogram/test.yml new file mode 100644 index 00000000..fd8bcaf4 --- /dev/null +++ b/tests/modules/cnvpytor/histogram/test.yml @@ -0,0 +1,10 @@ +- name: cnvpytor histogram test_cnvpytor_histogram + command: nextflow run tests/modules/cnvpytor/histogram -entry test_cnvpytor_histogram -c tests/config/nextflow.config + tags: + - cnvpytor + - cnvpytor/histogram + files: + - path: output/cnvpytor/test.pytor + md5sum: aa03a8fa15b39f77816705a48e10312a + - path: output/cnvpytor/versions.yml + md5sum: 9a4b176afd5f1a3edeb37eeb301cf464 diff --git a/tests/modules/cnvpytor/importreaddepth/main.nf b/tests/modules/cnvpytor/importreaddepth/main.nf new file mode 100644 index 00000000..0d9be324 --- /dev/null +++ b/tests/modules/cnvpytor/importreaddepth/main.nf @@ -0,0 +1,32 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CNVPYTOR_IMPORTREADDEPTH } from '../../../../modules/cnvpytor/importreaddepth/main.nf' + + +workflow test_cnvpytor_importreaddepth { + + input = [ + [ id: 'test' ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam_bai'], checkIfExists: true) + ] + + CNVPYTOR_IMPORTREADDEPTH (input, [], []) +} + +workflow test_cnvpytor_importreaddepth_cram { + + input = [ + [ id: 'test' ], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true), + file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true) + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + + fai = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true) + + CNVPYTOR_IMPORTREADDEPTH (input, fasta, fai) +} diff --git a/tests/modules/cnvpytor/importreaddepth/nextflow.config b/tests/modules/cnvpytor/importreaddepth/nextflow.config new file mode 100644 index 00000000..c60f979e --- /dev/null +++ b/tests/modules/cnvpytor/importreaddepth/nextflow.config @@ -0,0 +1,12 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: CNVPYTOR_IMPORTREADDEPTH { + ext.args = {params.cnvpytor_chr ? "-chrom ${params.cnvpytor_chr}" : '' } + } +} + +params { + cnvpytor_chr = '' // specifies chromosome name(s) the same way as they are described in the sam/bam/cram header e.g. '1 2' or 'chr1 chr2'. + } diff --git a/tests/modules/cnvpytor/partition/main.nf b/tests/modules/cnvpytor/partition/main.nf new file mode 100644 index 00000000..cd8063a4 --- /dev/null +++ b/tests/modules/cnvpytor/partition/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { CNVPYTOR_PARTITION } from '../../../../modules/cnvpytor/partition/main.nf' + +workflow test_cnvpytor_partition { + + input = [ + [ id:'test'], // meta map + file(params.test_data['homo_sapiens']['illumina']['test_pytor'], checkIfExists: true) + ] + + CNVPYTOR_PARTITION ( input ) +} diff --git a/tests/modules/cnvpytor/partition/nextflow.config b/tests/modules/cnvpytor/partition/nextflow.config new file mode 100644 index 00000000..b684d42a --- /dev/null +++ b/tests/modules/cnvpytor/partition/nextflow.config @@ -0,0 +1,7 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: CNVPYTOR_PARTITION { + ext.args = '10000 100000' + } +} diff --git a/tests/modules/cnvpytor/partition/test.yml b/tests/modules/cnvpytor/partition/test.yml new file mode 100644 index 00000000..1b838395 --- /dev/null +++ b/tests/modules/cnvpytor/partition/test.yml @@ -0,0 +1,10 @@ +- name: cnvpytor partition test_cnvpytor_partition + command: nextflow run tests/modules/cnvpytor/partition -entry test_cnvpytor_partition -c tests/config/nextflow.config + tags: + - cnvpytor + - cnvpytor/partition + files: + - path: output/cnvpytor/test.pytor + md5sum: aa03a8fa15b39f77816705a48e10312a + - path: output/cnvpytor/versions.yml + md5sum: 8a04506554c58cd170cc050fd9904c6f