From ac819179e9ee36abb4946b051edd44fc0cbc2efc Mon Sep 17 00:00:00 2001 From: nschcolnicov Date: Fri, 27 Dec 2024 18:21:31 +0000 Subject: [PATCH 1/2] added nftests --- modules/nf-core/gprofiler2/gost/main.nf | 40 +- .../gost/templates/gprofiler2_gost.R | 2 +- .../gprofiler2/gost/tests/main.nf.test | 114 +++++ .../gprofiler2/gost/tests/main.nf.test.snap | 413 ++++++++++++++++++ .../gprofiler2/gost/tests/nextflow.config | 3 + 5 files changed, 561 insertions(+), 11 deletions(-) create mode 100644 modules/nf-core/gprofiler2/gost/tests/main.nf.test create mode 100644 modules/nf-core/gprofiler2/gost/tests/main.nf.test.snap create mode 100644 modules/nf-core/gprofiler2/gost/tests/nextflow.config diff --git a/modules/nf-core/gprofiler2/gost/main.nf b/modules/nf-core/gprofiler2/gost/main.nf index acb18b93..b0fd21e8 100644 --- a/modules/nf-core/gprofiler2/gost/main.nf +++ b/modules/nf-core/gprofiler2/gost/main.nf @@ -4,8 +4,8 @@ process GPROFILER2_GOST { conda "${moduleDir}/environment.yml" container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/mulled-v2-3712554873398d849d0d11b22440f41febbc4ede:aa19bb8afc0ec6456a4f3cd650f7577c3bbdd4f3-0': - 'biocontainers/mulled-v2-3712554873398d849d0d11b22440f41febbc4ede:aa19bb8afc0ec6456a4f3cd650f7577c3bbdd4f3-0' }" + 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/e4/e4b0e10a72db4ad519c128c4e3cef6e10bc1a83440af31f105ab389a5532589a/data': + 'community.wave.seqera.io/library/r-ggplot2_r-gprofiler2:fab855ea9f680400' }" input: tuple val(meta), path(de_file) @@ -13,14 +13,14 @@ process GPROFILER2_GOST { path(background_file) output: - tuple val(meta), path("*.gprofiler2.all_enriched_pathways.tsv") , emit: all_enrich - tuple val(meta), path("*.gprofiler2.gost_results.rds") , emit: rds , optional: true - tuple val(meta), path("*.gprofiler2.gostplot.png") , emit: plot_png , optional: true - tuple val(meta), path("*.gprofiler2.gostplot.html") , emit: plot_html , optional: true - tuple val(meta), path("*.gprofiler2.*.sub_enriched_pathways.tsv") , emit: sub_enrich , optional: true - tuple val(meta), path("*.gprofiler2.*.sub_enriched_pathways.png") , emit: sub_plot , optional: true - tuple val(meta), path("*ENSG_filtered.gmt") , emit: filtered_gmt, optional: true - tuple val(meta), path("*R_sessionInfo.log") , emit: session_info + tuple val(meta), path("*.gprofiler2.all_enriched_pathways.tsv") , emit: all_enrich + tuple val(meta), path("*.gprofiler2.gost_results.rds") , emit: rds , optional: true + tuple val(meta), path("*.gprofiler2.gostplot.png") , emit: plot_png , optional: true + tuple val(meta), path("*.gprofiler2.gostplot.html") , emit: plot_html , optional: true + tuple val(meta), path("*.gprofiler2.*.sub_enriched_pathways.tsv") , emit: sub_enrich , optional: true + tuple val(meta), path("*.gprofiler2.*.sub_enriched_pathways.png") , emit: sub_plot , optional: true + tuple val(meta), path("*ENSG_filtered.gmt") , emit: filtered_gmt, optional: true + tuple val(meta), path("*R_sessionInfo.log") , emit: session_info path "versions.yml" , emit: versions when: @@ -28,4 +28,24 @@ process GPROFILER2_GOST { script: template 'gprofiler2_gost.R' + + stub: + def prefix = task.ext.prefix ?: meta.id + """ + touch ${prefix}.gprofiler2.all_enriched_pathways.tsv + touch ${prefix}.gprofiler2.gost_results.rds + touch ${prefix}.gprofiler2.gostplot.png + touch ${prefix}.gprofiler2.gostplot.html + touch ${prefix}.gprofiler2.*.sub_enriched_pathways.tsv + touch ${prefix}.gprofiler2.*.sub_enriched_pathways.png + touch ${prefix}.ENSG_filtered.gmt + touch ${prefix}.R_sessionInfo.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + r-base: \$(echo \$(R --version 2>&1) | sed 's/^.*R version //; s/ .*\$//') + r-ggplot2: \$(Rscript -e "library(ggplot2); cat(as.character(packageVersion('ggplot2')))") + r-gprofiler2: \$(Rscript -e "library(gprofiler2); cat(as.character(packageVersion('gprofiler2')))") + END_VERSIONS + """ } diff --git a/modules/nf-core/gprofiler2/gost/templates/gprofiler2_gost.R b/modules/nf-core/gprofiler2/gost/templates/gprofiler2_gost.R index 1de2a754..0e2c0f1e 100644 --- a/modules/nf-core/gprofiler2/gost/templates/gprofiler2_gost.R +++ b/modules/nf-core/gprofiler2/gost/templates/gprofiler2_gost.R @@ -449,7 +449,7 @@ gprofiler2.version <- as.character(packageVersion('gprofiler2')) ggplot2.version <- as.character(packageVersion('ggplot2')) writeLines( c( - '"\${task.process}":', + '"$task.process":', paste(' r-base:', r.version), paste(' r-ggplot2:', ggplot2.version), paste(' r-gprofiler2:', gprofiler2.version) diff --git a/modules/nf-core/gprofiler2/gost/tests/main.nf.test b/modules/nf-core/gprofiler2/gost/tests/main.nf.test new file mode 100644 index 00000000..e535b9cb --- /dev/null +++ b/modules/nf-core/gprofiler2/gost/tests/main.nf.test @@ -0,0 +1,114 @@ +nextflow_process { + + name "Test Process GPROFILER2_GOST" + script "../main.nf" + process "GPROFILER2_GOST" + config "./nextflow.config" + + tag "modules" + tag "modules_nfcore" + tag "gprofiler" + tag "gprofiler_gost" + tag "gost" + + test("test") { + + when { + params{ + module_args = null + } + process { + """ + input[0] = [['id':'Condition_treatment_Control_Treated', 'variable':'Condition treatment', 'reference':'Control', 'target':'Treated', 'blocking':''], file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/study.filtered.tsv", checkIfExists: true)] + input[1] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/modules/data/genomics/mus_musculus/gene_set_analysis/mh.all.v2022.1.Mm.symbols.gmt", checkIfExists: true) + input[2] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_genotype_WT_KO.deseq2.results_filtered.tsv", checkIfExists: true) + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("args_test") { + + when { + params{ + gprofiler2_significant = true + gprofiler2_measure_underrepresentation = false + gprofiler2_correction_method = "gSCS" + gprofiler2_evcodes = false + gprofiler2_max_qval = 0.05 + gprofiler2_domain_scope = "annotated" + gprofiler2_min_diff = 1 + report_round_digits = 4 + gprofiler2_palette_name = "Blues" + differential_feature_id_column = "gene_id" + gprofiler2_token = null + gprofiler2_organism = "mmusculus" + gprofiler2_background_column = null + gprofiler2_sources = null + + module_args = [ + "--significant \"${params.gprofiler2_significant}\"", + "--measure_underrepresentation \"${params.gprofiler2_measure_underrepresentation}\"", + "--correction_method \"${params.gprofiler2_correction_method}\"", + "--evcodes \"${params.gprofiler2_evcodes}\"", + "--pval_threshold \"${params.gprofiler2_max_qval}\"", + "--domain_scope ${params.gprofiler2_domain_scope}", + "--min_diff \"${params.gprofiler2_min_diff}\"", + "--round_digits ${params.report_round_digits}", + "--palette_name \"${params.gprofiler2_palette_name}\"", + ((params.differential_feature_id_column == null) ? '' : "--de_id_column \"${params.differential_feature_id_column}\""), + ((params.gprofiler2_token == null) ? '' : "--token \"${params.gprofiler2_token}\""), + ((params.gprofiler2_organism == null) ? '' : "--organism \"${params.gprofiler2_organism}\""), + ((params.gprofiler2_background_column == null) ? '' : "--background_column \"${params.gprofiler2_background_column}\""), + ((params.gprofiler2_sources == null) ? '' : "--sources \"${params.gprofiler2_sources}\"") + ].join(' ').trim() + } + process { + """ + input[0] = [['id':'Condition_treatment_Control_Treated', 'variable':'Condition treatment', 'reference':'Control', 'target':'Treated', 'blocking':''], file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/study.filtered.tsv", checkIfExists: true)] + input[1] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/modules/data/genomics/mus_musculus/gene_set_analysis/mh.all.v2022.1.Mm.symbols.gmt", checkIfExists: true) + input[2] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_genotype_WT_KO.deseq2.results_filtered.tsv", checkIfExists: true) + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("stub") { + + options "-stub" + + when { + params{ + module_args = null + } + process { + """ + input[0] = [['id':'Condition_treatment_Control_Treated', 'variable':'Condition treatment', 'reference':'Control', 'target':'Treated', 'blocking':''], file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/study.filtered.tsv", checkIfExists: true)] + input[1] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/modules/data/genomics/mus_musculus/gene_set_analysis/mh.all.v2022.1.Mm.symbols.gmt", checkIfExists: true) + input[2] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_genotype_WT_KO.deseq2.results_filtered.tsv", checkIfExists: true) + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } +} diff --git a/modules/nf-core/gprofiler2/gost/tests/main.nf.test.snap b/modules/nf-core/gprofiler2/gost/tests/main.nf.test.snap new file mode 100644 index 00000000..7e10fe02 --- /dev/null +++ b/modules/nf-core/gprofiler2/gost/tests/main.nf.test.snap @@ -0,0 +1,413 @@ +{ + "args_test": { + "content": [ + { + "0": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.all_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + + ], + "7": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "R_sessionInfo.log:md5,53f19395ba80140dc8a10155f285f383" + ] + ], + "8": [ + "versions.yml:md5,7ff4ab78463faf97bba7e698ed9a9069" + ], + "all_enrich": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.all_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "filtered_gmt": [ + + ], + "plot_html": [ + + ], + "plot_png": [ + + ], + "rds": [ + + ], + "session_info": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "R_sessionInfo.log:md5,53f19395ba80140dc8a10155f285f383" + ] + ], + "sub_enrich": [ + + ], + "sub_plot": [ + + ], + "versions": [ + "versions.yml:md5,7ff4ab78463faf97bba7e698ed9a9069" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-27T18:19:32.792294745" + }, + "test": { + "content": [ + { + "0": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.all_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + + ], + "7": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "R_sessionInfo.log:md5,53f19395ba80140dc8a10155f285f383" + ] + ], + "8": [ + "versions.yml:md5,7ff4ab78463faf97bba7e698ed9a9069" + ], + "all_enrich": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.all_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "filtered_gmt": [ + + ], + "plot_html": [ + + ], + "plot_png": [ + + ], + "rds": [ + + ], + "session_info": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "R_sessionInfo.log:md5,53f19395ba80140dc8a10155f285f383" + ] + ], + "sub_enrich": [ + + ], + "sub_plot": [ + + ], + "versions": [ + "versions.yml:md5,7ff4ab78463faf97bba7e698ed9a9069" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-27T18:18:59.391739948" + }, + "stub": { + "content": [ + { + "0": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.all_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.gost_results.rds:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.gostplot.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "3": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.gostplot.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "4": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.*.sub_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "5": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.*.sub_enriched_pathways.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "6": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.ENSG_filtered.gmt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "7": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.R_sessionInfo.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "8": [ + "versions.yml:md5,7ff4ab78463faf97bba7e698ed9a9069" + ], + "all_enrich": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.all_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "filtered_gmt": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.ENSG_filtered.gmt:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "plot_html": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.gostplot.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "plot_png": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.gostplot.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "rds": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.gost_results.rds:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "session_info": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.R_sessionInfo.log:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "sub_enrich": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.*.sub_enriched_pathways.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "sub_plot": [ + [ + { + "id": "Condition_treatment_Control_Treated", + "variable": "Condition treatment", + "reference": "Control", + "target": "Treated", + "blocking": "" + }, + "Condition_treatment_Control_Treated.gprofiler2.*.sub_enriched_pathways.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,7ff4ab78463faf97bba7e698ed9a9069" + ] + } + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.3" + }, + "timestamp": "2024-12-27T18:19:42.877124578" + } +} \ No newline at end of file diff --git a/modules/nf-core/gprofiler2/gost/tests/nextflow.config b/modules/nf-core/gprofiler2/gost/tests/nextflow.config new file mode 100644 index 00000000..1a77344d --- /dev/null +++ b/modules/nf-core/gprofiler2/gost/tests/nextflow.config @@ -0,0 +1,3 @@ +process { + ext.args = params.module_args +} \ No newline at end of file From a4fbb02ebca6742e14ffb573e6e46ddb137b8481 Mon Sep 17 00:00:00 2001 From: nschcolnicov Date: Fri, 27 Dec 2024 18:23:03 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c739194c..40de075d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [[#380](https://github.com/nf-core/differentialabundance/pull/380)] - Replace local filter_diff_table module with nf-core one, and create nf-tests for tabular_to_gsea_chip. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@pinin4fjords](https://github.com/pinin4fjords)) - [[#382](https://github.com/nf-core/differentialabundance/pull/382)] - Add YAML formatted contrasts file handling. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@TODO](https://github.com/TODO)) - [[#411](https://github.com/nf-core/differentialabundance/pull/411)] - Replace local tabulartogseachip with nf-core version. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@TODO](https://github.com/TODO)) +- [[#415](https://github.com/nf-core/differentialabundance/pull/415)] - Add nf-tests to gprofiler2/gost. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@TODO](https://github.com/TODO)) ### Fixed