Skip to content

Commit

Permalink
scimap/spatiallda (nf-core#5260)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
migueLib authored and tucano committed Mar 20, 2024
1 parent 800990d commit 328426e
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ jobs:
tags: molkartgarage/clahe
- profile: conda
tags: quartonotebook
- profile: conda
tags: scimap/spatiallda
- profile: conda
tags: sentieon/bwaindex
- profile: conda
Expand Down
50 changes: 50 additions & 0 deletions modules/nf-core/scimap/spatiallda/main.nf
Original file line number Diff line number Diff line change
@@ -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
"""
}
52 changes: 52 additions & 0 deletions modules/nf-core/scimap/spatiallda/meta.yml
Original file line number Diff line number Diff line change
@@ -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"
55 changes: 55 additions & 0 deletions modules/nf-core/scimap/spatiallda/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -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() },
)
}
}
}
79 changes: 79 additions & 0 deletions modules/nf-core/scimap/spatiallda/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions modules/nf-core/scimap/spatiallda/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -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'
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/scimap/spatiallda/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scimap/spatiallda:
- "modules/nf-core/scimap/spatiallda/**"
1 change: 1 addition & 0 deletions tests/config/test_data.config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 328426e

Please sign in to comment.