Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added nftests to gseagsea #7266

Merged
merged 14 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 51 additions & 29 deletions modules/nf-core/gsea/gsea/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,48 @@ process GSEA_GSEA {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/gsea:4.3.2--hdfd78af_0':
'biocontainers/gsea:4.3.2--hdfd78af_0' }"
'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/0f/0f4fe28961396eeeaa98484cb4f2db5c79abfdf117700df132312fe5c41bff81/data':
'community.wave.seqera.io/library/gsea:4.3.2--a7421d7504fd7c81' }"

input:
tuple val(meta), path(gct), path(cls), path(gene_sets)
tuple val(reference), val(target)
path(chip) // Optional identifier mapping file

output:
tuple val(meta), path("*.rpt") , emit: rpt
tuple val(meta), path("*index.html") , emit: index_html
tuple val(meta), path("*heat_map_corr_plot.html") , emit: heat_map_corr_plot
tuple val(meta), path("*gsea_report_for_${reference}.tsv") , emit: report_tsvs_ref
tuple val(meta), path("*gsea_report_for_${reference}.html"), emit: report_htmls_ref
tuple val(meta), path("*gsea_report_for_${target}.tsv") , emit: report_tsvs_target
tuple val(meta), path("*gsea_report_for_${target}.html") , emit: report_htmls_target
tuple val(meta), path("*ranked_gene_list*.tsv") , emit: ranked_gene_list
tuple val(meta), path("*gene_set_sizes.tsv") , emit: gene_set_sizes
tuple val(meta), path("*global_es_histogram.png") , emit: histogram
tuple val(meta), path("*heat_map_1.png") , emit: heatmap
tuple val(meta), path("*pvalues_vs_nes_plot.png") , emit: pvalues_vs_nes_plot
tuple val(meta), path("*ranked_list_corr_2.png") , emit: ranked_list_corr
tuple val(meta), path("*butterfly_plot.png") , emit: butterfly_plot, optional: true
tuple val(meta), path("*[!gene_set_size|gsea_report|ranked_gene_list]*.tsv"), emit: gene_set_tsv, optional: true
tuple val(meta), path("*[!gsea_report|heat_map_corr_plot|index|pos_snapshot|neg_snapshot]*.html"), emit: gene_set_html, optional: true
tuple val(meta), path("*.rpt") , emit: rpt
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
tuple val(meta), path("*index.html") , emit: index_html
tuple val(meta), path("*heat_map_corr_plot.html") , emit: heat_map_corr_plot
tuple val(meta), path("*gsea_report_for_${reference}.tsv") , emit: report_tsvs_ref
tuple val(meta), path("*gsea_report_for_${reference}.html") , emit: report_htmls_ref
tuple val(meta), path("*gsea_report_for_${target}.tsv") , emit: report_tsvs_target
tuple val(meta), path("*gsea_report_for_${target}.html") , emit: report_htmls_target
tuple val(meta), path("*ranked_gene_list*.tsv") , emit: ranked_gene_list
tuple val(meta), path("*gene_set_sizes.tsv") , emit: gene_set_sizes
tuple val(meta), path("*global_es_histogram.png") , emit: histogram
tuple val(meta), path("*heat_map_1.png") , emit: heatmap
tuple val(meta), path("*pvalues_vs_nes_plot.png") , emit: pvalues_vs_nes_plot
tuple val(meta), path("*ranked_list_corr_2.png") , emit: ranked_list_corr
tuple val(meta), path("*butterfly_plot.png") , emit: butterfly_plot, optional: true
tuple val(meta), path("*[!gene_set_size|gsea_report|ranked_gene_list]*.tsv") , emit: gene_set_tsv, optional: true
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
tuple val(meta), path("*[!gsea_report|heat_map_corr_plot|index|pos_snapshot|neg_snapshot]*.html") , emit: gene_set_html, optional: true
tuple val(meta), path("*[!butterfly|enplot|global_es_histogram|gset_rnd_es_dist|heat_map|pvalues_vs_nes_plot|ranked_list_corr]*.png"), emit: gene_set_heatmap, optional: true
tuple val(meta), path("*_snapshot*.html") , emit: snapshot, optional: true
tuple val(meta), path("*enplot*.png") , emit: gene_set_enplot, optional: true
tuple val(meta), path("*gset_rnd_es_dist*.png") , emit: gene_set_dist, optional: true
tuple val(meta), path("*.zip") , emit: archive, optional: true
path "versions.yml" , emit: versions
tuple val(meta), path("*_snapshot*.html") , emit: snapshot, optional: true
tuple val(meta), path("*enplot*.png") , emit: gene_set_enplot, optional: true
tuple val(meta), path("*gset_rnd_es_dist*.png") , emit: gene_set_dist, optional: true
tuple val(meta), path("*.zip") , emit: archive, optional: true
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def VERSION = '4.3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

// Remove any trailing dots from prefix when passed as report label, so
// GSEA doesn't produce double-dotted top-level outputs
def rpt_label = prefix.replaceAll('\\.$', '')

