From 328426e4bb6b30c33e0e0c0ca3d77bf66035fd06 Mon Sep 17 00:00:00 2001 From: "Miguel A. Ibarra-Arellano" Date: Wed, 20 Mar 2024 13:37:14 +0100 Subject: [PATCH] scimap/spatiallda (#5260) * Add phenotyped data under imaging/downstream * Add the scimap implementation of spatialLDA * passes lint and tests * now it has real tests * Added stub tests * Prettifies * exclude scimap/spatiallda from executing conda test * This works! :D --- .github/workflows/test.yml | 2 + modules/nf-core/scimap/spatiallda/main.nf | 50 ++++++++++++ modules/nf-core/scimap/spatiallda/meta.yml | 52 ++++++++++++ .../scimap/spatiallda/tests/main.nf.test | 55 +++++++++++++ .../scimap/spatiallda/tests/main.nf.test.snap | 79 +++++++++++++++++++ .../scimap/spatiallda/tests/nextflow.config | 5 ++ .../nf-core/scimap/spatiallda/tests/tags.yml | 2 + tests/config/test_data.config | 1 + 8 files changed, 246 insertions(+) create mode 100644 modules/nf-core/scimap/spatiallda/main.nf create mode 100644 modules/nf-core/scimap/spatiallda/meta.yml create mode 100644 modules/nf-core/scimap/spatiallda/tests/main.nf.test create mode 100644 modules/nf-core/scimap/spatiallda/tests/main.nf.test.snap create mode 100644 modules/nf-core/scimap/spatiallda/tests/nextflow.config create mode 100644 modules/nf-core/scimap/spatiallda/tests/tags.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bf82516a05..0f1d0c9bf37 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -565,6 +565,8 @@ jobs: tags: molkartgarage/clahe - profile: conda tags: quartonotebook + - profile: conda + tags: scimap/spatiallda - profile: conda tags: sentieon/bwaindex - profile: conda diff --git a/modules/nf-core/scimap/spatiallda/main.nf b/modules/nf-core/scimap/spatiallda/main.nf new file mode 100644 index 00000000000..855de661d89 --- /dev/null +++ b/modules/nf-core/scimap/spatiallda/main.nf @@ -0,0 +1,50 @@ +process SCIMAP_SPATIALLDA { + tag "$meta.id" + label 'process_single' + + container "docker.io/miguelib/scimap:0.0.3" + + input: + tuple val(meta), path(phenotyped) + + output: + tuple val(meta), path("*.csv") , emit: spatial_lda_output + tuple val(meta), path("*.png") , emit: composition_plot + tuple val(meta), path("*.html"), emit: motif_location_plot + 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}" + + """ + python /scimap/scripts/spatialLDA.py \ + --input $phenotyped \ + --output "${prefix}.csv" \ + --neighborhood-composition-plot "${prefix}.png" \ + --motif-locations-plot "${prefix}.html" \ + $args + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + scimap/spatialLDA: \$(python /scimap/scripts/spatialLDA.py --version) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + touch "${prefix}.csv" + touch "${prefix}.png" + touch "${prefix}.html" + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + scimap/spatialLDA: \$(python /scimap/scripts/spatialLDA.py --version) + END_VERSIONS + """ +} diff --git a/modules/nf-core/scimap/spatiallda/meta.yml b/modules/nf-core/scimap/spatiallda/meta.yml new file mode 100644 index 00000000000..b26932f2bc4 --- /dev/null +++ b/modules/nf-core/scimap/spatiallda/meta.yml @@ -0,0 +1,52 @@ +name: "scimap_spatiallda" +description: SpatialLDA uses an LDA based approach for the identification of cellular neighborhoods, using cell type identities. +keywords: + - spatial_neighborhoods + - scimap + - spatial_omics +tools: + - "scimap": + description: "Scimap is a scalable toolkit for analyzing spatial molecular data. The underlying framework is generalizable to spatial datasets mapped to XY coordinates. The package uses the anndata framework making it easy to integrate with other popular single-cell analysis toolkits. It includes preprocessing, phenotyping, visualization, clustering, spatial analysis and differential spatial testing. The Python-based implementation efficiently deals with large datasets of millions of cells." + homepage: "https://scimap.xyz/" + documentation: "https://scimap.xyz/tutorials/1-scimap-tutorial-getting-started/" + tool_dev_url: "https://github.com/labsyspharm/scimap" + doi: "10.5281/zenodo.7854095" + licence: ["MIT licence"] +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - phenotyped: + type: file + description: Phenotyped CSV file, it must contain the columns, sampleID, X, Y and Phenotype. + pattern: "*.{csv}" +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - spatial_lda_output: + type: file + description: File with the motifs detected from SpatialLDA + pattern: "*.{csv}" + - composition_plot: + type: file + description: Plot with the motif composition and the cell type composition of motifs. + pattern: "*.{png}" + - motif_location_plot: + type: file + description: Plot with the locations of the motifs. + pattern: "*.{html}" +authors: + - "@migueLib" + - "@chiarasch" +maintainers: + - "@migueLib" + - "@chiarasch" diff --git a/modules/nf-core/scimap/spatiallda/tests/main.nf.test b/modules/nf-core/scimap/spatiallda/tests/main.nf.test new file mode 100644 index 00000000000..90924a3b82a --- /dev/null +++ b/modules/nf-core/scimap/spatiallda/tests/main.nf.test @@ -0,0 +1,55 @@ +nextflow_process { + + name "Test Process SCIMAP_SPATIALLDA" + script "../main.nf" + config "./nextflow.config" + process "SCIMAP_SPATIALLDA" + + tag "modules" + tag "modules_nfcore" + tag "scimap" + tag "scimap/spatiallda" + + test("spatiallda - csv") { + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['imaging']['downstream']['phenotyped'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.spatial_lda_output }, + { assert process.out.composition_plot }, + { assert process.out.motif_location_plot }, + { assert process.out.versions }, + { assert snapshot(process.out.versions).match("versions") }, + ) + } + } + test("spatiallda - stub") { + options "-stub" + when { + process { + """ + input[0] = [ + [ id:'test' ], + file(params.test_data['imaging']['downstream']['phenotyped'], checkIfExists: true) + ] + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() }, + ) + } + } +} diff --git a/modules/nf-core/scimap/spatiallda/tests/main.nf.test.snap b/modules/nf-core/scimap/spatiallda/tests/main.nf.test.snap new file mode 100644 index 00000000000..c68b57bc365 --- /dev/null +++ b/modules/nf-core/scimap/spatiallda/tests/main.nf.test.snap @@ -0,0 +1,79 @@ +{ + "spatiallda - stub": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test.csv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "2": [ + [ + { + "id": "test" + }, + "test.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "3": [ + "versions.yml:md5,26948183ce6db386ac8f262bd4a4acad" + ], + "composition_plot": [ + [ + { + "id": "test" + }, + "test.png:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "motif_location_plot": [ + [ + { + "id": "test" + }, + "test.html:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "spatial_lda_output": [ + [ + { + "id": "test" + }, + "test.csv:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "versions": [ + "versions.yml:md5,26948183ce6db386ac8f262bd4a4acad" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-20T12:20:10.410687398" + }, + "versions": { + "content": [ + [ + "versions.yml:md5,26948183ce6db386ac8f262bd4a4acad" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-03-20T12:19:45.25425554" + } +} \ No newline at end of file diff --git a/modules/nf-core/scimap/spatiallda/tests/nextflow.config b/modules/nf-core/scimap/spatiallda/tests/nextflow.config new file mode 100644 index 00000000000..1598378b6ba --- /dev/null +++ b/modules/nf-core/scimap/spatiallda/tests/nextflow.config @@ -0,0 +1,5 @@ +process { + withName: "SCIMAP_SPATIALLDA" { + ext.args = '--phenotype phenotype --x-coordinate X_centroid --y-coordinate Y_centroid --sample-id sampleid --radius 30 --num-motifs 10 --method radius' + } +} diff --git a/modules/nf-core/scimap/spatiallda/tests/tags.yml b/modules/nf-core/scimap/spatiallda/tests/tags.yml new file mode 100644 index 00000000000..0375a08f645 --- /dev/null +++ b/modules/nf-core/scimap/spatiallda/tests/tags.yml @@ -0,0 +1,2 @@ +scimap/spatiallda: + - "modules/nf-core/scimap/spatiallda/**" diff --git a/tests/config/test_data.config b/tests/config/test_data.config index 3cacec1f61c..2e3e182f72c 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -793,6 +793,7 @@ params { 'downstream' { markers = "${params.test_data_base}/data/imaging/downstream/markers.csv" cell_feature_array = "${params.test_data_base}/data/imaging/downstream/cycif_tonsil_cell.csv" + phenotyped = "${params.test_data_base}/data/imaging/downstream/phenotyped.csv" } 'background_subtraction' { markers = "${params.test_data_base}/data/imaging/background_subtraction/markers.csv"