Skip to content

Commit 99724b4

Browse files
committed
feat: add gcta/makebksparse module
1 parent 8f3907c commit 99724b4

6 files changed

Lines changed: 301 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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
process GCTA_MAKEBKSPARSE {
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+
'docker://community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' :
7+
'community.wave.seqera.io/library/gcta:1.94.1--9bc35dc424fcf6e9' }"
8+
9+
input:
10+
tuple val(meta), path(grm_id), path(grm_bin), path(grm_n_bin)
11+
val(cutoff)
12+
13+
output:
14+
tuple val(meta), path("*_sp.grm.id"), path("*_sp.grm.sp"), emit: sparse_grm_files
15+
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
16+
17+
when:
18+
task.ext.when == null || task.ext.when
19+
20+
script:
21+
def args = task.ext.args ?: ''
22+
def prefix = task.ext.prefix ?: "${meta.id}"
23+
24+
"""
25+
gcta \\
26+
--grm ${meta.id} \\
27+
--make-bK-sparse ${cutoff} \\
28+
--out ${prefix}_sp \\
29+
--thread-num ${task.cpus} \\
30+
${args}
31+
"""
32+
33+
stub:
34+
def prefix = task.ext.prefix ?: "${meta.id}"
35+
"""
36+
touch ${prefix}_sp.grm.id
37+
touch ${prefix}_sp.grm.sp
38+
"""
39+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
2+
name: "gcta_makebksparse"
3+
description: Create a sparse GRM from a dense GRM for downstream fastGWA analyses
4+
keywords:
5+
- gcta
6+
- grm
7+
- sparse
8+
- genetics
9+
tools:
10+
- "gcta":
11+
description: "Genome-wide Complex Trait Analysis (GCTA) estimates genetic relationships, variance components, and association statistics from genome-wide data."
12+
homepage: "https://yanglab.westlake.edu.cn/software/gcta/"
13+
documentation: "https://yanglab.westlake.edu.cn/software/gcta/static/gcta_doc_latest.pdf"
14+
tool_dev_url: "https://yanglab.westlake.edu.cn/software/gcta/"
15+
16+
input:
17+
- - meta:
18+
type: map
19+
description: |
20+
Groovy map containing dense GRM metadata
21+
e.g. `[ id:'plink_simulated' ]`
22+
- grm_id:
23+
type: file
24+
description: Dense GRM sample identifier file
25+
pattern: "*.grm.id"
26+
ontologies: []
27+
- grm_bin:
28+
type: file
29+
description: Dense GRM binary matrix file
30+
pattern: "*.grm.bin"
31+
ontologies: []
32+
- grm_n_bin:
33+
type: file
34+
description: Dense GRM sample-count matrix file
35+
pattern: "*.grm.N.bin"
36+
ontologies: []
37+
- cutoff:
38+
type: float
39+
description: Sparse GRM cutoff passed to `--make-bK-sparse`
40+
41+
output:
42+
sparse_grm_files:
43+
- - meta:
44+
type: map
45+
description: |
46+
Groovy map containing dense GRM metadata
47+
e.g. `[ id:'plink_simulated' ]`
48+
- "*_sp.grm.id":
49+
type: file
50+
description: Sparse GRM sample identifier file
51+
pattern: "*_sp.grm.id"
52+
ontologies: []
53+
- "*_sp.grm.sp":
54+
type: file
55+
description: Sparse GRM matrix file
56+
pattern: "*_sp.grm.sp"
57+
ontologies: []
58+
versions_gcta:
59+
- - "${task.process}":
60+
type: string
61+
description: The process the version was collected from
62+
- "gcta":
63+
type: string
64+
description: The tool name
65+
- "gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//'":
66+
type: eval
67+
description: The command used to retrieve the GCTA version
68+
69+
topics:
70+
versions:
71+
- - ${task.process}:
72+
type: string
73+
description: The process the version was collected from
74+
- gcta:
75+
type: string
76+
description: The tool name
77+
- gcta --version 2>&1 | grep 'version v' | tr -s ' ' | cut -d' ' -f3 | sed 's/^v//':
78+
type: eval
79+
description: The command used to retrieve the GCTA version
80+
81+
authors:
82+
- "@andongni"
83+
maintainers:
84+
- "@andongni"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
nextflow_process {
2+
3+
name "Test Process GCTA_MAKEBKSPARSE"
4+
script "../main.nf"
5+
process "GCTA_MAKEBKSPARSE"
6+
7+
tag "modules"
8+
tag "modules_nfcore"
9+
tag "gcta"
10+
tag "gcta/makebksparse"
11+
tag "gcta/makegrmpart"
12+
13+
setup {
14+
run("GCTA_MAKEGRMPART", alias: "GCTA_MAKEGRMPART_DENSE") {
15+
script "../../makegrmpart/main.nf"
16+
process {
17+
"""
18+
file('plink_simulated.mbfile').text = 'plink_simulated\\n'
19+
20+
input[0] = [
21+
[ id:'plink_simulated_dense', part_gcta_job:1, nparts_gcta:1 ],
22+
file('plink_simulated.mbfile'),
23+
[
24+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bed', checkIfExists: true)
25+
],
26+
[
27+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.bim', checkIfExists: true)
28+
],
29+
[
30+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/popgen/plink_simulated.fam', checkIfExists: true)
31+
]
32+
]
33+
input[1] = [[ id:'all_variants' ], []]
34+
"""
35+
}
36+
}
37+
}
38+
39+
test("homo_sapiens popgen - create sparse GRM") {
40+
config "./nextflow.config"
41+
42+
when {
43+
process {
44+
"""
45+
dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin ->
46+
def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job
47+
[[ id:prefix ], grm_id, grm_bin, grm_n_bin]
48+
}
49+
50+
input[0] = dense_grm
51+
input[1] = Channel.value(0.05)
52+
"""
53+
}
54+
}
55+
56+
then {
57+
assertAll(
58+
{ assert process.success },
59+
{ assert process.out.sparse_grm_files.size() == 1 },
60+
{ assert process.out.sparse_grm_files.get(0).get(0).id == "plink_simulated_dense.part_1_1" },
61+
{
62+
assert snapshot(
63+
process.out.sparse_grm_files,
64+
process.out.findAll { key, val -> key.startsWith('versions') }
65+
).match()
66+
}
67+
)
68+
}
69+
}
70+
71+
test("homo_sapiens popgen - create sparse GRM - stub") {
72+
options "-stub"
73+
config "./nextflow.config"
74+
75+
when {
76+
process {
77+
"""
78+
dense_grm = GCTA_MAKEGRMPART_DENSE.out.grm_files.map { meta, grm_id, grm_bin, grm_n_bin ->
79+
def prefix = meta.id + '.part_' + meta.nparts_gcta + '_' + meta.part_gcta_job
80+
[[ id:prefix ], grm_id, grm_bin, grm_n_bin]
81+
}
82+
83+
input[0] = dense_grm
84+
input[1] = Channel.value(0.05)
85+
"""
86+
}
87+
}
88+
89+
then {
90+
assertAll(
91+
{ assert process.success },
92+
{ assert snapshot(process.out).match() }
93+
)
94+
}
95+
}
96+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"homo_sapiens popgen - create sparse GRM": {
3+
"content": [
4+
[
5+
[
6+
{
7+
"id": "plink_simulated_dense.part_1_1"
8+
},
9+
"plink_simulated_dense.part_1_1_sp.grm.id:md5,4f9aa36c44a417ff6d7caa9841e66ad9",
10+
"plink_simulated_dense.part_1_1_sp.grm.sp:md5,1b78fe4b14c8690943d7687dd22ba85a"
11+
]
12+
],
13+
{
14+
"versions_gcta": [
15+
[
16+
"GCTA_MAKEBKSPARSE",
17+
"gcta",
18+
"1.94.1"
19+
]
20+
]
21+
}
22+
],
23+
"meta": {
24+
"nf-test": "0.9.3",
25+
"nextflow": "25.10.4"
26+
},
27+
"timestamp": "2026-03-13T15:36:15.829559344"
28+
},
29+
"homo_sapiens popgen - create sparse GRM - stub": {
30+
"content": [
31+
{
32+
"0": [
33+
[
34+
{
35+
"id": "plink_simulated_dense.part_1_1"
36+
},
37+
"plink_simulated_dense.part_1_1_sp.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
38+
"plink_simulated_dense.part_1_1_sp.grm.sp:md5,d41d8cd98f00b204e9800998ecf8427e"
39+
]
40+
],
41+
"1": [
42+
[
43+
"GCTA_MAKEBKSPARSE",
44+
"gcta",
45+
"1.94.1"
46+
]
47+
],
48+
"sparse_grm_files": [
49+
[
50+
{
51+
"id": "plink_simulated_dense.part_1_1"
52+
},
53+
"plink_simulated_dense.part_1_1_sp.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e",
54+
"plink_simulated_dense.part_1_1_sp.grm.sp:md5,d41d8cd98f00b204e9800998ecf8427e"
55+
]
56+
],
57+
"versions_gcta": [
58+
[
59+
"GCTA_MAKEBKSPARSE",
60+
"gcta",
61+
"1.94.1"
62+
]
63+
]
64+
}
65+
],
66+
"meta": {
67+
"nf-test": "0.9.3",
68+
"nextflow": "25.10.4"
69+
},
70+
"timestamp": "2026-03-13T15:36:22.049066879"
71+
}
72+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
params {
2+
modules_testdata_base_path = System.getenv("NF_MODULES_TESTDATA_BASE_PATH") ?: "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/"
3+
}

0 commit comments

Comments
 (0)