From f17ea6ff25bd2229464e64c6594ad34098d2b2ea Mon Sep 17 00:00:00 2001 From: nservant <nicolas.servant@curie.fr> Date: Mon, 28 Feb 2022 19:26:23 +0100 Subject: [PATCH] [MODIF] update cooltools --- conf/modules.config | 21 +++++++++- modules/local/compartment_calling.nf | 30 -------------- modules/local/{ => cooler}/balance.nf | 0 modules/local/{ => cooler}/makebins.nf | 0 modules/local/cooltools/eigs-cis.nf | 30 ++++++++++++++ modules/local/cooltools/insulation.nf | 26 ++++++++++++ modules/local/tads_insulation.nf | 25 ----------- modules/local/{ => trash}/functions.nf | 0 subworkflows/local/compartments.nf | 24 +++++++---- subworkflows/local/cooler.nf | 4 +- subworkflows/local/tads.nf | 29 +++++++++---- workflows/hic.nf | 57 +++++++++++++++++++++++--- 12 files changed, 166 insertions(+), 80 deletions(-) delete mode 100644 modules/local/compartment_calling.nf rename modules/local/{ => cooler}/balance.nf (100%) rename modules/local/{ => cooler}/makebins.nf (100%) create mode 100644 modules/local/cooltools/eigs-cis.nf create mode 100644 modules/local/cooltools/insulation.nf delete mode 100644 modules/local/tads_insulation.nf rename modules/local/{ => trash}/functions.nf (100%) diff --git a/conf/modules.config b/conf/modules.config index 7f4fcea..9cef5f9 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -204,4 +204,23 @@ process { ] ext.args = "--balance" } -} + + //******************************** + // COMPARTMENTS + + withName: 'CALL_COMPARTMENTS' { + ext.args = '--bigwig' + } + + //******************************** + // TADS + + withName: 'INSULATION' { + ext.args = '15 25 50 --window-pixels' + } + + withName: 'HIC_FIND_TADS' { + ext.args = '--correctForMultipleTesting fdr' + } + +} \ No newline at end of file diff --git a/modules/local/compartment_calling.nf b/modules/local/compartment_calling.nf deleted file mode 100644 index 51f9788..0000000 --- a/modules/local/compartment_calling.nf +++ /dev/null @@ -1,30 +0,0 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -params.options = [:] -options = initOptions(params.options) - -process compartment_calling { - tag "$sample - $res" - label 'process_medium' - publishDir "${params.outdir}/compartments", mode: 'copy' - - when: - !params.skip_compartments - - input: - tuple val(sample), val(res), path(cool), val(r) - path(fasta) - path(chrsize) - - output: - path("*compartments*") optional true, emit:out_compartments - - script: - """ - cooltools genome binnify --all-names ${chrsize} ${res} > genome_bins.txt - cooltools genome gc genome_bins.txt ${fasta} > genome_gc.txt - cooltools call-compartments --contact-type cis -o ${sample}_compartments ${cool} - awk -F"\t" 'NR>1{OFS="\t"; if(\$6==""){\$6=0}; print \$1,\$2,\$3,\$6}' ${sample}_compartments.cis.vecs.tsv | sort -k1,1 -k2,2n > ${sample}_compartments.cis.E1.bedgraph - """ -} diff --git a/modules/local/balance.nf b/modules/local/cooler/balance.nf similarity index 100% rename from modules/local/balance.nf rename to modules/local/cooler/balance.nf diff --git a/modules/local/makebins.nf b/modules/local/cooler/makebins.nf similarity index 100% rename from modules/local/makebins.nf rename to modules/local/cooler/makebins.nf diff --git a/modules/local/cooltools/eigs-cis.nf b/modules/local/cooltools/eigs-cis.nf new file mode 100644 index 0000000..74cd265 --- /dev/null +++ b/modules/local/cooltools/eigs-cis.nf @@ -0,0 +1,30 @@ +/* + * cooltools - call_compartments + */ + +process CALL_COMPARTMENTS { + label 'process_medium' + + input: + tuple val(meta), val(res), path(cool) + path(fasta) + path(chrsize) + + output: + path("*compartments*"), emit: results + path("versions.yml"), emit: versions + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + cooltools genome binnify --all-names ${chrsize} ${res} > genome_bins.txt + cooltools genome gc genome_bins.txt ${fasta} > genome_gc.txt + cooltools eigs-cis ${args} -o ${prefix}_compartments ${cool} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cooltools: \$(cooltools --version 2>&1 | sed 's/cooletools, version //') + END_VERSIONS + """ +} diff --git a/modules/local/cooltools/insulation.nf b/modules/local/cooltools/insulation.nf new file mode 100644 index 0000000..531bab9 --- /dev/null +++ b/modules/local/cooltools/insulation.nf @@ -0,0 +1,26 @@ +/* + * Cooltools - diamond-insulation + */ + +process INSULATION { + label 'process_medium' + + input: + tuple val(meta), path(cool) + + output: + path("*tsv"), emit:results + path("versions.yml"), emit:versions + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + """ + cooltools insulation ${cool} ${args} > ${prefix}_insulation.tsv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + cooltools: \$(cooltools --version 2>&1 | sed 's/cooltools, version //') + END_VERSIONS + """ +} diff --git a/modules/local/tads_insulation.nf b/modules/local/tads_insulation.nf deleted file mode 100644 index 7338cd3..0000000 --- a/modules/local/tads_insulation.nf +++ /dev/null @@ -1,25 +0,0 @@ -// Import generic module functions -include { initOptions; saveFiles; getSoftwareName } from './functions' - -params.options = [:] -options = initOptions(params.options) - -process tads_insulation { - tag "$sample - $res" - label 'process_medium' - publishDir "${params.outdir}/tads/insulation", mode: 'copy' - - when: - !params.skip_tads && params.tads_caller =~ 'insulation' - - input: - tuple val(sample), val(res), path(cool), val(r) - - output: - path("*tsv"), emit:insulation_tads - - script: - """ - cooltools diamond-insulation --window-pixels ${cool} 15 25 50 > ${sample}_insulation.tsv - """ -} diff --git a/modules/local/functions.nf b/modules/local/trash/functions.nf similarity index 100% rename from modules/local/functions.nf rename to modules/local/trash/functions.nf diff --git a/subworkflows/local/compartments.nf b/subworkflows/local/compartments.nf index e3089f3..23d78ac 100644 --- a/subworkflows/local/compartments.nf +++ b/subworkflows/local/compartments.nf @@ -1,15 +1,23 @@ -params.options = [:] - -include { COMPARTMENT_CALLING } from '../../modules/local/compartment_calling' addParams( options: params.options ) +include { CALL_COMPARTMENTS } from '../../modules/local/cooltools/eigs-cis' workflow COMPARTMENTS { - take: + take: + cool + fasta + chrsize + main: + ch_versions = Channel.empty() - main: - + CALL_COMPARTMENTS ( + cool, + fasta.collect(), + chrsize.collect() + ) + ch_versions = ch_versions.mix(CALL_COMPARTMENTS.out.versions) - emit: - + emit: + versions = ch_versions + compartments = CALL_COMPARTMENTS.out.results } \ No newline at end of file diff --git a/subworkflows/local/cooler.nf b/subworkflows/local/cooler.nf index 897b057..5c61d87 100644 --- a/subworkflows/local/cooler.nf +++ b/subworkflows/local/cooler.nf @@ -8,9 +8,9 @@ include { COOLER_CLOAD } from '../../modules/nf-core/modules/cooler/cload/main' include { COOLER_DUMP } from '../../modules/nf-core/modules/cooler/dump/main' include { COOLER_ZOOMIFY } from '../../modules/nf-core/modules/cooler/zoomify/main' -include { COOLER_BALANCE } from '../../modules/local/balance' +include { COOLER_BALANCE } from '../../modules/local/cooler/balance' include { SPLIT_COOLER_DUMP } from '../../modules/local/split_cooler_dump' -include { COOLER_MAKEBINS } from '../../modules/local/makebins' +include { COOLER_MAKEBINS } from '../../modules/local/cooler/makebins' workflow COOLER { diff --git a/subworkflows/local/tads.nf b/subworkflows/local/tads.nf index 9f0836a..496e8d6 100644 --- a/subworkflows/local/tads.nf +++ b/subworkflows/local/tads.nf @@ -1,16 +1,27 @@ -params.options = [:] - -include { TADS_HICEXPLORER } from '../../modules/local/tads_hicexplorer' addParams( options: params.options ) -include { TADS_INSULATION } from '../../modules/local/tads_insulation' addParams( options: params.options ) +include { INSULATION } from '../../modules/local/cooltools/insulation' +include { HIC_FIND_TADS } from '../../modules/local/hicexplorer/hicFindTADs' workflow TADS { - take: + take: + cool + main: + ch_versions = Channel.empty() + ch_tads = Channel.empty() - main: - + if (params.tads_caller =~ 'insulation'){ + INSULATION(cool) + ch_versions = ch_versions.mix(INSULATION.out.versions) + ch_tads = ch_tads.mix(INSULATION.out.results) + } + + if (params.tads_caller =~ 'hicexplorer'){ + HIC_FIND_TADS(cool) + ch_versions = ch_versions.mix(HIC_FIND_TADS.out.versions) + ch_tads = ch_tads.mix(HIC_FIND_TADS.out.results) + } - emit: - + emit: + tads = ch_tads } \ No newline at end of file diff --git a/workflows/hic.nf b/workflows/hic.nf index a65a385..0204db7 100644 --- a/workflows/hic.nf +++ b/workflows/hic.nf @@ -96,9 +96,9 @@ ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multi // // MODULE: Local to the pipeline // -//include { GET_SOFTWARE_VERSIONS } from '../modules/local/get_software_versions' addParams( options: [publish_files : ['tsv':'']] ) -//include { OUTPUT_DOCUMENTATION } from '../modules/local/output_documentation' addParams( options: [publish_files : ['tsv':'']] ) - +//include { GET_SOFTWARE_VERSIONS } from '../modules/local/get_software_versions' +//include { OUTPUT_DOCUMENTATION } from '../modules/local/output_documentation' +include { HIC_PLOT_DIST_VS_COUNTS } from '../modules/local/hicexplorer/hicPlotDistVsCounts' // // SUBWORKFLOW: Consisting of a mix of local and nf-core/modules // @@ -106,8 +106,8 @@ include { INPUT_CHECK } from '../subworkflows/local/input_check' include { PREPARE_GENOME } from '../subworkflows/local/prepare_genome' include { HICPRO } from '../subworkflows/local/hicpro' include { COOLER } from '../subworkflows/local/cooler' -//include { COMPARTMENTS } from '../subworkflows/local/compartments' -//include { TADS } from '../subworkflows/local/tads' +include { COMPARTMENTS } from '../subworkflows/local/compartments' +include { TADS } from '../subworkflows/local/tads' /* ======================================================================================== @@ -190,6 +190,53 @@ workflow HIC { ch_map_res ) + // + // MODULE: HICEXPLORER/HIC_PLOT_DIST_VS_COUNTS + // + if (!params.skip_dist_decay){ + COOLER.out.cool + .combine(ch_ddecay_res) + .filter{ it[1] == it[3] } + .map { it -> [it[0], it[2]]} + .set{ ch_distdecay } + + HIC_PLOT_DIST_VS_COUNTS( + ch_distdecay + ) + } + + // + // SUB-WORKFLOW: COMPARTMENT CALLING + // + if (!params.skip_compartments){ + COOLER.out.cool + .combine(ch_comp_res) + .filter{ it[1] == it[3] } + .map { it -> [it[0], it[1], it[2]]} + .set{ ch_cool_compartments } + + COMPARTMENTS( + ch_cool_compartments, + ch_fasta, + PREPARE_GENOME.out.chromosome_size + ) + } + + // + // SUB-WORKFLOW : TADS CALLING + // + if (!params.skip_tads){ + COOLER.out.cool + .combine(ch_tads_res) + .filter{ it[1] == it[3] } + .map { it -> [it[0], it[2]]} + .set{ ch_cool_tads } + + TADS( + ch_cool_tads + ) + } + // // MODULE: MultiQC // -- GitLab