From b5ce19693df3d3e7b45d3d78cdde7550e5e60851 Mon Sep 17 00:00:00 2001 From: nschcolnicov Date: Tue, 10 Dec 2024 21:25:10 +0000 Subject: [PATCH] Initialized module --- modules/nf-core/immunedeconv/environment.yml | 5 + modules/nf-core/immunedeconv/main.nf | 85 +++++++++ modules/nf-core/immunedeconv/meta.yml | 49 ++++++ .../nf-core/immunedeconv/tests/main.nf.test | 65 +++++++ .../immunedeconv/tests/main.nf.test.snap | 161 ++++++++++++++++++ modules/nf-core/immunedeconv/tests/tags.yml | 2 + 6 files changed, 367 insertions(+) create mode 100644 modules/nf-core/immunedeconv/environment.yml create mode 100644 modules/nf-core/immunedeconv/main.nf create mode 100644 modules/nf-core/immunedeconv/meta.yml create mode 100644 modules/nf-core/immunedeconv/tests/main.nf.test create mode 100644 modules/nf-core/immunedeconv/tests/main.nf.test.snap create mode 100644 modules/nf-core/immunedeconv/tests/tags.yml diff --git a/modules/nf-core/immunedeconv/environment.yml b/modules/nf-core/immunedeconv/environment.yml new file mode 100644 index 00000000..8d81153a --- /dev/null +++ b/modules/nf-core/immunedeconv/environment.yml @@ -0,0 +1,5 @@ +channels: + - conda-forge + - bioconda +dependencies: + - bioconda::immunedeconv=2.1.2 diff --git a/modules/nf-core/immunedeconv/main.nf b/modules/nf-core/immunedeconv/main.nf new file mode 100644 index 00000000..c7167cd3 --- /dev/null +++ b/modules/nf-core/immunedeconv/main.nf @@ -0,0 +1,85 @@ +process IMMUNEDECONV { + tag "$meta.id" + label 'process_single' + + conda "${moduleDir}/environment.yml" + container "community.wave.seqera.io/library/r-immunedeconv:2.1.2--e1bb1ea1cf505cb3" + + input: + tuple val(meta), path(input_file), val(method), val(function) + + output: + tuple val(meta), path("deconvolution_results.tsv"), emit: deconv_table + tuple val(meta), path("*png"), emit: deconv_plots, optional: true + path "versions.yml", emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + """ + # Run Rscript for deconvolution + Rscript -e " + library(dplyr) + library(ggplot2) + library(tidyr) + library(immunedeconv) + library(tibble) + library(readr) + + # Load the TSV file + gene_expression_matrix <- readr::read_tsv('${input_file}') %>% + as.data.frame() %>% + tibble::column_to_rownames('gene_symbol') + + # Generate results + result <- immunedeconv::${function}(gene_expression_matrix, method = '${method}') + + # Save the result to a CSV file + readr::write_tsv(result, 'deconvolution_results.tsv') + + # Plot and save results + # Plot 1: Stacked bar chart + plot1 <- result %>% + gather(sample, fraction, -cell_type) %>% + ggplot(aes(x = sample, y = fraction, fill = cell_type)) + + geom_bar(stat = 'identity') + + coord_flip() + + scale_fill_brewer(palette = 'Paired') + + scale_x_discrete(limits = rev(levels(result))) + + # Save Plot 1 + ggsave('plot1_stacked_bar_chart.png', plot = plot1, dpi = 300, width = 10, height = 8) + + # Plot 2: Points with facets + plot2 <- result %>% + gather(sample, score, -cell_type) %>% + ggplot(aes(x = sample, y = score, color = cell_type)) + + geom_point(size = 4) + + facet_wrap(~cell_type, scales = 'free_x', ncol = 3) + + scale_color_brewer(palette = 'Paired', guide = FALSE) + + coord_flip() + + theme_bw() + + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) + + # Save Plot 2 + ggsave('plot2_points_with_facets.png', plot = plot2, dpi = 300, width = 12, height = 10) + " + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + r-immunedeconv: \$(Rscript -e "cat(as.character(packageVersion('immunedeconv')))") + END_VERSIONS + """ + + stub: + """ + touch deconvolution_results.tsv + touch deconvolution_results.png + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + r-immunedeconv: \$(Rscript -e "cat(as.character(packageVersion('immunedeconv')))") + END_VERSIONS + """ +} diff --git a/modules/nf-core/immunedeconv/meta.yml b/modules/nf-core/immunedeconv/meta.yml new file mode 100644 index 00000000..dd005a7d --- /dev/null +++ b/modules/nf-core/immunedeconv/meta.yml @@ -0,0 +1,49 @@ +name: untar #TODO update for module +description: Extract files. +keywords: + - untar + - uncompress + - extract +tools: + - untar: + description: | + Extract tar.gz files. + documentation: https://www.gnu.org/software/tar/manual/ + licence: ["GPL-3.0-or-later"] + identifier: "" +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - archive: + type: file + description: File to be untar + pattern: "*.{tar}.{gz}" +output: + - untar: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - $prefix: + type: directory + description: Directory containing contents of archive + pattern: "*/" + - versions: + - versions.yml: + type: file + description: File containing software versions + pattern: "versions.yml" +authors: + - "@joseespinosa" + - "@drpatelh" + - "@matthdsm" + - "@jfy133" +maintainers: + - "@joseespinosa" + - "@drpatelh" + - "@matthdsm" + - "@jfy133" diff --git a/modules/nf-core/immunedeconv/tests/main.nf.test b/modules/nf-core/immunedeconv/tests/main.nf.test new file mode 100644 index 00000000..4826679e --- /dev/null +++ b/modules/nf-core/immunedeconv/tests/main.nf.test @@ -0,0 +1,65 @@ +nextflow_process { + + name "Test Process IMMUNEDECONV" + script "../main.nf" + process "IMMUNEDECONV" + tag "modules" + tag "modules_nfcore" + tag "immunedeconv" + + test("test_immunedeconv_bulkmat") { + + when { + process { //val(meta), path(input_file), val(method), val(function) + """ + input[0] = [ [id:"immunedeconv"], file('https://raw.githubusercontent.com/omnideconv/immunedeconv/refs/heads/master/tests/testthat/bulk_mat.tsv', checkIfExists: true), "quantiseq", "deconvolute" ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("test_immunedeconv_bulkmat_mouse") { + + when { + process { //val(meta), path(input_file), val(method), val(function) + """ + input[0] = [ [id:"immunedeconv"], file('https://github.com/omnideconv/immunedeconv/raw/refs/heads/master/tests/testthat/bulk_mat_mouse.tsv', checkIfExists: true), "mmcp_counter", "deconvolute_mouse" ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } + + test("test_immunedeconv - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ [id:"immunedeconv"], file('https://raw.githubusercontent.com/omnideconv/immunedeconv/refs/heads/master/tests/testthat/bulk_mat.tsv', checkIfExists: true), "quantiseq", "deconvolute" ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } +} diff --git a/modules/nf-core/immunedeconv/tests/main.nf.test.snap b/modules/nf-core/immunedeconv/tests/main.nf.test.snap new file mode 100644 index 00000000..d2ff3577 --- /dev/null +++ b/modules/nf-core/immunedeconv/tests/main.nf.test.snap @@ -0,0 +1,161 @@ +{ + "test_immunedeconv_bulkmat": { + "content": [ + { + "0": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.tsv:md5,7ea22a01f198957cbe8dae92015583ff" + ] + ], + "1": [ + [ + { + "id": "immunedeconv" + }, + [ + "plot1_stacked_bar_chart.png:md5,68884a86fc1daeaa8128f913c4d0505f", + "plot2_points_with_facets.png:md5,9ca7caf63afefe6c38fe13f6a7a834f7" + ] + ] + ], + "2": [ + "versions.yml:md5,e155e29c7a7b3ba2ef8e3ed4c495b929" + ], + "deconv_plots": [ + [ + { + "id": "immunedeconv" + }, + [ + "plot1_stacked_bar_chart.png:md5,68884a86fc1daeaa8128f913c4d0505f", + "plot2_points_with_facets.png:md5,9ca7caf63afefe6c38fe13f6a7a834f7" + ] + ] + ], + "deconv_table": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.tsv:md5,7ea22a01f198957cbe8dae92015583ff" + ] + ], + "versions": [ + "versions.yml:md5,e155e29c7a7b3ba2ef8e3ed4c495b929" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-10T21:22:59.810734363" + }, + "test_immunedeconv_bulkmat_mouse": { + "content": [ + { + "0": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.tsv:md5,5c69779bac914a28737eb40460807bec" + ] + ], + "1": [ + [ + { + "id": "immunedeconv" + }, + [ + "plot1_stacked_bar_chart.png:md5,1907610f4d0712cc2e75eb64066719de", + "plot2_points_with_facets.png:md5,565088d5475a9be0dc0dadfc0f2e63d2" + ] + ] + ], + "2": [ + "versions.yml:md5,e155e29c7a7b3ba2ef8e3ed4c495b929" + ], + "deconv_plots": [ + [ + { + "id": "immunedeconv" + }, + [ + "plot1_stacked_bar_chart.png:md5,1907610f4d0712cc2e75eb64066719de", + "plot2_points_with_facets.png:md5,565088d5475a9be0dc0dadfc0f2e63d2" + ] + ] + ], + "deconv_table": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.tsv:md5,5c69779bac914a28737eb40460807bec" + ] + ], + "versions": [ + "versions.yml:md5,e155e29c7a7b3ba2ef8e3ed4c495b929" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-10T21:23:14.667010563" + }, + "test_immunedeconv - stub": { + "content": [ + { + "0": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + "versions.yml:md5,e155e29c7a7b3ba2ef8e3ed4c495b929" + ], + "deconv_plots": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "deconv_table": [ + [ + { + "id": "immunedeconv" + }, + "deconvolution_results.tsv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,e155e29c7a7b3ba2ef8e3ed4c495b929" + ] + } + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.2" + }, + "timestamp": "2024-12-10T21:23:22.185910251" + } +} \ No newline at end of file diff --git a/modules/nf-core/immunedeconv/tests/tags.yml b/modules/nf-core/immunedeconv/tests/tags.yml new file mode 100644 index 00000000..0c881831 --- /dev/null +++ b/modules/nf-core/immunedeconv/tests/tags.yml @@ -0,0 +1,2 @@ +untar: ##TODO update for module + - modules/nf-core/untar/**