Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions modules/nf-core/gcta/addgrms/environment.yml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions modules/nf-core/gcta/addgrms/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
process GCTA_ADDGRMS {
tag "${meta.id}"
label 'process_medium'
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' :
'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' }"

input:
tuple val(meta), path(mgrm_file), path(grm_files)

output:
tuple val(meta), path("${meta.id}.grm.id"), path("${meta.id}.grm.bin"), path("${meta.id}.grm.N.bin"), emit: combined_grm
tuple val("${task.process}"), val("gcta"), eval("gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'"), emit: versions_gcta, topic: versions

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

script:
def args = task.ext.args ?: ''

"""
gcta \\
--mgrm ${mgrm_file} \\
--make-grm \\
--out ${meta.id} \\
--thread-num ${task.cpus} \\
${args}
"""

stub:
"""
touch ${meta.id}.grm.id
touch ${meta.id}.grm.bin
touch ${meta.id}.grm.N.bin
"""
}
81 changes: 81 additions & 0 deletions modules/nf-core/gcta/addgrms/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "gcta_addgrms"
description: Combine multiple GRMs listed in an MGRM manifest into a single dense GRM
keywords:
- gcta
- grm
- 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/"

input:
- - meta:
type: map
description: |
Groovy map containing combined GRM metadata
e.g. `[ id:'plink_simulated' ]`
- mgrm_file:
type: file
description: MGRM manifest listing the GRM prefixes to combine
pattern: "*.mgrm"
ontologies:
- edam: "http://edamontology.org/format_2330"
- grm_files:
type: file
description: GRM sidecar files referenced by `mgrm_file`
pattern: "*"
ontologies: []

output:
combined_grm:
- - meta:
type: map
description: |
Groovy map containing combined GRM metadata
e.g. `[ id:'plink_simulated' ]`
- "${meta.id}.grm.id":
type: file
description: Combined GRM sample identifier file
pattern: "${meta.id}.grm.id"
ontologies: []
- "${meta.id}.grm.bin":
type: file
description: Combined GRM binary matrix file
pattern: "${meta.id}.grm.bin"
ontologies: []
- "${meta.id}.grm.N.bin":
type: file
description: Combined GRM sample-count matrix file
pattern: "${meta.id}.grm.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 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'":
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 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//':
type: eval
description: The command used to retrieve the GCTA version

authors:
- "@andongni"
maintainers:
- "@andongni"
153 changes: 153 additions & 0 deletions modules/nf-core/gcta/addgrms/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
nextflow_process {

name "Test Process GCTA_ADDGRMS"
script "../main.nf"
process "GCTA_ADDGRMS"

tag "modules"
tag "modules_nfcore"
tag "gcta"
tag "gcta/addgrms"
tag "gcta/makegrmpart"
tag "gawk"

setup {
run("GAWK", alias: "GAWK_COMPLEMENT_VARIANTS") {
script "../../../gawk/main.nf"
process {
"""
input[0] = [
[ id:'plink_simulated_complement' ],
[
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_random_selected_snp.txt', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
]
]
input[1] = Channel.of('FNR == NR { keep[\$1] = 1; next } !(\$2 in keep) { print \$2 }').collectFile(name:'complement_variants.awk')
input[2] = false
"""
}
}

run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_LDMS1") {
script "../../makegrmpart/main.nf"
process {
"""
file('plink_simulated.mbfile').text = 'plink_simulated\\n'

input[0] = [
[ id:'plink_simulated_ldms1', part_gcta_job:1, nparts_gcta:1 ],
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)
]
]
input[1] = [
[ id:'plink_random_selected_snp' ],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_random_selected_snp.txt', checkIfExists: true)
]
"""
}
}

run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_LDMS2") {
script "../../makegrmpart/main.nf"
process {
"""
file('plink_simulated.mbfile').text = 'plink_simulated\\n'

input[0] = [
[ id:'plink_simulated_ldms2', part_gcta_job:1, nparts_gcta:1 ],
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)
]
]
input[1] = GAWK_COMPLEMENT_VARIANTS.out.output
"""
}
}
}

test("homo_sapiens popgen - merge dense GRMs from mgrm") {
config "./nextflow.config"

when {
process {
"""
mgrm_file = Channel
.of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1')
.collectFile(name:'plink_simulated_ldms.mgrm', newLine: true)

grm_files = GCTA_MAKEGRMPART_LDMS1.out.grm_files
.mix(GCTA_MAKEGRMPART_LDMS2.out.grm_files)
.map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
.collect()
.map { rows -> rows.flatten() }

input[0] = mgrm_file
.combine(grm_files)
.map { row -> [[ id:'plink_simulated_ldms' ], row[0], row[1..-1]] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.combined_grm.size() == 1 },
{ assert process.out.combined_grm.get(0).get(0).id == "plink_simulated_ldms" },
{
assert snapshot(
process.out.combined_grm,
process.out.findAll { key, val -> key.startsWith('versions') }
).match()
}
)
}
}

test("homo_sapiens popgen - merge dense GRMs from mgrm - stub") {
options "-stub"
config "./nextflow.config"

when {
process {
"""
mgrm_file = Channel
.of('plink_simulated_ldms1.part_1_1\\nplink_simulated_ldms2.part_1_1')
.collectFile(name:'plink_simulated_ldms.mgrm', newLine: true)

grm_files = GCTA_MAKEGRMPART_LDMS1.out.grm_files
.mix(GCTA_MAKEGRMPART_LDMS2.out.grm_files)
.map { meta, grm_id, grm_bin, grm_n_bin -> [grm_id, grm_bin, grm_n_bin] }
.collect()
.map { rows -> rows.flatten() }

input[0] = mgrm_file
.combine(grm_files)
.map { row -> [[ id:'plink_simulated_ldms' ], row[0], row[1..-1]] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
75 changes: 75 additions & 0 deletions modules/nf-core/gcta/addgrms/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"homo_sapiens popgen - merge dense GRMs from mgrm - stub": {
"content": [
{
"0": [
[
{
"id": "plink_simulated_ldms"
},
"plink_simulated_ldms.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
"plink_simulated_ldms.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
"plink_simulated_ldms.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
"GCTA_ADDGRMS",
"gcta",
"1.94.1"
]
],
"combined_grm": [
[
{
"id": "plink_simulated_ldms"
},
"plink_simulated_ldms.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
"plink_simulated_ldms.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
"plink_simulated_ldms.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions_gcta": [
[
"GCTA_ADDGRMS",
"gcta",
"1.94.1"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-13T14:16:18.17102219"
},
"homo_sapiens popgen - merge dense GRMs from mgrm": {
"content": [
[
[
{
"id": "plink_simulated_ldms"
},
"plink_simulated_ldms.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9",
"plink_simulated_ldms.grm.bin:md5,e6a56e44acd03f87043435c382fe0149",
"plink_simulated_ldms.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4"
]
],
{
"versions_gcta": [
[
"GCTA_ADDGRMS",
"gcta",
"1.94.1"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-13T15:38:05.74494821"
}
}
3 changes: 3 additions & 0 deletions modules/nf-core/gcta/addgrms/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -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/"
}
7 changes: 7 additions & 0 deletions modules/nf-core/gcta/adjustgrm/environment.yml
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading