diff --git a/modules/ichorcna/createpon/main.nf b/modules/ichorcna/createpon/main.nf new file mode 100644 index 00000000..6b249b32 --- /dev/null +++ b/modules/ichorcna/createpon/main.nf @@ -0,0 +1,48 @@ +def VERSION = '0.3.2' // Version information not provided by tool on CLI + +process ICHORCNA_CREATEPON { + label 'process_low' + + conda (params.enable_conda ? "bioconda::r-ichorcna=0.3.2" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/r-ichorcna:0.3.2--r41hdfd78af_0' : + 'quay.io/biocontainers/r-ichorcna:0.3.2--r41hdfd78af_0' }" + + input: + path wigs + path gc_wig + path map_wig + path centromere + + output: + path "*.rds" , emit: rds + path "*.txt" , emit: txt + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def centro = centromere ? "--centromere ${centromere}" : '' + def prefix = task.ext.prefix ?: "PoN" + + """ + echo ${wigs} | tr " " "\\n" > wig_files.txt + + createPanelOfNormals.R \\ + --filelist wig_files.txt \\ + --gcWig ${gc_wig} \\ + --mapWig ${map_wig} \\ + ${centro} \\ + ${args} \\ + --outfile ${prefix} + + rm wig_files.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + ichorcna: $VERSION + END_VERSIONS + """ +} diff --git a/modules/ichorcna/createpon/meta.yml b/modules/ichorcna/createpon/meta.yml new file mode 100644 index 00000000..ce1eca0a --- /dev/null +++ b/modules/ichorcna/createpon/meta.yml @@ -0,0 +1,57 @@ +name: ichorcna_createpon +description: ichorCNA is an R package for calculating copy number alteration from (low-pass) whole genome sequencing, particularly for use in cell-free DNA. This module generates a panel of normals +keywords: + - ichorcna + - cnv + - cna + - cfDNA + - wgs + - panel_of_normals +tools: + - ichorcna: + description: Estimating tumor fraction in cell-free DNA from ultra-low-pass whole genome sequencing. + homepage: https://github.com/broadinstitute/ichorCNA + documentation: https://github.com/broadinstitute/ichorCNA/wiki + tool_dev_url: https://github.com/broadinstitute/ichorCNA + doi: "10.1038/s41467-017-00965-y" + licence: ['GPL v3'] + +input: + - wigs: + type: file + description: Any number of hmmcopy/readCounter processed .wig files giving the number of reads in the sample, in each genomic window. These will be averaged over to generate the panel of normals. + pattern: "*.{wig}" + + - gc_wig: + type: file + description: hmmcopy/gcCounter processed .wig file giving the gc content in the reference fasta, in each genomic window + pattern: "*.{wig}" + + - map_wig: + type: file + description: hmmcopy/mapCounter processed .wig file giving the mapability in the reference fasta, in each genomic window + pattern: "*.{wig}" + + - centromere: + type: file + description: Text file giving centromere locations of each genome, to exclude these windows + pattern: "*.{txt}" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + + - rds: + type: file + description: R data file (.rds) containing panel of normals data, medians of each bin. + pattern: "*.rds" + + - txt: + type: file + description: Text file containing panel of normals data, medians of each bin. + pattern: "*.txt" + +authors: + - "@sppearce" diff --git a/modules/ichorcna/run/main.nf b/modules/ichorcna/run/main.nf new file mode 100644 index 00000000..cc72adc9 --- /dev/null +++ b/modules/ichorcna/run/main.nf @@ -0,0 +1,50 @@ +def VERSION = '0.3.2' // Version information not provided by tool on CLI + +process ICHORCNA_RUN { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::r-ichorcna=0.3.2" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/r-ichorcna:0.3.2--r41hdfd78af_0' : + 'quay.io/biocontainers/r-ichorcna:0.3.2--r41hdfd78af_0' }" + + input: + tuple val(meta), path(wig) + path gc_wig + path map_wig + path panel_of_normals + path centromere + + output: + tuple val(meta), path("*.cna.seg") , emit: cna_seg + tuple val(meta), path("*.params.txt") , emit: ichorcna_params + path "**/*genomeWide.pdf" , emit: genome_plot + 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 pon = panel_of_normals ? "--normalPanel ${panel_of_normals}" : '' + def centro = centromere ? "--centromere ${centromere}" : '' + + """ + runIchorCNA.R --id ${prefix} \\ + $args \\ + --WIG ${wig} \\ + --id ${meta.id} \\ + --gcWig ${gc_wig} \\ + --mapWig ${map_wig} \\ + ${pon} \\ + ${centro} \\ + --outDir . + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + ichorcna: $VERSION + END_VERSIONS + """ +} diff --git a/modules/ichorcna/run/meta.yml b/modules/ichorcna/run/meta.yml new file mode 100644 index 00000000..f0febddf --- /dev/null +++ b/modules/ichorcna/run/meta.yml @@ -0,0 +1,72 @@ +name: ichorcna_run +description: ichorCNA is an R package for calculating copy number alteration from (low-pass) whole genome sequencing, particularly for use in cell-free DNA +keywords: + - ichorcna + - cnv + - cna + - cfDNA + - wgs +tools: + - ichorcna: + description: Estimating tumor fraction in cell-free DNA from ultra-low-pass whole genome sequencing. + homepage: https://github.com/broadinstitute/ichorCNA + documentation: https://github.com/broadinstitute/ichorCNA/wiki + tool_dev_url: https://github.com/broadinstitute/ichorCNA + doi: "10.1038/s41467-017-00965-y" + licence: ['GPL v3'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test'] + - wig: + type: file + description: hmmcopy/readCounter processed .wig file giving the number of reads in the sample, in each genomic window + pattern: "*.{wig}" + + - gc_wig: + type: file + description: hmmcopy/gcCounter processed .wig file giving the gc content in the reference fasta, in each genomic window + pattern: "*.{wig}" + + - map_wig: + type: file + description: hmmcopy/mapCounter processed .wig file giving the mapability in the reference fasta, in each genomic window + pattern: "*.{wig}" + + - panel_of_normals: + type: file + description: Panel of normals data, generated by calling ichorCNA on a set of normal samples with the same window size etc. + pattern: "*.{rds}" + + - centromere: + type: file + description: Text file giving centromere locations of each genome, to exclude these windows + pattern: "*.{txt}" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test'] + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - cna_seg: + type: file + description: Predicted copy number variation per segment + pattern: "*.{cng.seg}" + - ichorcna_params: + type: file + description: A text file showing the values that ichorCNA has estimated for tumour fraction, ploidy etc + pattern: "*.{params.txt}" + - genome_plot: + type: file + description: A plot with the best-fit genome-wide CNV data + pattern: "*.{genomeWide.pdf}" +authors: + - "@sppearce" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 3dcdcfd7..ac82bd39 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -755,6 +755,14 @@ homer/makeucscfile: - modules/homer/makeucscfile/** - tests/modules/homer/makeucscfile/** +ichorcna/createpon: + - modules/ichorcna/createpon/** + - tests/modules/ichorcna/createpon/** + +ichorcna/run: + - modules/ichorcna/run/** + - tests/modules/ichorcna/run/** + idr: - modules/idr/** - tests/modules/idr/** diff --git a/tests/modules/ichorcna/createpon/main.nf b/tests/modules/ichorcna/createpon/main.nf new file mode 100644 index 00000000..0e86fb92 --- /dev/null +++ b/tests/modules/ichorcna/createpon/main.nf @@ -0,0 +1,30 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ICHORCNA_CREATEPON } from '../../../../modules/ichorcna/createpon/main.nf' + +workflow test_ichorcna_createpon { + + input = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/MBC_315.ctDNA.reads.wig", checkIfExists: true) + + gcwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/gc_hg19_1000kb.wig", checkIfExists: true) + mapwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/map_hg19_1000kb.wig", checkIfExists: true) + + centromere = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt", checkIfExists: true) + + ICHORCNA_CREATEPON ( input, gcwig, mapwig, centromere ) +} + +workflow test_ichorcna_createpon2 { + + input = [file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/MBC_315.ctDNA.reads.wig", checkIfExists: true), + file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/MBC_315_T2.ctDNA.reads.wig", checkIfExists: true)] + + gcwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/gc_hg19_1000kb.wig", checkIfExists: true) + mapwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/map_hg19_1000kb.wig", checkIfExists: true) + + centromere = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt", checkIfExists: true) + + ICHORCNA_CREATEPON ( input, gcwig, mapwig, centromere ) +} diff --git a/tests/modules/ichorcna/createpon/nextflow.config b/tests/modules/ichorcna/createpon/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/ichorcna/createpon/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/ichorcna/createpon/test.yml b/tests/modules/ichorcna/createpon/test.yml new file mode 100644 index 00000000..53422b78 --- /dev/null +++ b/tests/modules/ichorcna/createpon/test.yml @@ -0,0 +1,21 @@ +- name: ichorcna createpon test_ichorcna_createpon + command: nextflow run tests/modules/ichorcna/createpon -entry test_ichorcna_createpon -c tests/config/nextflow.config + tags: + - ichorcna/createpon + - ichorcna + files: + - path: output/ichorcna/PoN_median.txt + contains: ['seqnames'] + - path: output/ichorcna/versions.yml + md5sum: 59a2121301113cc013bfae65935e07f1 + +- name: ichorcna createpon test_ichorcna_createpon2 + command: nextflow run tests/modules/ichorcna/createpon -entry test_ichorcna_createpon2 -c tests/config/nextflow.config + tags: + - ichorcna/createpon + - ichorcna + files: + - path: output/ichorcna/PoN_median.txt + contains: ['seqnames'] + - path: output/ichorcna/versions.yml + md5sum: 31a5fcc0075dbe747f7736efbdb99644 diff --git a/tests/modules/ichorcna/run/main.nf b/tests/modules/ichorcna/run/main.nf new file mode 100644 index 00000000..8a830f62 --- /dev/null +++ b/tests/modules/ichorcna/run/main.nf @@ -0,0 +1,40 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ICHORCNA_RUN } from '../../../../modules/ichorcna/run/main.nf' +include { HMMCOPY_READCOUNTER } from '../../../../modules/hmmcopy/readcounter/main.nf' +include { HMMCOPY_GCCOUNTER } from '../../../../modules/hmmcopy/gccounter/main.nf' +include { HMMCOPY_MAPCOUNTER } from '../../../../modules/hmmcopy/mapcounter/main.nf' +include { HMMCOPY_GENERATEMAP } from '../../../../modules/hmmcopy/generatemap/main.nf' + +workflow test_ichorcna_run_no_panel { + + input = [ [ id:'test'], // meta map + file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/MBC_315.ctDNA.reads.wig", checkIfExists: true) + ] + + gcwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/gc_hg19_1000kb.wig", checkIfExists: true) + mapwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/map_hg19_1000kb.wig", checkIfExists: true) + + panel_of_normals = [] + centromere = [] + + ICHORCNA_RUN ( input, gcwig, mapwig, panel_of_normals, centromere) +} + +workflow test_ichorcna_run_inc_panel { + + input = [ [ id:'test'], // meta map + file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/MBC_315.ctDNA.reads.wig", checkIfExists: true) + ] + + gcwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/gc_hg19_1000kb.wig", checkIfExists: true) + mapwig = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/map_hg19_1000kb.wig", checkIfExists: true) + + panel_of_normals = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/HD_ULP_PoN_1Mb_median_normAutosome_mapScoreFiltered_median.rds", checkIfExists: true) + + centromere = file("https://raw.githubusercontent.com/broadinstitute/ichorCNA/master/inst/extdata/GRCh37.p13_centromere_UCSC-gapTable.txt", checkIfExists: true) + + ICHORCNA_RUN ( input, gcwig, mapwig, panel_of_normals, centromere) +} diff --git a/tests/modules/ichorcna/run/nextflow.config b/tests/modules/ichorcna/run/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/ichorcna/run/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/ichorcna/run/test.yml b/tests/modules/ichorcna/run/test.yml new file mode 100644 index 00000000..af78e4b3 --- /dev/null +++ b/tests/modules/ichorcna/run/test.yml @@ -0,0 +1,25 @@ +- name: ichorcna run test_ichorcna_run_no_panel + command: nextflow run tests/modules/ichorcna/run -entry test_ichorcna_run_no_panel -c tests/config/nextflow.config + tags: + - ichorcna + - ichorcna/run + files: + - path: output/ichorcna/test.cna.seg + contains: ['Corrected_Copy_Number'] + - path: output/ichorcna/test.params.txt + md5sum: e39a579cdcc9576679f06dc5c22605a7 + - path: output/ichorcna/versions.yml + md5sum: effb37e19bec3609417aaccad4b6a294 + +- name: ichorcna run test_ichorcna_run_inc_panel + command: nextflow run tests/modules/ichorcna/run -entry test_ichorcna_run_inc_panel -c tests/config/nextflow.config + tags: + - ichorcna + - ichorcna/run + files: + - path: output/ichorcna/test.cna.seg + contains: ['Corrected_Copy_Number'] + - path: output/ichorcna/test.params.txt + md5sum: 0b97e0269cd0b571f5a85890f6ddb181 + - path: output/ichorcna/versions.yml + md5sum: fc9d96de0a1c15cea59208305b14e535