From 0718260ac888082bfef724e794e38eaa693778f5 Mon Sep 17 00:00:00 2001 From: Erik Fasterius Date: Mon, 15 Jan 2024 10:49:21 +0100 Subject: [PATCH] Update `spaceranger/count` module --- modules.json | 5 +- .../nf-core/spaceranger/count/environment.yml | 5 - modules/nf-core/spaceranger/count/main.nf | 8 +- modules/nf-core/spaceranger/count/meta.yml | 5 +- .../spaceranger/count/spaceranger-count.diff | 47 ---- .../spaceranger/count/tests/main.nf.test | 226 ++++++++++++++++++ .../spaceranger/count/tests/main.nf.test.snap | 54 +++++ .../nf-core/spaceranger/count/tests/tags.yml | 2 + 8 files changed, 291 insertions(+), 61 deletions(-) delete mode 100644 modules/nf-core/spaceranger/count/environment.yml delete mode 100644 modules/nf-core/spaceranger/count/spaceranger-count.diff create mode 100644 modules/nf-core/spaceranger/count/tests/main.nf.test create mode 100644 modules/nf-core/spaceranger/count/tests/main.nf.test.snap create mode 100644 modules/nf-core/spaceranger/count/tests/tags.yml diff --git a/modules.json b/modules.json index 0dfba23..968eaf0 100644 --- a/modules.json +++ b/modules.json @@ -22,9 +22,8 @@ }, "spaceranger/count": { "branch": "master", - "git_sha": "3f5420aa22e00bd030a2556dfdffc9e164ec0ec5", - "installed_by": ["modules"], - "patch": "modules/nf-core/spaceranger/count/spaceranger-count.diff" + "git_sha": "e89a3110141cdf77abd4fbc85cd0d7cb8f01b49b", + "installed_by": ["modules"] }, "untar": { "branch": "master", diff --git a/modules/nf-core/spaceranger/count/environment.yml b/modules/nf-core/spaceranger/count/environment.yml deleted file mode 100644 index a5049bf..0000000 --- a/modules/nf-core/spaceranger/count/environment.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: spaceranger_count -channels: - - conda-forge - - bioconda - - defaults diff --git a/modules/nf-core/spaceranger/count/main.nf b/modules/nf-core/spaceranger/count/main.nf index cac83e0..c0f10e5 100644 --- a/modules/nf-core/spaceranger/count/main.nf +++ b/modules/nf-core/spaceranger/count/main.nf @@ -10,7 +10,7 @@ process SPACERANGER_COUNT { path(probeset) output: - tuple val(meta), path("outs/**"), emit: outs + tuple val(meta), path("**/outs/**"), emit: outs path "versions.yml", emit: versions when: @@ -46,7 +46,6 @@ process SPACERANGER_COUNT { $alignment \\ $slidefile \\ $args - mv ${prefix}/outs outs cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -59,9 +58,10 @@ process SPACERANGER_COUNT { if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { error "SPACERANGER_COUNT module does not support Conda. Please use Docker / Singularity / Podman instead." } + def prefix = task.ext.prefix ?: "${meta.id}" """ - mkdir -p outs/ - touch outs/fake_file.txt + mkdir -p "${prefix}/outs/" + touch ${prefix}/outs/fake_file.txt cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/spaceranger/count/meta.yml b/modules/nf-core/spaceranger/count/meta.yml index 2811fd2..123c96c 100644 --- a/modules/nf-core/spaceranger/count/meta.yml +++ b/modules/nf-core/spaceranger/count/meta.yml @@ -20,7 +20,8 @@ tools: homepage: "https://support.10xgenomics.com/spatial-gene-expression/software/pipelines/latest/what-is-space-ranger" documentation: "https://support.10xgenomics.com/spatial-gene-expression/software/pipelines/latest/what-is-space-ranger" tool_dev_url: "https://support.10xgenomics.com/spatial-gene-expression/software/pipelines/latest/what-is-space-ranger" - licence: "10x Genomics EULA" + licence: + - "10x Genomics EULA" input: - meta: type: map @@ -83,7 +84,7 @@ output: - outs: type: file description: Files containing the outputs of Cell Ranger, see official 10X Genomics documentation for a complete list - pattern: "outs/*" + pattern: "${meta.id}/outs/*" - versions: type: file description: File containing software versions diff --git a/modules/nf-core/spaceranger/count/spaceranger-count.diff b/modules/nf-core/spaceranger/count/spaceranger-count.diff deleted file mode 100644 index e138217..0000000 --- a/modules/nf-core/spaceranger/count/spaceranger-count.diff +++ /dev/null @@ -1,47 +0,0 @@ -Changes in module 'nf-core/spaceranger/count' ---- modules/nf-core/spaceranger/count/meta.yml -+++ modules/nf-core/spaceranger/count/meta.yml -@@ -83,7 +83,7 @@ - - outs: - type: file - description: Files containing the outputs of Cell Ranger, see official 10X Genomics documentation for a complete list -- pattern: "${meta.id}/outs/*" -+ pattern: "outs/*" - - versions: - type: file - description: File containing software versions - ---- modules/nf-core/spaceranger/count/main.nf -+++ modules/nf-core/spaceranger/count/main.nf -@@ -10,7 +10,7 @@ - path(probeset) - - output: -- tuple val(meta), path("**/outs/**"), emit: outs -+ tuple val(meta), path("outs/**"), emit: outs - path "versions.yml", emit: versions - - when: -@@ -46,6 +46,7 @@ - $alignment \\ - $slidefile \\ - $args -+ mv ${prefix}/outs outs - - cat <<-END_VERSIONS > versions.yml - "${task.process}": -@@ -58,10 +59,9 @@ - if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { - error "SPACERANGER_COUNT module does not support Conda. Please use Docker / Singularity / Podman instead." - } -- def prefix = task.ext.prefix ?: "${meta.id}" - """ -- mkdir -p "${prefix}/outs/" -- touch ${prefix}/outs/fake_file.txt -+ mkdir -p outs/ -+ touch outs/fake_file.txt - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - -************************************************************ diff --git a/modules/nf-core/spaceranger/count/tests/main.nf.test b/modules/nf-core/spaceranger/count/tests/main.nf.test new file mode 100644 index 0000000..b751b07 --- /dev/null +++ b/modules/nf-core/spaceranger/count/tests/main.nf.test @@ -0,0 +1,226 @@ +nextflow_process { + + name "Test Process SPACERANGER_COUNT" + script "../main.nf" + process "SPACERANGER_COUNT" + + tag "modules" + tag "modules_nfcore" + tag "spaceranger" + tag "spaceranger/count" + tag "spaceranger/mkgtf" + tag "spaceranger/mkref" + + test("spaceranger v1 - homo_sapiens - fasta - gtf - fastq - tif - csv") { + + setup { + run("SPACERANGER_MKGTF") { + script "../../mkgtf/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + """ + } + } + } + + setup { + run("SPACERANGER_MKREF") { + script "../../mkref/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + input[1] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + input[2] = 'homo_sapiens_chr22_reference' + """ + } + } + } + + when { + process { + """ + input[0] = [ + [ + id: 'Visium_FFPE_Human_Ovarian_Cancer', + slide: 'V10L13-020', + area: 'D1' + ], // Meta map + [ + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_v1_fastq_1_gz']), + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_v1_fastq_2_gz']) + ], // Reads + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_v1_image']), // Image + [], // Cytaimage + [], // Darkimage + [], // Colorizedimage + [], // Manual alignment (default: automatic alignment) + [], // Slide specification (default: automatic download) + ] + input[1] = SPACERANGER_MKREF.out.reference // Reference + input[2] = [] // Probeset (default: use the one included with Space Ranger) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.versions, + process.out.outs.get(0).get(1).findAll { file(it).name !in [ + 'web_summary.html', + 'scalefactors_json.json', + 'barcodes.tsv.gz', + 'features.tsv.gz', + 'matrix.mtx.gz' + ]} + ).match() + }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'web_summary.html' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'scalefactors_json.json' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'barcodes.tsv.gz' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'features.tsv.gz' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'matrix.mtx.gz' }).exists() } + ) + } + } + + test("spaceranger v1 (stub) - homo_sapiens - fasta - gtf - fastq - tif - csv") { + + setup { + run("SPACERANGER_MKGTF") { + script "../../mkgtf/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + """ + } + } + } + + setup { + run("SPACERANGER_MKREF") { + script "../../mkref/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + input[1] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + input[2] = 'homo_sapiens_chr22_reference' + """ + } + } + } + + options "-stub" + + when { + process { + """ + input[0] = [ + [ + id: 'Visium_FFPE_Human_Ovarian_Cancer', + slide: 'V10L13-020', + area: 'D1' + ], // Meta map + [ + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_v1_fastq_1_gz']), + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_v1_fastq_2_gz']) + ], // Reads + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_v1_image']), // Image + [], // Cytaimage + [], // Darkimage + [], // Colorizedimage + [], // Manual alignment (default: automatic alignment) + [], // Slide specification (default: automatic download) + ] + input[1] = SPACERANGER_MKREF.out.reference // Reference + input[2] = [] // Probeset (default: use the one included with Space Ranger) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + } + + test("spaceranger v2 - homo_sapiens - fasta - gtf - fastq - tif - csv") { + setup { + run("SPACERANGER_MKGTF") { + script "../../mkgtf/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + """ + } + } + } + + setup { + run("SPACERANGER_MKREF") { + script "../../mkref/main.nf" + process { + """ + input[0] = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) + input[1] = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true) + input[2] = 'homo_sapiens_chr22_reference' + """ + } + } + } + + when { + process { + """ + input[0] = [ + [ + id: 'CytAssist_11mm_FFPE_Human_Glioblastoma_2', + slide: 'V52Y10-317', + area: 'B1' + ], // Meta map + [ + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_cytassist_fastq_1_gz']), + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_cytassist_fastq_2_gz']) + ], // Reads + [], // Image + file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_cytassist_image']), // Cytaimage + [], // Darkimage + [], // Colorizedimage + [], // Manual alignment (default: automatic alignment) + file('https://s3.us-west-2.amazonaws.com/10x.spatial-slides/gpr/V52Y10/V52Y10-317.gpr') // Slide specification (default: automatic download) + ] + input[1] = SPACERANGER_MKREF.out.reference // Reference + input[2] = file(params.test_data['homo_sapiens']['10xgenomics']['spaceranger']['test_10x_ffpe_cytassist_probeset']) // Probeset (default: use the one included with Space Ranger) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + process.out.versions, + process.out.outs.get(0).get(1).findAll { file(it).name !in [ + 'web_summary.html', + 'scalefactors_json.json', + 'molecule_info.h5', + 'barcodes.tsv.gz', + 'features.tsv.gz', + 'matrix.mtx.gz' + ]} + ).match() + }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'web_summary.html' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'scalefactors_json.json' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'molecule_info.h5' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'barcodes.tsv.gz' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'features.tsv.gz' }).exists() }, + { assert file(process.out.outs.get(0).get(1).find { file(it).name == 'matrix.mtx.gz' }).exists() } + ) + } + } +} \ No newline at end of file diff --git a/modules/nf-core/spaceranger/count/tests/main.nf.test.snap b/modules/nf-core/spaceranger/count/tests/main.nf.test.snap new file mode 100644 index 0000000..ece665f --- /dev/null +++ b/modules/nf-core/spaceranger/count/tests/main.nf.test.snap @@ -0,0 +1,54 @@ +{ + "spaceranger v1 (stub) - homo_sapiens - fasta - gtf - fastq - tif - csv": { + "content": [ + [ + "versions.yml:md5,038e17e049a72dd3d417d0e221dce732" + ] + ], + "timestamp": "2024-01-09T15:09:24.723008" + }, + "spaceranger v2 - homo_sapiens - fasta - gtf - fastq - tif - csv": { + "content": [ + [ + "versions.yml:md5,038e17e049a72dd3d417d0e221dce732" + ], + [ + "filtered_feature_bc_matrix.h5:md5,509e18ed6b218850e5095124ecc771c1", + "metrics_summary.csv:md5,412caff0fcd9f39cb54671147058de2f", + "possorted_genome_bam.bam:md5,23cd192fcc217d835b8c0afee0619f40", + "possorted_genome_bam.bam.bai:md5,baf623d3e554ba5008304f32414c9fb2", + "probe_set.csv:md5,5bfb8f12319be1b2b6c14142537c3804", + "raw_feature_bc_matrix.h5:md5,2263d2c756785f86dc28f6b76fd61b73", + "raw_probe_bc_matrix.h5:md5,3d5e711d0891ca2caaf301a2c1fbda91", + "aligned_fiducials.jpg:md5,51dcc3a32d3d5ca4704f664c8ede81ef", + "cytassist_image.tiff:md5,0fb04a55e5658f4d158d986a334b034d", + "detected_tissue_image.jpg:md5,64d9adb4844ab91506131476d93b28dc", + "tissue_hires_image.png:md5,1c0f1e94522a886c19f56a629227e097", + "tissue_lowres_image.png:md5,8c1fcb378f7f886301f49ffc4f84360a", + "tissue_positions.csv:md5,1b2df34f9e762e9e64aa226226b96c4b" + ] + ], + "timestamp": "2024-01-11T17:49:27.776247" + }, + "spaceranger v1 - homo_sapiens - fasta - gtf - fastq - tif - csv": { + "content": [ + [ + "versions.yml:md5,038e17e049a72dd3d417d0e221dce732" + ], + [ + "filtered_feature_bc_matrix.h5:md5,f444a4816bf40d377271a6157b320556", + "metrics_summary.csv:md5,5e36f2f9b6987791e0b5eb2736d25115", + "molecule_info.h5:md5,b3d14dfbfc167bb8fc9b158f083efdb6", + "possorted_genome_bam.bam:md5,6ed7f3bb2f17322113f940989a3771ff", + "possorted_genome_bam.bam.bai:md5,08ce9ffd30d9b82091932b744873610b", + "raw_feature_bc_matrix.h5:md5,7e937b4863a98b0d3784f4e21c07c326", + "aligned_fiducials.jpg:md5,f6217ddd707bb189e665f56b130c3da8", + "detected_tissue_image.jpg:md5,4a26b91db5aca179d627b86f352006e2", + "tissue_hires_image.png:md5,d91f8f176ae35ab824ede87117ac0889", + "tissue_lowres_image.png:md5,475a04208d193191c84d7a3b5d4eb287", + "tissue_positions.csv:md5,37d288d0e29e8572ea4c5bef292de4b6" + ] + ], + "timestamp": "2024-01-11T20:34:18.669838" + } +} \ No newline at end of file diff --git a/modules/nf-core/spaceranger/count/tests/tags.yml b/modules/nf-core/spaceranger/count/tests/tags.yml new file mode 100644 index 0000000..ad51f67 --- /dev/null +++ b/modules/nf-core/spaceranger/count/tests/tags.yml @@ -0,0 +1,2 @@ +spaceranger/count: + - "modules/nf-core/spaceranger/count/**"