def rpt_label = prefix.replaceAll('\\.$', '') // Remove any trailing dots from prefix when passed as report label, so GSEA doesn't produce double-dotted top-level outputs
def chip_command = chip ? "-chip $chip -collapse true" : ''
def VERSION = '4.3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.

"""
# Run GSEA

Expand Down Expand Up @@ -78,9 +75,34 @@ process GSEA_GSEA {
sed -i.bak "s/\$f/${prefix}\${f}/g" *.rpt *.html && rm *.bak
done

#Version command uses both conda and micromamba so that it works with both wave containers and conda environments
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gsea: $VERSION
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def VERSION = '4.3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
"""
touch ${prefix}.rpt
touch ${prefix}.index.html
touch ${prefix}.heat_map_corr_plot.html
touch ${prefix}.gsea_report_for_${reference}.tsv
touch ${prefix}.gsea_report_for_${reference}.html
touch ${prefix}.gsea_report_for_${target}.tsv
touch ${prefix}.gsea_report_for_${target}.html
touch ${prefix}.ranked_gene_list*.tsv
touch ${prefix}.gene_set_sizes.tsv
touch ${prefix}.global_es_histogram.png
touch ${prefix}.heat_map_1.png
touch ${prefix}.pvalues_vs_nes_plot.png
touch ${prefix}.ranked_list_corr_2.png

#Version command uses both conda and micromamba so that it works with both wave containers and conda environments
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gsea: $VERSION
"""
}
69 changes: 69 additions & 0 deletions modules/nf-core/gsea/gsea/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
nextflow_process {

name "Test Process GSEA_GSEA"
script "../main.nf"
process "GSEA_GSEA"
tag "modules"
tag "modules_nfcore"
tag "gsea_gsea"
tag "gsea"
tag "gsea/gsea"

test("test") {

when {
process {
"""
input[0] = [['id':'Condition_genotype_WT_KO', 'variable':'Condition genotype', 'reference':'WT', 'target':'KO', 'blocking':'batch'], file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_treatment_Control_Treated.gct", checkIfExists:true), file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_genotype_WT_KO.cls", checkIfExists:true), file("https://github.com/nf-core/test-datasets/raw/refs/heads/modules/data/genomics/mus_musculus/gene_set_analysis/mh.all.v2022.1.Mm.symbols.gmt", checkIfExists:true)]
input[1] = ['WT', 'KO']
input[2] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Mus_musculus.anno.feature_metadata.chip", checkIfExists:true)
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(
process.out.rpt.collect{ meta,rpt -> file(rpt).name }, //assert unstable file,
process.out.index_html.collect{ meta,index_html -> file(index_html).name }, //assert unstable file
process.out.heat_map_corr_plot,
process.out.report_tsvs_ref.collect{ meta,report_tsvs_ref -> file(report_tsvs_ref).name },
process.out.report_htmls_ref.collect{ meta,report_htmls_ref -> file(report_htmls_ref).name }, //assert unstable file
process.out.report_tsvs_target.collect{ meta,report_tsvs_target -> file(report_tsvs_target).name }, //assert unstable file
process.out.report_htmls_target.collect{ meta,report_htmls_target -> file(report_htmls_target).name }, //assert unstable file
process.out.ranked_gene_list.collect{ meta,ranked_gene_list -> file(ranked_gene_list).name }, //assert unstable file
process.out.gene_set_sizes,
process.out.histogram.collect{ meta,histogram -> file(histogram).name }, //assert unstable file
process.out.heatmap.collect{ meta,heatmap -> file(heatmap).name }, //assert unstable file
process.out.pvalues_vs_nes_plot.collect{ meta,pvalues_vs_nes_plot -> file(pvalues_vs_nes_plot).name }, //assert unstable file
process.out.ranked_list_corr.collect{ meta,ranked_list_corr -> file(ranked_list_corr).name }, //assert unstable file
process.out.versions
).match()
}
)
}
}

test("stub") {

options "-stub"

when {
process {
"""
input[0] = [['id':'Condition_genotype_WT_KO', 'variable':'Condition genotype', 'reference':'WT', 'target':'KO', 'blocking':'batch'], file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_treatment_Control_Treated.gct", checkIfExists:true), file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Condition_genotype_WT_KO.cls", checkIfExists:true), file("https://github.com/nf-core/test-datasets/raw/refs/heads/modules/data/genomics/mus_musculus/gene_set_analysis/mh.all.v2022.1.Mm.symbols.gmt", checkIfExists:true)]
input[1] = ['WT', 'KO']
input[2] = file("https://github.com/nf-core/test-datasets/raw/refs/heads/differentialabundance/modules_testdata/Mus_musculus.anno.feature_metadata.chip", checkIfExists:true)
"""
}
}

then {
assertAll (
{ assert process.success },
{ assert snapshot(process.out).match() },
)
}
}
}
Loading
Loading