diff --git a/conf/modules.config b/conf/modules.config index 104a515..954e266 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -619,6 +619,16 @@ process { memory = { 36.GB * task.attempt } } + withName: ".*:FIMO:SELECT_SIGNIFICANT" { + ext.args = {"'NR==1 || \$9 <= ${params.fimo_qvalue_threshold}'"} + ext.prefix = {"${meta.id}_significant"} + publishDir = [ + path: { "${params.outdir}/06_fimo/05_significant_results" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename } + ] + } + /* SNEEP */ diff --git a/nextflow.config b/nextflow.config index 39d80aa..503283e 100644 --- a/nextflow.config +++ b/nextflow.config @@ -40,6 +40,9 @@ params { // SNEEP options skip_sneep = false + // FIMO options + fimo_qvalue_threshold = 0.05 + dynamite_ofolds = 3 dynamite_ifolds = 6 dynamite_alpha = 0.1 diff --git a/nextflow_schema.json b/nextflow_schema.json index 6ac9a4b..c43b476 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -270,6 +270,21 @@ } } }, + "fimo_options": { + "title": "FIMO options", + "type": "object", + "fa_icon": "fas fa-search", + "description": "Options for FIMO (Find Individual Motif Occurrences) analysis.", + "properties": { + "fimo_qvalue_threshold": { + "type": "number", + "default": 0.05, + "description": "Q-value threshold for filtering significant FIMO results.", + "fa_icon": "fas fa-filter", + "help_text": "Q-value threshold for filtering significant FIMO results. Only motif occurrences with q-values below this threshold will be kept. The default value is 0.05." + } + } + }, "dynamite_options": { "title": "DYNAMITE options", "type": "object", @@ -582,6 +597,9 @@ { "$ref": "#/$defs/optional_steps" }, + { + "$ref": "#/$defs/fimo_options" + }, { "$ref": "#/$defs/dynamite_options" }, diff --git a/subworkflows/local/fimo/main.nf b/subworkflows/local/fimo/main.nf index 9d23437..9e922c1 100644 --- a/subworkflows/local/fimo/main.nf +++ b/subworkflows/local/fimo/main.nf @@ -5,6 +5,7 @@ include { GAWK as CONCAT_FILTER_GFF } from "../../../modules/nf-core include { GNU_SORT as SORT_GFF } from "../../../modules/nf-core/gnu/sort" include { GAWK as CONCAT_FILTER_TSV } from "../../../modules/nf-core/gawk" include { CSVTK_SORT as SORT_TSV } from '../../../modules/nf-core/csvtk/sort' +include { GAWK as SELECT_SIGNIFICANT } from "../../../modules/nf-core/gawk" workflow FIMO { take: @@ -67,8 +68,12 @@ workflow FIMO { SORT_TSV(CONCAT_FILTER_TSV.out.output, 'tsv', 'tsv') ch_versions = ch_versions.mix(SORT_TSV.out.versions) + SELECT_SIGNIFICANT(SORT_TSV.out.sorted, [], false) + ch_versions = ch_versions.mix(SELECT_SIGNIFICANT.out.versions) + emit: - gff = SORT_GFF.out.sorted - tsv = SORT_TSV.out.sorted - versions = ch_versions + gff = SORT_GFF.out.sorted + tsv = SORT_TSV.out.sorted + tsv_significant = SELECT_SIGNIFICANT.out.output + versions = ch_versions } diff --git a/subworkflows/local/fimo/tests/main.nf.test.snap b/subworkflows/local/fimo/tests/main.nf.test.snap index baa1ff7..74109e5 100644 --- a/subworkflows/local/fimo/tests/main.nf.test.snap +++ b/subworkflows/local/fimo/tests/main.nf.test.snap @@ -19,6 +19,14 @@ ] ], "2": [ + [ + { + "id": "L10_chromHMM_promoters" + }, + "L10_chromHMM_promoters_significant.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "3": [ "versions.yml:md5,09deaa382cdc983ffad29500b0c47210", "versions.yml:md5,270cc8fd3cf5da52f09e2bcfb66844d1", "versions.yml:md5,37d1f45c834fbc3c356023cdfed0918a", @@ -26,6 +34,7 @@ "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,c1dfd15a1f2163efd0fc318809c8a071", + "versions.yml:md5,d9cf2bc9a6b5f0916586f0b5184b580f", "versions.yml:md5,def0f65b2a7925e2541586ea7ad06118", "versions.yml:md5,e50e1883b0220a195e1c520411dcbc63" ], @@ -45,6 +54,14 @@ "L10_chromHMM_promoters.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], + "tsv_significant": [ + [ + { + "id": "L10_chromHMM_promoters" + }, + "L10_chromHMM_promoters_significant.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "versions": [ "versions.yml:md5,09deaa382cdc983ffad29500b0c47210", "versions.yml:md5,270cc8fd3cf5da52f09e2bcfb66844d1", @@ -53,6 +70,7 @@ "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,c1dfd15a1f2163efd0fc318809c8a071", + "versions.yml:md5,d9cf2bc9a6b5f0916586f0b5184b580f", "versions.yml:md5,def0f65b2a7925e2541586ea7ad06118", "versions.yml:md5,e50e1883b0220a195e1c520411dcbc63" ] @@ -60,9 +78,9 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nextflow": "25.10.0" }, - "timestamp": "2025-09-28T13:45:59.335325874" + "timestamp": "2025-11-13T18:36:04.422878191" }, "Should run without failures": { "content": [ @@ -80,16 +98,25 @@ { "id": "L10_chromHMM_promoters" }, - "L10_chromHMM_promoters.tsv:md5,b9dccc98df70fa127fed3ec9f5d2b0cd" + "L10_chromHMM_promoters.tsv:md5,903892dbd88b1cf1fe69f6e85ede5974" ] ], "2": [ + [ + { + "id": "L10_chromHMM_promoters" + }, + "L10_chromHMM_promoters_significant.tsv:md5,6ec71314deae3fb80be236a018899406" + ] + ], + "3": [ "versions.yml:md5,270cc8fd3cf5da52f09e2bcfb66844d1", "versions.yml:md5,37d1f45c834fbc3c356023cdfed0918a", "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,91d4e73ea846dae7e805279e47204dc7", "versions.yml:md5,c1dfd15a1f2163efd0fc318809c8a071", + "versions.yml:md5,d9cf2bc9a6b5f0916586f0b5184b580f", "versions.yml:md5,def0f65b2a7925e2541586ea7ad06118", "versions.yml:md5,e50e1883b0220a195e1c520411dcbc63" ], @@ -106,7 +133,15 @@ { "id": "L10_chromHMM_promoters" }, - "L10_chromHMM_promoters.tsv:md5,b9dccc98df70fa127fed3ec9f5d2b0cd" + "L10_chromHMM_promoters.tsv:md5,903892dbd88b1cf1fe69f6e85ede5974" + ] + ], + "tsv_significant": [ + [ + { + "id": "L10_chromHMM_promoters" + }, + "L10_chromHMM_promoters_significant.tsv:md5,6ec71314deae3fb80be236a018899406" ] ], "versions": [ @@ -116,6 +151,7 @@ "versions.yml:md5,612da238fbeb03191d349ddc72093946", "versions.yml:md5,91d4e73ea846dae7e805279e47204dc7", "versions.yml:md5,c1dfd15a1f2163efd0fc318809c8a071", + "versions.yml:md5,d9cf2bc9a6b5f0916586f0b5184b580f", "versions.yml:md5,def0f65b2a7925e2541586ea7ad06118", "versions.yml:md5,e50e1883b0220a195e1c520411dcbc63" ] @@ -123,8 +159,8 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nextflow": "25.10.0" }, - "timestamp": "2025-09-28T13:45:35.150219947" + "timestamp": "2025-11-13T18:35:49.650684716" } } \ No newline at end of file diff --git a/subworkflows/local/fimo/tests/nextflow.config b/subworkflows/local/fimo/tests/nextflow.config index d4f8b01..88a79a4 100644 --- a/subworkflows/local/fimo/tests/nextflow.config +++ b/subworkflows/local/fimo/tests/nextflow.config @@ -12,7 +12,12 @@ process { ext.args = "-v HEADER='motif_id\\tmotif_alt_id\\tsequence_name\\tstart\\tstop\\tstrand\\tscore\\tp-value\\tq-value\\tmatched_sequence' 'BEGIN {print HEADER} FNR==1 {next} /^#/ {next} NF==0 {next} {print}'" } - withName: ".*:FIMO:SORT_TSV" { + withName: "FIMO:SORT_TSV" { ext.args = "-k motif_id:N -k sequence_name:N -k start:n -k stop:n -k strand -k score:nr -k p-value:n -k q-value:n -k matched_sequence" } + + withName: "FIMO:SELECT_SIGNIFICANT" { + ext.args = {"'NR==1 || \$9 <= 0.4'"} + ext.prefix = {"${meta.id}_significant"} + } } diff --git a/tests/default.nf.test.snap b/tests/default.nf.test.snap index 0a0aafa..d52d72a 100644 --- a/tests/default.nf.test.snap +++ b/tests/default.nf.test.snap @@ -1,7 +1,7 @@ { "Should run with bed only": { "content": [ - 174, + 179, { "AFFINITY_MEAN": { "numpy": "2.2.6", @@ -143,6 +143,9 @@ "RUN_FIMO": { "fimo": "5.5.8" }, + "SELECT_SIGNIFICANT": { + "gawk": "5.3.0" + }, "SORT_BED": { "coreutils": 9.3 }, @@ -599,6 +602,12 @@ "06_fimo/04_combined_results/tsv/L1_H3K4me3.tsv", "06_fimo/04_combined_results/tsv/p6_H3K27ac.tsv", "06_fimo/04_combined_results/tsv/p6_H3K4me3.tsv", + "06_fimo/05_significant_results", + "06_fimo/05_significant_results/L10_H3K27ac_significant.tsv", + "06_fimo/05_significant_results/L1_H3K27ac_significant.tsv", + "06_fimo/05_significant_results/L1_H3K4me3_significant.tsv", + "06_fimo/05_significant_results/p6_H3K27ac_significant.tsv", + "06_fimo/05_significant_results/p6_H3K4me3_significant.tsv", "07_sneep", "07_sneep/01_filtered_scales_motifs", "07_sneep/01_filtered_scales_motifs/filtered_sneep_scale_mouse_218.txt", @@ -3949,6 +3958,11 @@ "L1_H3K4me3.tsv:md5,234fdab4f7c07b423f8f022b6c3d0d8a", "p6_H3K27ac.tsv:md5,d75f51f8af229ad6082a3bbe38f94f14", "p6_H3K4me3.tsv:md5,b1004c2222c3b0e75062dbb0083d46eb", + "L10_H3K27ac_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "L1_H3K27ac_significant.tsv:md5,0700a8ce866a2ca40795461eecf1bdf6", + "L1_H3K4me3_significant.tsv:md5,a2b971328c33a981678d90d16849c272", + "p6_H3K27ac_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "p6_H3K4me3_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", "filtered_sneep_scale_mouse_218.txt:md5,26199aaf8103de723163c03bfa8b88b2", "filtered_sneep_transfac_mouse_218.txt:md5,d41d8cd98f00b204e9800998ecf8427e", "L10_H3K27ac.bed:md5,4e48a06e991fdd12712c25823eebc5be", @@ -3975,13 +3989,13 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nextflow": "25.10.0" }, - "timestamp": "2025-09-28T13:58:48.753999494" + "timestamp": "2025-11-13T19:36:12.666238946" }, "Should run with both bed and bam input": { "content": [ - 396, + 407, { "AFFINITY_MEAN": { "numpy": "2.2.6", @@ -4148,6 +4162,9 @@ "RUN_FIMO": { "fimo": "5.5.8" }, + "SELECT_SIGNIFICANT": { + "gawk": "5.3.0" + }, "SORT_BED": { "coreutils": 9.3 }, @@ -5163,6 +5180,18 @@ "06_fimo/04_combined_results/tsv/p6_H3K4me3.tsv", "06_fimo/04_combined_results/tsv/p6_chromHMM_enhancers.tsv", "06_fimo/04_combined_results/tsv/p6_chromHMM_promoters.tsv", + "06_fimo/05_significant_results", + "06_fimo/05_significant_results/L10_H3K27ac_significant.tsv", + "06_fimo/05_significant_results/L10_chromHMM_enhancers_significant.tsv", + "06_fimo/05_significant_results/L10_chromHMM_promoters_significant.tsv", + "06_fimo/05_significant_results/L1_H3K27ac_significant.tsv", + "06_fimo/05_significant_results/L1_H3K4me3_significant.tsv", + "06_fimo/05_significant_results/L1_chromHMM_enhancers_significant.tsv", + "06_fimo/05_significant_results/L1_chromHMM_promoters_significant.tsv", + "06_fimo/05_significant_results/p6_H3K27ac_significant.tsv", + "06_fimo/05_significant_results/p6_H3K4me3_significant.tsv", + "06_fimo/05_significant_results/p6_chromHMM_enhancers_significant.tsv", + "06_fimo/05_significant_results/p6_chromHMM_promoters_significant.tsv", "07_sneep", "07_sneep/01_filtered_scales_motifs", "07_sneep/01_filtered_scales_motifs/filtered_sneep_scale_mouse_218.txt", @@ -10054,6 +10083,17 @@ "p6_H3K4me3.tsv:md5,264817038ac5cd1062b224364c96a451", "p6_chromHMM_enhancers.tsv:md5,38f7bdbc36fbe617905a88934d402630", "p6_chromHMM_promoters.tsv:md5,95a3cfa56a471160f6d1d2b35ddd5362", + "L10_H3K27ac_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "L10_chromHMM_enhancers_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "L10_chromHMM_promoters_significant.tsv:md5,8a21488440735b59233f13af69d9d387", + "L1_H3K27ac_significant.tsv:md5,0700a8ce866a2ca40795461eecf1bdf6", + "L1_H3K4me3_significant.tsv:md5,a2b971328c33a981678d90d16849c272", + "L1_chromHMM_enhancers_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "L1_chromHMM_promoters_significant.tsv:md5,4695ea8aec0374345d4276338add6d75", + "p6_H3K27ac_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "p6_H3K4me3_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "p6_chromHMM_enhancers_significant.tsv:md5,cd7825b546b90fc8e7a8eb1cc8533ca3", + "p6_chromHMM_promoters_significant.tsv:md5,188507b513f0016ecb82965de3b58bd7", "filtered_sneep_scale_mouse_218.txt:md5,26199aaf8103de723163c03bfa8b88b2", "filtered_sneep_transfac_mouse_218.txt:md5,d41d8cd98f00b204e9800998ecf8427e", "L10_H3K27ac.bed:md5,59f68dd95564876b3fe43e9af1195bfa", @@ -10104,8 +10144,8 @@ ], "meta": { "nf-test": "0.9.2", - "nextflow": "25.04.2" + "nextflow": "25.10.0" }, - "timestamp": "2025-09-28T13:53:09.941876368" + "timestamp": "2025-11-13T19:32:43.987079271" } } \ No newline at end of file diff --git a/workflows/tfactivity.nf b/workflows/tfactivity.nf index 2220dde..41088c2 100644 --- a/workflows/tfactivity.nf +++ b/workflows/tfactivity.nf @@ -147,7 +147,7 @@ workflow TFACTIVITY { MOTIFS.out.meme, ) ch_versions = ch_versions.mix(FIMO.out.versions) - ch_fimo_binding_sites = FIMO.out.tsv + ch_fimo_binding_sites = FIMO.out.tsv_significant } if (!params.skip_sneep) {