diff --git a/conf/modules.config b/conf/modules.config index 7f4fceaf6bc79b61b4d142dcc4765feb4d13e446..9cef5f9b0dea9b7ed06be24cb17f84e87eaf0687 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 51f9788e55ba0dcc068cbcb35c0711d57274ce7f..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..74cd265fa48906c116a64947939bcdd6905eea2e --- /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 0000000000000000000000000000000000000000..531bab94dd948e6fe7cab6c884c10829447351cf --- /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 7338cd39ed982e1552ae59049fad244d3c15883b..0000000000000000000000000000000000000000 --- 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 e3089f3eb3cd3359eec2ede37e27aae8273d0527..23d78ac0f3083a00224b130655d94070b1478228 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 897b0575e827e731b2e703ea0c73d2f9a2bd470c..5c61d8726ef45569d44bf13064e8959c1a0662f7 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 9f0836af8542b012253e82afa63b8ebd45bd5bf4..496e8d6ee13fbd63ae7162ca295b2689e22b84e0 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 a65a385b05b26d7069e2b99d5d6a29864f2fec82..0204db7e0c10dc8574bf45f8827dd7f1be602b92 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 //