From 7d2f638131df07e39f22b122a1de1c3b46f67193 Mon Sep 17 00:00:00 2001 From: Sebastian Gonzalez Tirado Date: Thu, 12 Dec 2024 13:07:00 +0000 Subject: [PATCH 1/5] Add first test running and most of the module --- .idea/.gitignore | 8 ++ .idea/codeStyles/Project.xml | 57 +++++++++++++ .idea/codeStyles/codeStyleConfig.xml | 5 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 + .idea/modules.iml | 22 +++++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ modules/nf-core/baysor/environment.yml | 7 ++ modules/nf-core/baysor/main.nf | 82 +++++++++++++++++++ modules/nf-core/baysor/meta.yml | 59 +++++++++++++ modules/nf-core/baysor/tests/main.nf.test | 72 ++++++++++++++++ modules/nf-core/baysor/tests/tags.yml | 2 + 13 files changed, 338 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 modules/nf-core/baysor/environment.yml create mode 100644 modules/nf-core/baysor/main.nf create mode 100644 modules/nf-core/baysor/meta.yml create mode 100644 modules/nf-core/baysor/tests/main.nf.test create mode 100644 modules/nf-core/baysor/tests/tags.yml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000000..13566b81b01 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000000..60dc64bfda7 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000000..79ee123c2b2 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000000..105ce2da2d6 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000000..dc9ea4906e1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.iml b/.idea/modules.iml new file mode 100644 index 00000000000..52f3a0e7e3f --- /dev/null +++ b/.idea/modules.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000000..75a0f377d8e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000000..35eb1ddfbbc --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/modules/nf-core/baysor/environment.yml b/modules/nf-core/baysor/environment.yml new file mode 100644 index 00000000000..4b3c9d37bb8 --- /dev/null +++ b/modules/nf-core/baysor/environment.yml @@ -0,0 +1,7 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +channels: + - conda-forge + - bioconda +dependencies: + - "YOUR-TOOL-HERE" diff --git a/modules/nf-core/baysor/main.nf b/modules/nf-core/baysor/main.nf new file mode 100644 index 00000000000..7bf402450e6 --- /dev/null +++ b/modules/nf-core/baysor/main.nf @@ -0,0 +1,82 @@ +// TODO nf-core: If in doubt look at other nf-core/modules to see how we are doing things! :) +// https://github.com/nf-core/modules/tree/master/modules/nf-core/ +// You can also ask for help via your pull request or on the #modules channel on the nf-core Slack workspace: +// https://nf-co.re/join +// TODO nf-core: A module file SHOULD only define input and output files as command-line parameters. +// All other parameters MUST be provided using the "task.ext" directive, see here: +// https://www.nextflow.io/docs/latest/process.html#ext +// where "task.ext" is a string. +// Any parameters that need to be evaluated in the context of a particular sample +// e.g. single-end/paired-end data MUST also be defined and evaluated appropriately. +// TODO nf-core: Software that can be piped together SHOULD be added to separate module files +// unless there is a run-time, storage advantage in implementing in this way +// e.g. it's ok to have a single module for bwa to output BAM instead of SAM: +// bwa mem | samtools view -B -T ref.fasta +// TODO nf-core: Optional inputs are not currently supported by Nextflow. However, using an empty +// list (`[]`) instead of a file can be used to work around this issue. + +process BAYSOR { + tag '$meta.id' + label 'process_high_memory' + + // TODO nf-core: List required Conda package(s). + // Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10"). + // TODO nf-core: See section in main README for further information regarding finding and adding container addresses to the section below. + conda "${moduleDir}/environment.yml" + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/YOUR-TOOL-HERE': + 'biocontainers/YOUR-TOOL-HERE' }" + + container "docker.io/segonzal/baysor:latest" + + input: + tuple val(meta), path(transcripts_csv) + + output: + // TODO nf-core: Named file extensions MUST be emitted for ALL output channels + tuple val(meta), path("segmentation.csv"), emit: segmentation + // TODO nf-core: List additional required output channels/values here + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = "0.7.1" + // TODO nf-core: Where possible, a command MUST be provided to obtain the version number of the software e.g. 1.10 + // If the software is unable to output a version number on the command-line then it can be manually specified + // e.g. https://github.com/nf-core/modules/blob/master/modules/nf-core/homer/annotatepeaks/main.nf + // Each software used MUST provide the software name and version number in the YAML version file (versions.yml) + // TODO nf-core: It MUST be possible to pass additional parameters to the tool as a command-line string via the "task.ext.args" directive + // TODO nf-core: If the tool supports multi-threading then you MUST provide the appropriate parameter + // using the Nextflow "task" variable e.g. "--threads $task.cpus" + // TODO nf-core: Please replace the example samtools command below with your module's command + // TODO nf-core: Please indent the command appropriately (4 spaces!!) to help with readability ;) + """ + /app/bin/baysor run ${transcripts_csv} -x x_location -y y_location --gene-column feature_name -m 1 -s 24 + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + baysor: $VERSION + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = "0.7.1" + // TODO nf-core: A stub section should mimic the execution of the original module as best as possible + // Have a look at the following examples: + // Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63 + // Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54 + """ + touch ${prefix}.csv + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + baysor: $VERSION + END_VERSIONS + """ +} diff --git a/modules/nf-core/baysor/meta.yml b/modules/nf-core/baysor/meta.yml new file mode 100644 index 00000000000..99b38531f85 --- /dev/null +++ b/modules/nf-core/baysor/meta.yml @@ -0,0 +1,59 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "baysor" +description: Bayesian segmentation of spatial transcriptomics data. +keywords: + - segmentation + - spatial transcriptomics + - cell clustering + - imaging +tools: + - "baysor": + description: "Baysor is a tool that segments cells using spatial gene expression maps. Optionally, segmentation masks can be given as additional input." + homepage: "https://kharchenkolab.github.io/Baysor/dev/" + documentation: "https://kharchenkolab.github.io/Baysor/dev/" + tool_dev_url: "https://github.com/kharchenkolab/Baysor" + doi: "https://doi.org/10.1038/s41587-021-01044-w" + licence: ["MIT license"] + identifier: + +## Baysor requires only a transcript map of the data +input: + - - meta: + type: map + description: | + Groovy Map containing information about + keyword arguments + e. g. `[x: x_location, gene-column: csv_gene_column]` + + - - csv + type: file + description: CSV file + pattern: "*.csv" + +## segmentation results +output: + - meta: + type: map + description: | + Groovy Map containing information about + keyword arguments + e. g. `[x: x_location, gene-column: csv_gene_column]` + + - segmentation: + type: file + description: results of segmentation + pattern: "segmentation.csv" + + - + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + + +authors: + - "@sebgoti8" +maintainers: + - "@sebgoti8" diff --git a/modules/nf-core/baysor/tests/main.nf.test b/modules/nf-core/baysor/tests/main.nf.test new file mode 100644 index 00000000000..18703b70c68 --- /dev/null +++ b/modules/nf-core/baysor/tests/main.nf.test @@ -0,0 +1,72 @@ +// TODO nf-core: Once you have added the required tests, please run the following command to build this file: +// nf-core modules test baysor +nextflow_process { + + name "Test Process BAYSOR" + script "../main.nf" + process "BAYSOR" + + tag "modules" + tag "modules_nfcore" + tag "baysor" + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used + test("baysor - csv") { + + // TODO nf-core: If you are created a test for a chained module + // (the module requires running more than one process to generate the required output) + // add the 'setup' method here. + // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = [ + [ id:'test' ], + file('/workspace/test-datasets/minimal_dataset.csv', checkIfExists: true), + ] + """ + } + } +//input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + then { + assertAll( + { assert process.success }, + //{ assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. + ) + } + + } +} +/* + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. + test("sarscov2 - bam - stub") { + + options "-stub" + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + ) + } + + } + +} +*/ \ No newline at end of file diff --git a/modules/nf-core/baysor/tests/tags.yml b/modules/nf-core/baysor/tests/tags.yml new file mode 100644 index 00000000000..36066680c4a --- /dev/null +++ b/modules/nf-core/baysor/tests/tags.yml @@ -0,0 +1,2 @@ +baysor: + - "modules/nf-core/baysor/**" From bfbcbe98c8d2bf68d57744b955728be4265aca66 Mon Sep 17 00:00:00 2001 From: Sebastian Gonzalez Tirado Date: Tue, 7 Jan 2025 09:50:03 +0000 Subject: [PATCH 2/5] Tests pass --- modules/nf-core/baysor/environment.yml | 3 - modules/nf-core/baysor/main.nf | 60 ++++++-------------- modules/nf-core/baysor/meta.yml | 67 +++++++++++++++++------ modules/nf-core/baysor/tests/main.nf.test | 39 ++++++------- 4 files changed, 81 insertions(+), 88 deletions(-) diff --git a/modules/nf-core/baysor/environment.yml b/modules/nf-core/baysor/environment.yml index 4b3c9d37bb8..e317fff3b0c 100644 --- a/modules/nf-core/baysor/environment.yml +++ b/modules/nf-core/baysor/environment.yml @@ -1,7 +1,4 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json channels: - conda-forge - bioconda dependencies: - - "YOUR-TOOL-HERE" diff --git a/modules/nf-core/baysor/main.nf b/modules/nf-core/baysor/main.nf index 7bf402450e6..46591865024 100644 --- a/modules/nf-core/baysor/main.nf +++ b/modules/nf-core/baysor/main.nf @@ -1,41 +1,19 @@ -// TODO nf-core: If in doubt look at other nf-core/modules to see how we are doing things! :) -// https://github.com/nf-core/modules/tree/master/modules/nf-core/ -// You can also ask for help via your pull request or on the #modules channel on the nf-core Slack workspace: -// https://nf-co.re/join -// TODO nf-core: A module file SHOULD only define input and output files as command-line parameters. -// All other parameters MUST be provided using the "task.ext" directive, see here: -// https://www.nextflow.io/docs/latest/process.html#ext -// where "task.ext" is a string. -// Any parameters that need to be evaluated in the context of a particular sample -// e.g. single-end/paired-end data MUST also be defined and evaluated appropriately. -// TODO nf-core: Software that can be piped together SHOULD be added to separate module files -// unless there is a run-time, storage advantage in implementing in this way -// e.g. it's ok to have a single module for bwa to output BAM instead of SAM: -// bwa mem | samtools view -B -T ref.fasta -// TODO nf-core: Optional inputs are not currently supported by Nextflow. However, using an empty -// list (`[]`) instead of a file can be used to work around this issue. - process BAYSOR { tag '$meta.id' label 'process_high_memory' - - // TODO nf-core: List required Conda package(s). - // Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10"). - // TODO nf-core: See section in main README for further information regarding finding and adding container addresses to the section below. - conda "${moduleDir}/environment.yml" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/YOUR-TOOL-HERE': - 'biocontainers/YOUR-TOOL-HERE' }" - - container "docker.io/segonzal/baysor:latest" + container "docker.io/segonzal/baysor:0.7.1" input: tuple val(meta), path(transcripts_csv) + path(config_toml) output: - // TODO nf-core: Named file extensions MUST be emitted for ALL output channels tuple val(meta), path("segmentation.csv"), emit: segmentation - // TODO nf-core: List additional required output channels/values here + path("*.json"), emit: polygons + path("*.toml"), emit: params + path("*.log"), emit: log + path("*.loom"), emit: loom + path("segmentation_cell_stats.csv"), emit: stats path "versions.yml" , emit: versions when: @@ -45,17 +23,9 @@ process BAYSOR { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def VERSION = "0.7.1" - // TODO nf-core: Where possible, a command MUST be provided to obtain the version number of the software e.g. 1.10 - // If the software is unable to output a version number on the command-line then it can be manually specified - // e.g. https://github.com/nf-core/modules/blob/master/modules/nf-core/homer/annotatepeaks/main.nf - // Each software used MUST provide the software name and version number in the YAML version file (versions.yml) - // TODO nf-core: It MUST be possible to pass additional parameters to the tool as a command-line string via the "task.ext.args" directive - // TODO nf-core: If the tool supports multi-threading then you MUST provide the appropriate parameter - // using the Nextflow "task" variable e.g. "--threads $task.cpus" - // TODO nf-core: Please replace the example samtools command below with your module's command - // TODO nf-core: Please indent the command appropriately (4 spaces!!) to help with readability ;) + """ - /app/bin/baysor run ${transcripts_csv} -x x_location -y y_location --gene-column feature_name -m 1 -s 24 + /app/bin/baysor run ${transcripts_csv} -c ${config_toml} $args cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -67,12 +37,14 @@ process BAYSOR { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def VERSION = "0.7.1" - // TODO nf-core: A stub section should mimic the execution of the original module as best as possible - // Have a look at the following examples: - // Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63 - // Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54 + """ - touch ${prefix}.csv + touch segmentation.csv + touch segmentation_polygons_2d.json + touch segmentation_log.log + touch segmentation_counts.loom + touch segmentation_cell_stats.csv + touch segmentation_params.dump.toml cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/baysor/meta.yml b/modules/nf-core/baysor/meta.yml index 99b38531f85..ee004fee446 100644 --- a/modules/nf-core/baysor/meta.yml +++ b/modules/nf-core/baysor/meta.yml @@ -3,10 +3,10 @@ name: "baysor" description: Bayesian segmentation of spatial transcriptomics data. keywords: - - segmentation - - spatial transcriptomics - - cell clustering - - imaging + - segmentation + - spatial transcriptomics + - cell clustering + - imaging tools: - "baysor": description: "Baysor is a tool that segments cells using spatial gene expression maps. Optionally, segmentation masks can be given as additional input." @@ -17,42 +17,73 @@ tools: licence: ["MIT license"] identifier: -## Baysor requires only a transcript map of the data +## Baysor requires a transcript map of the data and a configuration file with argument values input: - - - meta: + - - meta: type: map description: | Groovy Map containing information about keyword arguments e. g. `[x: x_location, gene-column: csv_gene_column]` - - - - csv + - transcripts_csv: type: file description: CSV file pattern: "*.csv" + - config_toml: + type: file + description: TOML file with config arguments + pattern: "*.toml" + ## segmentation results output: - - meta: - type: map + - segmentation: + - meta: + type: map + description: | + Groovy Map containing information about + keyword arguments + e. g. `[x: x_location, gene-column: csv_gene_column]` + - "*segmentation.csv": + type: file + description: results of segmentation + pattern: "*segmentation.csv" + + - polygons: + type: file description: | - Groovy Map containing information about - keyword arguments - e. g. `[x: x_location, gene-column: csv_gene_column]` + File with outlines of segmentation + pattern: "*.json" - - segmentation: + - params: type: file - description: results of segmentation - pattern: "segmentation.csv" + description: | + File with full list of parameters used for the model + pattern: "segmentation_params.dump.toml" - - + - log: + type: file + description: | + Output file with metadata of running the workflow + pattern: "segmentation_log.log" + + - loom: + type: file + description: | + Loom file with metadata + pattern: "segmentation_counts.loom" + + - stats: + type: file + description: | + Statistics of segmented cells + pattern: "segmentation_cell_stats.csv" - versions: type: file description: File containing software versions pattern: "versions.yml" - authors: - "@sebgoti8" maintainers: diff --git a/modules/nf-core/baysor/tests/main.nf.test b/modules/nf-core/baysor/tests/main.nf.test index 18703b70c68..428a3287813 100644 --- a/modules/nf-core/baysor/tests/main.nf.test +++ b/modules/nf-core/baysor/tests/main.nf.test @@ -1,5 +1,3 @@ -// TODO nf-core: Once you have added the required tests, please run the following command to build this file: -// nf-core modules test baysor nextflow_process { name "Test Process BAYSOR" @@ -10,50 +8,47 @@ nextflow_process { tag "modules_nfcore" tag "baysor" - // TODO nf-core: Change the test name preferably indicating the test-data and file-format used test("baysor - csv") { - // TODO nf-core: If you are created a test for a chained module - // (the module requires running more than one process to generate the required output) - // add the 'setup' method here. - // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). - when { process { """ - // TODO nf-core: define inputs of the process here. Example: - input[0] = [ [ id:'test' ], - file('/workspace/test-datasets/minimal_dataset.csv', checkIfExists: true), + file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), + ] + + input[1] = [ + file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml', checkIfExists: true) ] """ } } -//input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + then { assertAll( { assert process.success }, //{ assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. - // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. ) } } -} -/* - // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. - test("sarscov2 - bam - stub") { + + test("baysor - csv - stub") { options "-stub" when { process { """ - // TODO nf-core: define inputs of the process here. Example: + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), + ] - input[0] = file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + input[1] = [ + file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml' , checkIfExists: true) + ] """ } } @@ -61,12 +56,10 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. + //{ assert snapshot(process.out).match() } ) } } } -*/ \ No newline at end of file From 6a4d36c11417a051097e1265d05c28e6d75ecfcb Mon Sep 17 00:00:00 2001 From: Sebastian Gonzalez Tirado Date: Tue, 7 Jan 2025 11:08:06 +0000 Subject: [PATCH 3/5] Lint and add tests without snapshat --- modules/nf-core/baysor/meta.yml | 12 ++++-------- modules/nf-core/baysor/tests/main.nf.test | 2 -- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/nf-core/baysor/meta.yml b/modules/nf-core/baysor/meta.yml index ee004fee446..91abacda788 100644 --- a/modules/nf-core/baysor/meta.yml +++ b/modules/nf-core/baysor/meta.yml @@ -1,5 +1,3 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json name: "baysor" description: Bayesian segmentation of spatial transcriptomics data. keywords: @@ -22,9 +20,8 @@ input: - - meta: type: map description: | - Groovy Map containing information about - keyword arguments - e. g. `[x: x_location, gene-column: csv_gene_column]` + Groovy Map containing sample information + e.g. [ id:'test' ] - transcripts_csv: type: file description: CSV file @@ -41,9 +38,8 @@ output: - meta: type: map description: | - Groovy Map containing information about - keyword arguments - e. g. `[x: x_location, gene-column: csv_gene_column]` + Groovy Map containing sample information + e.g. [ id:'test' ] - "*segmentation.csv": type: file description: results of segmentation diff --git a/modules/nf-core/baysor/tests/main.nf.test b/modules/nf-core/baysor/tests/main.nf.test index 428a3287813..c8dadb127f2 100644 --- a/modules/nf-core/baysor/tests/main.nf.test +++ b/modules/nf-core/baysor/tests/main.nf.test @@ -28,7 +28,6 @@ nextflow_process { then { assertAll( { assert process.success }, - //{ assert snapshot(process.out).match() } ) } @@ -56,7 +55,6 @@ nextflow_process { then { assertAll( { assert process.success }, - //{ assert snapshot(process.out).match() } ) } From 131bf3cf77441f4ff35d0c76ff80ae82f46bfa66 Mon Sep 17 00:00:00 2001 From: Sebastian Gonzalez Tirado Date: Wed, 8 Jan 2025 13:17:56 +0000 Subject: [PATCH 4/5] Add submodules for run, preview, and segfree commands --- modules/nf-core/baysor/environment.yml | 4 -- modules/nf-core/baysor/preview/main.nf | 53 ++++++++++++++++ modules/nf-core/baysor/preview/meta.yml | 55 ++++++++++++++++ .../nf-core/baysor/preview/tests/main.nf.test | 63 +++++++++++++++++++ modules/nf-core/baysor/preview/tests/tags.yml | 2 + modules/nf-core/baysor/{ => run}/main.nf | 12 +++- modules/nf-core/baysor/{ => run}/meta.yml | 2 +- .../baysor/{ => run}/tests/main.nf.test | 4 +- modules/nf-core/baysor/run/tests/tags.yml | 2 + modules/nf-core/baysor/segfree/main.nf | 53 ++++++++++++++++ modules/nf-core/baysor/segfree/meta.yml | 55 ++++++++++++++++ .../nf-core/baysor/segfree/tests/main.nf.test | 63 +++++++++++++++++++ modules/nf-core/baysor/segfree/tests/tags.yml | 2 + modules/nf-core/baysor/tests/tags.yml | 2 - 14 files changed, 361 insertions(+), 11 deletions(-) delete mode 100644 modules/nf-core/baysor/environment.yml create mode 100644 modules/nf-core/baysor/preview/main.nf create mode 100644 modules/nf-core/baysor/preview/meta.yml create mode 100644 modules/nf-core/baysor/preview/tests/main.nf.test create mode 100644 modules/nf-core/baysor/preview/tests/tags.yml rename modules/nf-core/baysor/{ => run}/main.nf (67%) rename modules/nf-core/baysor/{ => run}/meta.yml (99%) rename modules/nf-core/baysor/{ => run}/tests/main.nf.test (95%) create mode 100644 modules/nf-core/baysor/run/tests/tags.yml create mode 100644 modules/nf-core/baysor/segfree/main.nf create mode 100644 modules/nf-core/baysor/segfree/meta.yml create mode 100644 modules/nf-core/baysor/segfree/tests/main.nf.test create mode 100644 modules/nf-core/baysor/segfree/tests/tags.yml delete mode 100644 modules/nf-core/baysor/tests/tags.yml diff --git a/modules/nf-core/baysor/environment.yml b/modules/nf-core/baysor/environment.yml deleted file mode 100644 index e317fff3b0c..00000000000 --- a/modules/nf-core/baysor/environment.yml +++ /dev/null @@ -1,4 +0,0 @@ -channels: - - conda-forge - - bioconda -dependencies: diff --git a/modules/nf-core/baysor/preview/main.nf b/modules/nf-core/baysor/preview/main.nf new file mode 100644 index 00000000000..1fa054a775a --- /dev/null +++ b/modules/nf-core/baysor/preview/main.nf @@ -0,0 +1,53 @@ +process BAYSOR_PREVIEW { + tag '$meta.id' + label 'process_high_memory' + container "docker.io/segonzal/baysor:0.7.1" + + input: + tuple val(meta), path(transcripts_csv) + path(config_toml) + + output: + tuple val(meta), path("preview.html"), emit: preview_html + path("preview_preview_log.log"), emit: preview_log + + when: + task.ext.when == null || task.ext.when + + script: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "BAYSOR_PREVIEW module does not support Conda. Please use Docker / Singularity / Podman instead." + } + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = "0.7.1" + + """ + baysor preview ${transcripts_csv} -c ${config_toml} $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + baysor: $VERSION + END_VERSIONS + """ + + stub: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "BAYSOR_PREVIEW module does not support Conda. Please use Docker / Singularity / Podman instead." + } + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = "0.7.1" + + """ + touch preview.html + touch preview_preview_log.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + baysor: $VERSION + END_VERSIONS + """ +} diff --git a/modules/nf-core/baysor/preview/meta.yml b/modules/nf-core/baysor/preview/meta.yml new file mode 100644 index 00000000000..731a8d2d6d9 --- /dev/null +++ b/modules/nf-core/baysor/preview/meta.yml @@ -0,0 +1,55 @@ +name: "baysor_preview" +description: Preview run for visualization of data. +keywords: + - exploratory-data-analysis +tools: + - "baysor": + description: "Baysor is a tool that segments cells using spatial gene expression maps. Optionally, segmentation masks can be given as additional input." + homepage: "https://kharchenkolab.github.io/Baysor/dev/" + documentation: "https://kharchenkolab.github.io/Baysor/dev/" + tool_dev_url: "https://github.com/kharchenkolab/Baysor" + doi: "https://doi.org/10.1038/s41587-021-01044-w" + licence: ["MIT license"] + identifier: + +## baysor_preview requires a transcript map of the data and a configuration file with argument values +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - transcripts_csv: + type: file + description: CSV file + pattern: "*.csv" + + - config_toml: + type: file + description: TOML file with config arguments + pattern: "*.toml" + +## segmentation results +output: + - preview_html: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - "preview.html": + type: file + description: segmentation preview + pattern: "preview.html" + + - preview_log: + type: file + description: | + Log file with summary statistics of preview + pattern: "preview_preview_log.log" + + +authors: + - "@sebgoti8" +maintainers: + - "@sebgoti8" diff --git a/modules/nf-core/baysor/preview/tests/main.nf.test b/modules/nf-core/baysor/preview/tests/main.nf.test new file mode 100644 index 00000000000..016e28f44e9 --- /dev/null +++ b/modules/nf-core/baysor/preview/tests/main.nf.test @@ -0,0 +1,63 @@ +nextflow_process { + + name "Test Process BAYSOR_PREVIEW" + script "../main.nf" + process "BAYSOR_PREVIEW" + + tag "modules" + tag "modules_nfcore" + tag "baysor" + + test("baysor preview - html") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), + ] + + input[1] = [ + file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + ) + } + + } + + test("baysor preview - html - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), + ] + + input[1] = [ + file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml' , checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + ) + } + + } + +} diff --git a/modules/nf-core/baysor/preview/tests/tags.yml b/modules/nf-core/baysor/preview/tests/tags.yml new file mode 100644 index 00000000000..62f8a278055 --- /dev/null +++ b/modules/nf-core/baysor/preview/tests/tags.yml @@ -0,0 +1,2 @@ +baysor: + - "modules/nf-core/baysor/preview/**" diff --git a/modules/nf-core/baysor/main.nf b/modules/nf-core/baysor/run/main.nf similarity index 67% rename from modules/nf-core/baysor/main.nf rename to modules/nf-core/baysor/run/main.nf index 46591865024..43d8af47558 100644 --- a/modules/nf-core/baysor/main.nf +++ b/modules/nf-core/baysor/run/main.nf @@ -1,4 +1,4 @@ -process BAYSOR { +process BAYSOR_RUN { tag '$meta.id' label 'process_high_memory' container "docker.io/segonzal/baysor:0.7.1" @@ -20,12 +20,16 @@ process BAYSOR { task.ext.when == null || task.ext.when script: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "BAYSOR_RUN module does not support Conda. Please use Docker / Singularity / Podman instead." + } def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def VERSION = "0.7.1" """ - /app/bin/baysor run ${transcripts_csv} -c ${config_toml} $args + baysor run ${transcripts_csv} -c ${config_toml} $args cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -34,6 +38,10 @@ process BAYSOR { """ stub: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "BAYSOR_RUN module does not support Conda. Please use Docker / Singularity / Podman instead." + } def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def VERSION = "0.7.1" diff --git a/modules/nf-core/baysor/meta.yml b/modules/nf-core/baysor/run/meta.yml similarity index 99% rename from modules/nf-core/baysor/meta.yml rename to modules/nf-core/baysor/run/meta.yml index 91abacda788..99b3b0a358c 100644 --- a/modules/nf-core/baysor/meta.yml +++ b/modules/nf-core/baysor/run/meta.yml @@ -1,4 +1,4 @@ -name: "baysor" +name: "baysor_run" description: Bayesian segmentation of spatial transcriptomics data. keywords: - segmentation diff --git a/modules/nf-core/baysor/tests/main.nf.test b/modules/nf-core/baysor/run/tests/main.nf.test similarity index 95% rename from modules/nf-core/baysor/tests/main.nf.test rename to modules/nf-core/baysor/run/tests/main.nf.test index c8dadb127f2..7915ad06aa2 100644 --- a/modules/nf-core/baysor/tests/main.nf.test +++ b/modules/nf-core/baysor/run/tests/main.nf.test @@ -1,8 +1,8 @@ nextflow_process { - name "Test Process BAYSOR" + name "Test Process BAYSOR_RUN" script "../main.nf" - process "BAYSOR" + process "BAYSOR_RUN" tag "modules" tag "modules_nfcore" diff --git a/modules/nf-core/baysor/run/tests/tags.yml b/modules/nf-core/baysor/run/tests/tags.yml new file mode 100644 index 00000000000..0371b2b2952 --- /dev/null +++ b/modules/nf-core/baysor/run/tests/tags.yml @@ -0,0 +1,2 @@ +baysor: + - "modules/nf-core/baysor/run/**" diff --git a/modules/nf-core/baysor/segfree/main.nf b/modules/nf-core/baysor/segfree/main.nf new file mode 100644 index 00000000000..430b443f4d7 --- /dev/null +++ b/modules/nf-core/baysor/segfree/main.nf @@ -0,0 +1,53 @@ +process BAYSOR_SEGFREE { + tag '$meta.id' + label 'process_high_memory' + container "docker.io/segonzal/baysor:0.7.1" + + input: + tuple val(meta), path(transcripts_csv) + path(config_toml) + + output: + tuple val(meta), path("ncvs.loom"), emit: ncvs + path("ncvs_segfree_log.log"), emit: ncvs_log + + when: + task.ext.when == null || task.ext.when + + script: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "BAYSOR_SEGFREE module does not support Conda. Please use Docker / Singularity / Podman instead." + } + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = "0.7.1" + + """ + baysor segfree ${transcripts_csv} -c ${config_toml} $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + baysor: $VERSION + END_VERSIONS + """ + + stub: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "BAYSOR_SEGFREE module does not support Conda. Please use Docker / Singularity / Podman instead." + } + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def VERSION = "0.7.1" + + """ + touch ncvs.loom + touch ncvs_segfree_log.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + baysor: $VERSION + END_VERSIONS + """ +} diff --git a/modules/nf-core/baysor/segfree/meta.yml b/modules/nf-core/baysor/segfree/meta.yml new file mode 100644 index 00000000000..965119edb55 --- /dev/null +++ b/modules/nf-core/baysor/segfree/meta.yml @@ -0,0 +1,55 @@ +name: "baysor_segfree" +description: Extract neighborhood composition vectors (NVCs) from a dataset. +keywords: + - neighborhood +tools: + - "baysor": + description: "Baysor is a tool that segments cells using spatial gene expression maps. Optionally, segmentation masks can be given as additional input." + homepage: "https://kharchenkolab.github.io/Baysor/dev/" + documentation: "https://kharchenkolab.github.io/Baysor/dev/" + tool_dev_url: "https://github.com/kharchenkolab/Baysor" + doi: "https://doi.org/10.1038/s41587-021-01044-w" + licence: ["MIT license"] + identifier: + +## baysor_segfree requires a transcript map of the data and a configuration file with argument values +input: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - transcripts_csv: + type: file + description: CSV file + pattern: "*.csv" + + - config_toml: + type: file + description: TOML file with config arguments + pattern: "*.toml" + +## neighborhood composition vectors +output: + - preview_html: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - "ncvs.loom": + type: file + description: loom file with neighborhood results + pattern: "preview.html" + + - ncvs_log: + type: file + description: | + Log file with summary statistics + pattern: "ncvs_segfree_log.log" + + +authors: + - "@sebgoti8" +maintainers: + - "@sebgoti8" diff --git a/modules/nf-core/baysor/segfree/tests/main.nf.test b/modules/nf-core/baysor/segfree/tests/main.nf.test new file mode 100644 index 00000000000..c5b7c9bdb1a --- /dev/null +++ b/modules/nf-core/baysor/segfree/tests/main.nf.test @@ -0,0 +1,63 @@ +nextflow_process { + + name "Test Process BAYSOR_SEGFREE" + script "../main.nf" + process "BAYSOR_SEGFREE" + + tag "modules" + tag "modules_nfcore" + tag "baysor" + + test("baysor segfree - loom") { + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), + ] + + input[1] = [ + file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml', checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + ) + } + + } + + test("baysor segfree - loom - stub") { + + options "-stub" + + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), + ] + + input[1] = [ + file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml' , checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + ) + } + + } + +} diff --git a/modules/nf-core/baysor/segfree/tests/tags.yml b/modules/nf-core/baysor/segfree/tests/tags.yml new file mode 100644 index 00000000000..338452eb3ac --- /dev/null +++ b/modules/nf-core/baysor/segfree/tests/tags.yml @@ -0,0 +1,2 @@ +baysor: + - "modules/nf-core/baysor/segfree/**" diff --git a/modules/nf-core/baysor/tests/tags.yml b/modules/nf-core/baysor/tests/tags.yml deleted file mode 100644 index 36066680c4a..00000000000 --- a/modules/nf-core/baysor/tests/tags.yml +++ /dev/null @@ -1,2 +0,0 @@ -baysor: - - "modules/nf-core/baysor/**" From a73216a79672fb7d9b6baf04387bfe244179f4cd Mon Sep 17 00:00:00 2001 From: Sebastian Gonzalez Tirado Date: Thu, 9 Jan 2025 10:33:54 +0000 Subject: [PATCH 5/5] Change channel factory in tests --- modules/nf-core/baysor/run/main.nf | 2 +- modules/nf-core/baysor/run/meta.yml | 2 +- modules/nf-core/baysor/run/tests/main.nf.test | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/nf-core/baysor/run/main.nf b/modules/nf-core/baysor/run/main.nf index 43d8af47558..e5be2e90245 100644 --- a/modules/nf-core/baysor/run/main.nf +++ b/modules/nf-core/baysor/run/main.nf @@ -8,7 +8,7 @@ process BAYSOR_RUN { path(config_toml) output: - tuple val(meta), path("segmentation.csv"), emit: segmentation + tuple val(meta), path("*segmentation.csv"), emit: segmentation path("*.json"), emit: polygons path("*.toml"), emit: params path("*.log"), emit: log diff --git a/modules/nf-core/baysor/run/meta.yml b/modules/nf-core/baysor/run/meta.yml index 99b3b0a358c..a511658f906 100644 --- a/modules/nf-core/baysor/run/meta.yml +++ b/modules/nf-core/baysor/run/meta.yml @@ -43,7 +43,7 @@ output: - "*segmentation.csv": type: file description: results of segmentation - pattern: "*segmentation.csv" + pattern: "segmentation.csv" - polygons: type: file diff --git a/modules/nf-core/baysor/run/tests/main.nf.test b/modules/nf-core/baysor/run/tests/main.nf.test index 7915ad06aa2..92588aba262 100644 --- a/modules/nf-core/baysor/run/tests/main.nf.test +++ b/modules/nf-core/baysor/run/tests/main.nf.test @@ -13,10 +13,10 @@ nextflow_process { when { process { """ - input[0] = [ - [ id:'test' ], + input[0] = Channel.of([ + [ id:'segmentation' ], file(params.modules_testdata_base_path + 'spatial_omics/xenium/homo_sapiens/spatial_gene_expression.csv', checkIfExists: true), - ] + ]) input[1] = [ file(params.modules_testdata_base_path + 'generic/config/config_baysor.toml', checkIfExists: true)