Skip to content

Commit f34f12c

Browse files
committed
Add gcta/removerelatedsubjects module
1 parent 4b801f9 commit f34f12c

11 files changed

Lines changed: 779 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
3+
channels:
4+
- conda-forge
5+
- bioconda
6+
dependencies:
7+
- bioconda::gcta=1.94.1
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
process GCTA_MAKEGRM {
2+
tag "${meta.id}"
3+
label 'process_medium'
4+
conda "${moduleDir}/environment.yml"
5+
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
6+
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/46/46b0d05f0daa47561d87d2a9cac5e51edc2c78e26f1bbab439c688386241a274/data'
7+
: 'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9'}"
8+
9+
input:
10+
tuple val(meta), path(mfile), path(bed_pgen), path(bim_pvar), path(fam_psam)
11+
12+
output:
13+
tuple val(meta), path("*.grm.*"), emit: grm_files
14+
tuple val("${task.process}"), val("gcta"), eval("gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'"), emit: versions_gcta, topic: versions
15+
16+
when:
17+
task.ext.when == null || task.ext.when
18+
19+
script:
20+
def args = task.ext.args ?: ''
21+
def prefix = task.ext.prefix ?: "${meta.id}"
22+
def genotype_files = bed_pgen instanceof List ? bed_pgen : [bed_pgen]
23+
def genotype_extension = genotype_files[0].name.tokenize('.').last()
24+
def multi_file_flag = genotype_extension == 'pgen' ? '--mpfile' : '--mbfile'
25+
"""
26+
gcta \\
27+
${multi_file_flag} ${mfile} \\
28+
--make-grm \\
29+
--thread-num ${task.cpus} \\
30+
--out ${prefix} \\
31+
${args}
32+
"""
33+
34+
stub:
35+
def prefix = task.ext.prefix ?: "${meta.id}"
36+
"""
37+
touch ${prefix}.grm.id
38+
touch ${prefix}.grm.bin
39+
touch ${prefix}.grm.N.bin
40+
"""
41+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
2+
name: "gcta_makegrm"
3+
description: Compute a whole dense GRM with GCTA
4+
keywords:
5+
- gcta
6+
- genome-wide complex trait analysis
7+
- grm
8+
- genetic relationship matrix
9+
- genetics
10+
tools:
11+
- "gcta":
12+
description: "GCTA is a tool for genome-wide complex trait analysis."
13+
homepage: "https://yanglab.westlake.edu.cn/software/gcta/"
14+
documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf"
15+
tool_dev_url: "https://github.com/jianyangqt/gcta"
16+
licence:
17+
- "GPL-3.0-only"
18+
identifier: biotools:gcta
19+
20+
input:
21+
- - meta:
22+
type: map
23+
description: |
24+
Groovy Map containing GRM sample metadata
25+
e.g. `[ id:'gcta_grm' ]`
26+
- mfile:
27+
type: file
28+
description: GCTA multi-input manifest consumed by `--mbfile` or
29+
`--mpfile`
30+
pattern: "*.{mbfile,mpfile,txt}"
31+
ontologies:
32+
- edam: "http://edamontology.org/format_2330"
33+
- bed_pgen:
34+
type: file
35+
description: Collection of PLINK primary genotype files referenced by the
36+
multi-input manifest
37+
pattern: "*.{bed,pgen}"
38+
ontologies:
39+
- edam: "http://edamontology.org/format_3003"
40+
- bim_pvar:
41+
type: file
42+
description: Collection of PLINK variant metadata files referenced by the
43+
multi-input manifest
44+
pattern: "*.{bim,pvar}"
45+
ontologies: []
46+
- fam_psam:
47+
type: file
48+
description: Collection of PLINK sample metadata files referenced by the
49+
multi-input manifest
50+
pattern: "*.{fam,psam}"
51+
ontologies: []
52+
53+
output:
54+
grm_files:
55+
- - meta:
56+
type: map
57+
description: |
58+
Groovy Map containing GRM sample metadata
59+
e.g. `[ id:'gcta_grm' ]`
60+
- "*.grm.*":
61+
type: file
62+
description: Dense GRM sidecar files
63+
pattern: "*.grm.{id,bin,N.bin}"
64+
ontologies: []
65+
versions_gcta:
66+
- - ${task.process}:
67+
type: string
68+
description: The process the version was collected from
69+
- gcta:
70+
type: string
71+
description: The tool name
72+
- "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'":
73+
type: eval
74+
description: The command used to generate the version of the tool
75+
76+
topics:
77+
versions:
78+
- - ${task.process}:
79+
type: string
80+
description: The process the versions were collected from
81+
- gcta:
82+
type: string
83+
description: The tool name
84+
- "gcta --version | sed -En 's/^[*] version v([0-9.]*).*/\\1/p'":
85+
type: eval
86+
description: The command used to generate the version of the tool
87+
88+
authors:
89+
- "@lyh970817"
90+
maintainers:
91+
- "@lyh970817"
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
nextflow_process {
2+
3+
name "Test Process GCTA_MAKEGRM"
4+
script "../main.nf"
5+
process "GCTA_MAKEGRM"
6+
7+
tag "modules"
8+
tag "modules_nfcore"
9+
tag "gcta"
10+
tag "gcta/makegrm"
11+
12+
test("homo_sapiens popgen - plink2") {
13+
when {
14+
process {
15+
"""
16+
file('gcta_grm.mpfile').text = 'plink_simulated plink_simulated.pgen plink_simulated.psam plink_simulated.pvar\\n'
17+
18+
input[0] = [
19+
[ id:'gcta_grm' ],
20+
file('gcta_grm.mpfile'),
21+
[
22+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.pgen', checkIfExists: true)
23+
],
24+
[
25+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.pvar', checkIfExists: true)
26+
],
27+
[
28+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.psam', checkIfExists: true)
29+
]
30+
]
31+
"""
32+
}
33+
}
34+
35+
then {
36+
assertAll(
37+
{ assert process.success },
38+
{ assert process.out.grm_files.size() == 1 },
39+
{ assert process.out.grm_files.get(0).get(0).id == 'gcta_grm' },
40+
{ assert process.out.grm_files.get(0).get(0).keySet() == ['id'] as Set },
41+
{ assert process.out.grm_files.get(0).get(1).size() == 3 },
42+
{
43+
assert process.out.grm_files.get(0).get(1).collect { file(it).name }.toSet() == [
44+
'gcta_grm.grm.id',
45+
'gcta_grm.grm.bin',
46+
'gcta_grm.grm.N.bin'
47+
] as Set
48+
},
49+
{ assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--make-grm') },
50+
{ assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--mpfile') },
51+
{
52+
assert snapshot(
53+
process.out.grm_files,
54+
process.out.findAll { key, val -> key.startsWith('versions') }
55+
).match()
56+
}
57+
)
58+
}
59+
}
60+
61+
test("homo_sapiens popgen - plink1") {
62+
when {
63+
process {
64+
"""
65+
file('gcta_grm.mbfile').text = 'plink_simulated\\n'
66+
67+
input[0] = [
68+
[ id:'gcta_grm_bed' ],
69+
file('gcta_grm.mbfile'),
70+
[
71+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
72+
],
73+
[
74+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
75+
],
76+
[
77+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
78+
]
79+
]
80+
"""
81+
}
82+
}
83+
84+
then {
85+
assertAll(
86+
{ assert process.success },
87+
{ assert process.out.grm_files.size() == 1 },
88+
{ assert process.out.grm_files.get(0).get(0).id == 'gcta_grm_bed' },
89+
{ assert process.out.grm_files.get(0).get(0).keySet() == ['id'] as Set },
90+
{ assert process.out.grm_files.get(0).get(1).size() == 3 },
91+
{
92+
assert process.out.grm_files.get(0).get(1).collect { file(it).name }.toSet() == [
93+
'gcta_grm_bed.grm.id',
94+
'gcta_grm_bed.grm.bin',
95+
'gcta_grm_bed.grm.N.bin'
96+
] as Set
97+
},
98+
{ assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--make-grm') },
99+
{ assert file(path(process.out.grm_files.get(0).get(1)[0]).parent.toString() + '/.command.sh').text.contains('--mbfile') },
100+
{
101+
assert snapshot(
102+
process.out.grm_files,
103+
process.out.findAll { key, val -> key.startsWith('versions') }
104+
).match()
105+
}
106+
)
107+
}
108+
}
109+
110+
test("homo_sapiens popgen - plink1 - stub") {
111+
options "-stub"
112+
113+
when {
114+
process {
115+
"""
116+
file('gcta_grm.mbfile').text = 'plink_simulated\\n'
117+
118+
input[0] = [
119+
[ id:'gcta_grm_bed' ],
120+
file('gcta_grm.mbfile'),
121+
[
122+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
123+
],
124+
[
125+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
126+
],
127+
[
128+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
129+
]
130+
]
131+
"""
132+
}
133+
}
134+
135+
then {
136+
assertAll(
137+
{ assert process.success },
138+
{ assert snapshot(process.out).match() }
139+
)
140+
}
141+
}
142+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"homo_sapiens popgen - plink2": {
3+
"content": [
4+
[
5+
[
6+
{
7+
"id": "gcta_grm"
8+
},
9+
[
10+
"gcta_grm.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4",
11+
"gcta_grm.grm.bin:md5,45f8dff14bda17d50009a21050572228",
12+
"gcta_grm.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9"
13+
]
14+
]
15+
],
16+
{
17+
"versions_gcta": [
18+
[
19+
"GCTA_MAKEGRM",
20+
"gcta",
21+
"1.94.1"
22+
]
23+
]
24+
}
25+
],
26+
"meta": {
27+
"nf-test": "0.9.3",
28+
"nextflow": "25.10.4"
29+
},
30+
"timestamp": "2026-05-15T21:08:43.209734458"
31+
},
32+
"homo_sapiens popgen - plink1": {
33+
"content": [
34+
[
35+
[
36+
{
37+
"id": "gcta_grm_bed"
38+
},
39+
[
40+
"gcta_grm_bed.grm.N.bin:md5,acaa43bbbf2253d392537a178ecf09a4",
41+
"gcta_grm_bed.grm.bin:md5,45f8dff14bda17d50009a21050572228",
42+
"gcta_grm_bed.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9"
43+
]
44+
]
45+
],
46+
{
47+
"versions_gcta": [
48+
[
49+
"GCTA_MAKEGRM",
50+
"gcta",
51+
"1.94.1"
52+
]
53+
]
54+
}
55+
],
56+
"meta": {
57+
"nf-test": "0.9.3",
58+
"nextflow": "25.10.4"
59+
},
60+
"timestamp": "2026-05-15T21:09:34.058651287"
61+
},
62+
"homo_sapiens popgen - plink1 - stub": {
63+
"content": [
64+
{
65+
"0": [
66+
[
67+
{
68+
"id": "gcta_grm_bed"
69+
},
70+
[
71+
"gcta_grm_bed.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
72+
"gcta_grm_bed.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
73+
"gcta_grm_bed.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e"
74+
]
75+
]
76+
],
77+
"1": [
78+
[
79+
"GCTA_MAKEGRM",
80+
"gcta",
81+
"1.94.1"
82+
]
83+
],
84+
"grm_files": [
85+
[
86+
{
87+
"id": "gcta_grm_bed"
88+
},
89+
[
90+
"gcta_grm_bed.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
91+
"gcta_grm_bed.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
92+
"gcta_grm_bed.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e"
93+
]
94+
]
95+
],
96+
"versions_gcta": [
97+
[
98+
"GCTA_MAKEGRM",
99+
"gcta",
100+
"1.94.1"
101+
]
102+
]
103+
}
104+
],
105+
"meta": {
106+
"nf-test": "0.9.3",
107+
"nextflow": "25.10.4"
108+
},
109+
"timestamp": "2026-05-15T21:10:21.024687128"
110+
}
111+
}

0 commit comments

Comments
 (0)