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/makegrm/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
42 changes: 42 additions & 0 deletions modules/nf-core/gcta/makegrm/main.nf
Original file line number Diff line number Diff line change
@@ -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
"""
}
91 changes: 91 additions & 0 deletions modules/nf-core/gcta/makegrm/meta.yml
Original file line number Diff line number Diff line change
@@ -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"
142 changes: 142 additions & 0 deletions modules/nf-core/gcta/makegrm/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -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() }
)
}
}
}
111 changes: 111 additions & 0 deletions modules/nf-core/gcta/makegrm/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading
Loading