diff --git a/modules/nf-core/gcta/makegrm/environment.yml b/modules/nf-core/gcta/makegrm/environment.yml new file mode 100644 index 00000000000..3e22ea7b9f2 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/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: + - bioconda::gcta=1.94.1 diff --git a/modules/nf-core/gcta/makegrm/main.nf b/modules/nf-core/gcta/makegrm/main.nf new file mode 100644 index 00000000000..0bb78639e36 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/main.nf @@ -0,0 +1,42 @@ +process GCTA_MAKEGRM { + tag "${meta.id}" + label 'process_medium' + conda "${moduleDir}/environment.yml" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/46/46b0d05f0daa47561d87d2a9cac5e51edc2c78e26f1bbab439c688386241a274/data' + : 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}" + + input: + tuple val(meta), path(mfile), path(bed_pgen), path(bim_pvar), path(fam_psam) + + output: + tuple val(meta), path("*.grm.*"), emit: grm_files + tuple val("${task.process}"), val("gcta"), eval("gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'"), emit: versions_gcta, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def extra_args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def genotype_files = bed_pgen instanceof List ? bed_pgen : [bed_pgen] + def genotype_extension = genotype_files[0].name.tokenize('.').last() + def multi_file_flag = genotype_extension == 'pgen' ? '--mpfile' : '--mbfile' + + """ + + gcta \\ + ${multi_file_flag} ${mfile} \\ + --make-grm \\ + --thread-num ${task.cpus} \\ + --out ${prefix} ${extra_args} + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.grm.id + touch ${prefix}.grm.bin + touch ${prefix}.grm.N.bin + """ +} diff --git a/modules/nf-core/gcta/makegrm/meta.yml b/modules/nf-core/gcta/makegrm/meta.yml new file mode 100644 index 00000000000..0c813dadada --- /dev/null +++ b/modules/nf-core/gcta/makegrm/meta.yml @@ -0,0 +1,91 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "gcta_makegrm" +description: Compute a whole dense GRM with GCTA +keywords: + - gcta + - genome-wide complex trait analysis + - grm + - genetic relationship matrix + - genetics +tools: + - "gcta": + description: "GCTA is a tool for genome-wide complex trait analysis." + homepage: "https://yanglab.westlake.edu.cn/software/gcta/" + documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf" + tool_dev_url: "https://github.com/jianyangqt/gcta" + licence: + - "GPL-3.0-only" + identifier: biotools:gcta + +input: + - - meta: + type: map + description: | + Groovy Map containing GRM sample metadata + e.g. `[ id:'gcta_grm' ]` + - mfile: + type: file + description: GCTA multi-input manifest consumed by `--mbfile` or + `--mpfile` + pattern: "*.{mbfile,mpfile,txt}" + ontologies: + - edam: "http://edamontology.org/format_2330" + - bed_pgen: + type: file + description: Collection of PLINK primary genotype files referenced by the + multi-input manifest + pattern: "*.{bed,pgen}" + ontologies: + - edam: "http://edamontology.org/format_3003" + - bim_pvar: + type: file + description: Collection of PLINK variant metadata files referenced by the + multi-input manifest + pattern: "*.{bim,pvar}" + ontologies: [] + - fam_psam: + type: file + description: Collection of PLINK sample metadata files referenced by the + multi-input manifest + pattern: "*.{fam,psam}" + ontologies: [] + +output: + grm_files: + - - meta: + type: map + description: | + Groovy Map containing GRM sample metadata + e.g. `[ id:'gcta_grm' ]` + - "*.grm.*": + type: file + description: Dense GRM sidecar files + pattern: "*.grm.{id,bin,N.bin}" + ontologies: [] + versions_gcta: + - - ${task.process}: + type: string + description: The process the version was collected from + - gcta: + type: string + description: The tool name + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": + type: eval + description: The command used to generate the version of the tool + +topics: + versions: + - - ${task.process}: + type: string + description: The process the versions were collected from + - gcta: + type: string + description: The tool name + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": + type: eval + description: The command used to generate the version of the tool + +authors: + - "@lyh970817" +maintainers: + - "@lyh970817" diff --git a/modules/nf-core/gcta/makegrm/tests/main.nf.test b/modules/nf-core/gcta/makegrm/tests/main.nf.test new file mode 100644 index 00000000000..e5c63233678 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/tests/main.nf.test @@ -0,0 +1,142 @@ +nextflow_process { + + name "Test Process GCTA_MAKEGRM" + script "../main.nf" + process "GCTA_MAKEGRM" + + tag "modules" + tag "modules_nfcore" + tag "gcta" + tag "gcta/makegrm" + + test("homo_sapiens popgen - plink2") { + when { + process { + """ + file('gcta_grm.mpfile').text = 'plink_simulated plink_simulated.pgen plink_simulated.psam plink_simulated.pvar\\n' + + input[0] = [ + [ id:'gcta_grm' ], + file('gcta_grm.mpfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.pgen', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.pvar', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.psam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.grm_files.size() == 1 }, + { assert process.out.grm_files.get(0).get(0).id == 'gcta_grm' }, + { assert process.out.grm_files.get(0).get(0).keySet() == ['id'] as Set }, + { assert process.out.grm_files.get(0).get(1).size() == 3 }, + { + assert process.out.grm_files.get(0).get(1).collect { file(it).name }.toSet() == [ + 'gcta_grm.grm.id', + 'gcta_grm.grm.bin', + 'gcta_grm.grm.N.bin' + ] as Set + }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--make-grm') }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--mpfile') }, + { + assert snapshot( + process.out.grm_files, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - plink1") { + when { + process { + """ + file('gcta_grm.mbfile').text = 'plink_simulated\\n' + + input[0] = [ + [ id:'gcta_grm_bed' ], + file('gcta_grm.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.grm_files.size() == 1 }, + { assert process.out.grm_files.get(0).get(0).id == 'gcta_grm_bed' }, + { assert process.out.grm_files.get(0).get(0).keySet() == ['id'] as Set }, + { assert process.out.grm_files.get(0).get(1).size() == 3 }, + { + assert process.out.grm_files.get(0).get(1).collect { file(it).name }.toSet() == [ + 'gcta_grm_bed.grm.id', + 'gcta_grm_bed.grm.bin', + 'gcta_grm_bed.grm.N.bin' + ] as Set + }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--make-grm') }, + { assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--mbfile') }, + { + assert snapshot( + process.out.grm_files, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - plink1 - stub") { + options "-stub" + + when { + process { + """ + file('gcta_grm.mbfile').text = 'plink_simulated\\n' + + input[0] = [ + [ id:'gcta_grm_bed' ], + file('gcta_grm.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-core/gcta/makegrm/tests/main.nf.test.snap b/modules/nf-core/gcta/makegrm/tests/main.nf.test.snap new file mode 100644 index 00000000000..f8fbe133d5a --- /dev/null +++ b/modules/nf-core/gcta/makegrm/tests/main.nf.test.snap @@ -0,0 +1,111 @@ +{ + "homo_sapiens popgen - plink2": { + "content": [ + [ + [ + { + "id": "gcta_grm" + }, + [ + "gcta_grm.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4", + "gcta_grm.grm.bin:md5,45f8dff14bda17d50009a21050572228", + "gcta_grm.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9" + ] + ] + ], + { + "versions_gcta": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-15T21:08:43.209734458" + }, + "homo_sapiens popgen - plink1": { + "content": [ + [ + [ + { + "id": "gcta_grm_bed" + }, + [ + "gcta_grm_bed.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4", + "gcta_grm_bed.grm.bin:md5,45f8dff14bda17d50009a21050572228", + "gcta_grm_bed.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9" + ] + ] + ], + { + "versions_gcta": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-15T21:09:34.058651287" + }, + "homo_sapiens popgen - plink1 - stub": { + "content": [ + { + "0": [ + [ + { + "id": "gcta_grm_bed" + }, + [ + "gcta_grm_bed.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "1": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ], + "grm_files": [ + [ + { + "id": "gcta_grm_bed" + }, + [ + "gcta_grm_bed.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e", + "gcta_grm_bed.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ] + ], + "versions_gcta": [ + [ + "GCTA_MAKEGRM", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-15T21:10:21.024687128" + } +} \ No newline at end of file diff --git a/modules/nf-core/gcta/makegrm/tests/nextflow.config b/modules/nf-core/gcta/makegrm/tests/nextflow.config new file mode 100644 index 00000000000..de31e021882 --- /dev/null +++ b/modules/nf-core/gcta/makegrm/tests/nextflow.config @@ -0,0 +1,3 @@ +params { + modules_testdata_base_path = System.getenv("NF_MODULES_TESTDATA_BASE_PATH") ?: "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/" +} diff --git a/modules/nf-core/gcta/reml/environment.yml b/modules/nf-core/gcta/reml/environment.yml new file mode 100644 index 00000000000..3e22ea7b9f2 --- /dev/null +++ b/modules/nf-core/gcta/reml/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: + - bioconda::gcta=1.94.1 diff --git a/modules/nf-core/gcta/reml/main.nf b/modules/nf-core/gcta/reml/main.nf new file mode 100644 index 00000000000..02a7769453e --- /dev/null +++ b/modules/nf-core/gcta/reml/main.nf @@ -0,0 +1,52 @@ +process GCTA_REML { + tag "gcta_reml_${meta.id}_${meta2.id}" + label 'process_medium' + + conda "${moduleDir}/environment.yml" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/46/46b0d05f0daa47561d87d2a9cac5e51edc2c78e26f1bbab439c688386241a274/data' + : 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}" + + input: + tuple val(meta), path(phenotypes_file), val(mpheno), val(prevalence) + tuple val(meta2), path(grm_files) + tuple val(meta3), path(quant_covariates_file) + tuple val(meta4), path(cat_covariates_file) + + output: + tuple val(meta), path("*.hsq"), emit: reml_results + tuple val("${task.process}"), val("gcta"), eval("gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'"), emit: versions_gcta, topic: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + def mpheno_value = mpheno ?: 1 + def mpheno_param = "--mpheno ${mpheno_value}" + def prevalence_param = prevalence ? "--prevalence ${prevalence}" : '' + def qcovar_param = quant_covariates_file ? "--qcovar ${quant_covariates_file}" : '' + def covar_param = cat_covariates_file ? "--covar ${cat_covariates_file}" : '' + def extra_args = task.ext.args ?: '' + + """ + set -euo pipefail + + gcta \\ + --reml \\ + --grm ${meta2.id} \\ + --pheno ${phenotypes_file} \\ + ${mpheno_param} \\ + ${prevalence_param} \\ + ${qcovar_param} \\ + ${covar_param} \\ + --out "${prefix}" \\ + --thread-num ${task.cpus} ${extra_args} + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch "${prefix}.hsq" + """ +} diff --git a/modules/nf-core/gcta/reml/meta.yml b/modules/nf-core/gcta/reml/meta.yml new file mode 100644 index 00000000000..2d3f0e0e980 --- /dev/null +++ b/modules/nf-core/gcta/reml/meta.yml @@ -0,0 +1,113 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "gcta_reml" +description: Run univariate REML heritability estimation with a dense GRM +keywords: + - gcta + - genome-wide complex trait analysis + - reml + - restricted maximum likelihood + - grm + - genetic relationship matrix + - genetics +tools: + - "gcta": + description: "Genome-wide Complex Trait Analysis (GCTA) estimates genetic relationships, variance components, and association statistics from genome-wide data." + homepage: "https://yanglab.westlake.edu.cn/software/gcta/" + documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf" + tool_dev_url: "https://yanglab.westlake.edu.cn/software/gcta/" + licence: ["GPL-3.0-only"] + identifier: "biotools:gcta" +input: + - - meta: + type: map + description: | + Groovy map containing phenotype metadata + e.g. `[ id:'QuantitativeTrait' ]` + - phenotypes_file: + type: file + description: Phenotype file passed to `--pheno` + pattern: "*.{phe,pheno,txt,tsv}" + ontologies: + - edam: "http://edamontology.org/format_3475" + - mpheno: + type: integer + description: | + Phenotype column selector passed to `--mpheno`. + Pass `[]` or `null` to use the default first phenotype column + (`--mpheno 1`). + - prevalence: + type: float + description: | + Population prevalence passed to `--prevalence` for case-control traits. + Pass `[]` or `null` for quantitative traits. + - - meta2: + type: map + description: | + Groovy map containing dense GRM metadata + e.g. `[ id:'plink_simulated' ]` + - grm_files: + type: file + description: Dense GRM bundle containing sample identifier, binary matrix, + and sample-count matrix files + pattern: "*.grm.*" + ontologies: [] + - - meta3: + type: map + description: | + Groovy map containing quantitative covariate metadata + e.g. `[ id:'covariates_quant' ]` + - quant_covariates_file: + type: file + description: Quantitative covariates file, pass `[]` when absent + pattern: "*.{covar,cov,txt,tsv}" + ontologies: + - edam: "http://edamontology.org/format_3475" + - - meta4: + type: map + description: | + Groovy map containing categorical covariate metadata + e.g. `[ id:'covariates_cat' ]` + - cat_covariates_file: + type: file + description: Categorical covariates file, pass `[]` when absent + pattern: "*.{covar,cov,txt,tsv}" + ontologies: + - edam: "http://edamontology.org/format_3475" +output: + reml_results: + - - meta: + type: map + description: | + Groovy map containing phenotype metadata + e.g. `[ id:'QuantitativeTrait' ]` + - "*.hsq": + type: file + description: REML result file + pattern: "*.{hsq}" + ontologies: + - edam: "http://edamontology.org/format_2330" + versions_gcta: + - - "${task.process}": + type: string + description: The process the version was collected from + - "gcta": + type: string + description: The tool name + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": + type: eval + description: The command used to retrieve the GCTA version +topics: + versions: + - - ${task.process}: + type: string + description: The process the version was collected from + - gcta: + type: string + description: The tool name + - "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'": + type: eval + description: The command used to retrieve the GCTA version +authors: + - "@lyh970817" +maintainers: + - "@lyh970817" diff --git a/modules/nf-core/gcta/reml/tests/main.nf.test b/modules/nf-core/gcta/reml/tests/main.nf.test new file mode 100644 index 00000000000..ce2730ab94e --- /dev/null +++ b/modules/nf-core/gcta/reml/tests/main.nf.test @@ -0,0 +1,299 @@ +nextflow_process { + + name "Test Process GCTA_REML" + script "../main.nf" + process "GCTA_REML" + + tag "modules" + tag "modules_nfcore" + tag "gcta" + tag "gcta/reml" + tag "gcta/makegrm" + tag "gawk" + + setup { + run("GAWK", alias: "GAWK_QUANTITATIVE_PHENOTYPE") { + script "../../../gawk/main.nf" + process { + """ + input[0] = [ + [ id:'QuantitativeTrait' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated_quantitative_phenoname.phe', checkIfExists: true) + ] + input[1] = Channel.of('{ print \$1, \$2, \$3 }').collectFile(name:'quantitative_phenotypes.awk') + input[2] = false + """ + } + } + + run("GAWK", alias: "GAWK_MULTI_PHENOTYPES") { + script "../../../gawk/main.nf" + process { + """ + input[0] = [ + [ id:'QuantitativeTraitMpheno' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated_quantitative_phenoname.phe', checkIfExists: true) + ] + input[1] = Channel.of('{ print \$1, \$2, \$3, (\$3 * 0.5) + ((NR % 7) / 10.0) }').collectFile(name:'multi_phenotypes.awk') + input[2] = false + """ + } + } + + run("GAWK", alias: "GAWK_BINARY_PHENOTYPE") { + script "../../../gawk/main.nf" + process { + """ + input[0] = [ + [ id:'BinaryTrait' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated_binary_phenoname.phe', checkIfExists: true) + ] + input[1] = Channel.of('FNR == 1 { next } { print \$1, \$2, \$3 + 1 }').collectFile(name:'binary_phenotypes.awk') + input[2] = false + """ + } + } + + run("GAWK", alias: "GAWK_QUANTITATIVE_COVARIATES") { + script "../../../gawk/main.nf" + process { + """ + input[0] = [ + [ id:'covariates_quant' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated_covariates.txt', checkIfExists: true) + ] + input[1] = Channel.of('FNR == 1 { next } { print \$1, \$2, \$4, \$5 }').collectFile(name:'quantitative_covariates.awk') + input[2] = false + """ + } + } + + run("GAWK", alias: "GAWK_CATEGORICAL_COVARIATES") { + script "../../../gawk/main.nf" + process { + """ + input[0] = [ + [ id:'covariates_cat' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated_covariates.txt', checkIfExists: true) + ] + input[1] = Channel.of('FNR == 1 { next } { print \$1, \$2, \$3 }').collectFile(name:'categorical_covariates.awk') + input[2] = false + """ + } + } + + run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_DENSE") { + script "../../makegrm/main.nf" + process { + """ + file('plink_simulated.mbfile').text = 'plink_simulated\\n' + + input[0] = [ + [ id:'plink_simulated_dense' ], + file('plink_simulated.mbfile'), + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true) + ], + [ + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true) + ] + ] + """ + } + } + } + + test("homo_sapiens popgen - dense GRM with mpheno selection") { + config "./nextflow.config" + when { + process { + """ + input[0] = GAWK_MULTI_PHENOTYPES.out.output.map { meta, pheno -> [[ id:'QuantitativeTraitMpheno2' ], pheno, 2, []] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = GAWK_QUANTITATIVE_COVARIATES.out.output + input[3] = GAWK_CATEGORICAL_COVARIATES.out.output + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.reml_results.size() == 1 }, + { assert process.out.reml_results.get(0).get(0).id == "QuantitativeTraitMpheno2" }, + { + assert snapshot( + process.out.reml_results, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - quantitative phenotype with dense GRM and covariates") { + config "./nextflow.config" + when { + process { + """ + input[0] = GAWK_QUANTITATIVE_PHENOTYPE.out.output.map { meta, pheno -> [meta, pheno, 1, []] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = GAWK_QUANTITATIVE_COVARIATES.out.output + input[3] = GAWK_CATEGORICAL_COVARIATES.out.output + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.reml_results.size() == 1 }, + { assert process.out.reml_results.get(0).get(0).id == "QuantitativeTrait" }, + { + assert snapshot( + process.out.reml_results, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - quantitative phenotype with dense GRM and no covariates") { + config "./nextflow.config" + when { + process { + """ + input[0] = GAWK_QUANTITATIVE_PHENOTYPE.out.output.map { meta, pheno -> [meta, pheno, 1, null] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = [[ id:'covariates_quant' ], []] + input[3] = [[ id:'covariates_cat' ], []] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.reml_results.size() == 1 }, + { assert process.out.reml_results.get(0).get(0).id == "QuantitativeTrait" }, + { + assert snapshot( + process.out.reml_results, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - binary phenotype with dense GRM and prevalence") { + config "./nextflow.config" + when { + process { + """ + input[0] = GAWK_BINARY_PHENOTYPE.out.output.map { meta, pheno -> [[ id:'BinaryTraitPrevalence' ], pheno, 1, 0.1] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = [[ id:'covariates_quant' ], []] + input[3] = [[ id:'covariates_cat' ], []] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.reml_results.size() == 1 }, + { assert process.out.reml_results.get(0).get(0).id == "BinaryTraitPrevalence" }, + { + assert snapshot( + process.out.reml_results, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - dense GRM mpheno defaults to first phenotype when empty") { + config "./nextflow.config" + when { + process { + """ + input[0] = GAWK_MULTI_PHENOTYPES.out.output.map { meta, pheno -> [[ id:'QuantitativeTraitMphenoDefault' ], pheno, [], []] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = GAWK_QUANTITATIVE_COVARIATES.out.output + input[3] = GAWK_CATEGORICAL_COVARIATES.out.output + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.reml_results.size() == 1 }, + { assert process.out.reml_results.get(0).get(0).id == "QuantitativeTraitMphenoDefault" }, + { + assert snapshot( + process.out.reml_results, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } + + test("homo_sapiens popgen - fails when mpheno index is out of range") { + config "./nextflow.config" + when { + process { + """ + input[0] = GAWK_MULTI_PHENOTYPES.out.output.map { meta, pheno -> [[ id:'QuantitativeTraitInvalidMpheno' ], pheno, 3, []] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = GAWK_QUANTITATIVE_COVARIATES.out.output + input[3] = GAWK_CATEGORICAL_COVARIATES.out.output + """ + } + } + + then { + assertAll( + { assert !process.success }, + { assert process.exitStatus != 0 } + ) + } + } + + test("homo_sapiens popgen - quantitative phenotype with dense GRM - stub") { + options "-stub" + config "./nextflow.config" + + when { + process { + """ + input[0] = GAWK_QUANTITATIVE_PHENOTYPE.out.output.map { meta, pheno -> [meta, pheno, 1, []] } + input[1] = GCTA_MAKEGRM_DENSE.out.grm_files + input[2] = [[ id:'covariates_quant' ], []] + input[3] = [[ id:'covariates_cat' ], []] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert process.out.reml_results.size() == 1 }, + { assert process.out.reml_results.get(0).get(0).id == "QuantitativeTrait" }, + { + assert snapshot( + process.out.reml_results, + process.out.findAll { key, val -> key.startsWith('versions') } + ).match() + } + ) + } + } +} diff --git a/modules/nf-core/gcta/reml/tests/main.nf.test.snap b/modules/nf-core/gcta/reml/tests/main.nf.test.snap new file mode 100644 index 00000000000..78669adf1c8 --- /dev/null +++ b/modules/nf-core/gcta/reml/tests/main.nf.test.snap @@ -0,0 +1,158 @@ +{ + "homo_sapiens popgen - quantitative phenotype with dense GRM - stub": { + "content": [ + [ + [ + { + "id": "QuantitativeTrait" + }, + "QuantitativeTrait.hsq:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REML", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-21T00:39:12.308775079" + }, + "homo_sapiens popgen - dense GRM mpheno defaults to first phenotype when empty": { + "content": [ + [ + [ + { + "id": "QuantitativeTraitMphenoDefault" + }, + "QuantitativeTraitMphenoDefault.hsq:md5,17d5e79e461b582b0aaba2a40666c8f7" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REML", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-21T18:45:48.891436292" + }, + "homo_sapiens popgen - quantitative phenotype with dense GRM and no covariates": { + "content": [ + [ + [ + { + "id": "QuantitativeTrait" + }, + "QuantitativeTrait.hsq:md5,51c1328c8feb6d53f3984cd58324fed7" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REML", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-21T18:45:38.965175332" + }, + "homo_sapiens popgen - quantitative phenotype with dense GRM and covariates": { + "content": [ + [ + [ + { + "id": "QuantitativeTrait" + }, + "QuantitativeTrait.hsq:md5,17d5e79e461b582b0aaba2a40666c8f7" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REML", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-21T18:45:28.626250983" + }, + "homo_sapiens popgen - dense GRM with mpheno selection": { + "content": [ + [ + [ + { + "id": "QuantitativeTraitMpheno2" + }, + "QuantitativeTraitMpheno2.hsq:md5,0a29048e72305f462889481b2dfb94db" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REML", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-03-21T18:45:19.433138352" + }, + "homo_sapiens popgen - binary phenotype with dense GRM and prevalence": { + "content": [ + [ + [ + { + "id": "BinaryTraitPrevalence" + }, + "BinaryTraitPrevalence.hsq:md5,86672f6a0b3c49b2347d402cb03b8606" + ] + ], + { + "versions_gcta": [ + [ + "GCTA_REML", + "gcta", + "1.94.1" + ] + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.4" + }, + "timestamp": "2026-05-13T16:08:12.836619238" + } +} \ No newline at end of file diff --git a/modules/nf-core/gcta/reml/tests/nextflow.config b/modules/nf-core/gcta/reml/tests/nextflow.config new file mode 100644 index 00000000000..de31e021882 --- /dev/null +++ b/modules/nf-core/gcta/reml/tests/nextflow.config @@ -0,0 +1,3 @@ +params { + modules_testdata_base_path = System.getenv("NF_MODULES_TESTDATA_BASE_PATH") ?: "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/" +}