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/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
42 changes: 42 additions & 0 deletions modules/nf-core/gcta/adjustgrm/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
process GCTA_ADJUSTGRM {
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(grm_files), val(grm_adj)

output:
tuple val(meta), path("*_adj.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 grm_adj_value = grm_adj == null ? 0 : grm_adj
def prefix = task.ext.prefix ?: "${meta.id}"

"""

gcta \\
--grm ${meta.id} \\
--grm-adj ${grm_adj_value} \\
--make-grm \\
--out ${prefix}_adj \\
--thread-num ${task.cpus} \\
${extra_args}
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}_adj.grm.id
touch ${prefix}_adj.grm.bin
touch ${prefix}_adj.grm.N.bin
"""
}
77 changes: 77 additions & 0 deletions modules/nf-core/gcta/adjustgrm/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "gcta_adjustgrm"
description: Adjust a dense GRM for incomplete tagging using `gcta --grm-adj`
keywords:
- gcta
- genome-wide complex trait analysis
- 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 dense GRM metadata.
`meta.id` is the required GRM basename consumed by `--grm` and must match
the staged dense GRM files.
e.g. `[ id:'tiny_dense' ]` requires
`tiny_dense.grm.id`, `tiny_dense.grm.bin`, and `tiny_dense.grm.N.bin`.
- grm_files:
type: file
description: Dense GRM file bundle with basename `${meta.id}`
pattern: "*.grm.*"
ontologies: []
- grm_adj:
type: integer
description: |
GRM adjustment value passed to `--grm-adj`.
If not provided (`null`), the module falls back to integer `0`.

output:
grm_files:
- - meta:
type: map
description: |
Groovy map containing dense GRM metadata.
`meta.id` remains the dense-GRM basename contract used for `--grm`.
- "*_adj.grm.*":
type: file
description: Adjusted GRM file bundle
pattern: "*_adj.grm.*"
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 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"
200 changes: 200 additions & 0 deletions modules/nf-core/gcta/adjustgrm/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "gcta"
tag "gcta/adjustgrm"
tag "gcta/makegrm"

setup {
run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_DENSE") {
script "../../makegrm/main.nf"
process {
"""
file('plink_simulated.mbfile').text = 'plink_simulated\\n'

input[0] = [
[ id:'tiny_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)
]
]
"""
}
}

run("GCTA_MAKEGRM", alias: "GCTA_MAKEGRM_DENSE_STUB") {
script "../../makegrm/main.nf"
process {
"""
file('plink_simulated.mbfile').text = 'plink_simulated\\n'

input[0] = [
[ id:'stub_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 - adjust dense GRM") {
config "./nextflow.config"

when {
process {
"""
input[0] = GCTA_MAKEGRM_DENSE.out.grm_files.map { meta, grm_files -> [meta, grm_files, 1] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.grm_files.size() == 1 },
{ assert process.out.grm_files.get(0).get(0).id == "tiny_dense" },
{
def grm_row = process.out.grm_files.get(0)
def expected_prefix = "${grm_row.get(0).id}_adj"
assert grm_row.get(1).collect { file(it).name }.sort() == [
"${expected_prefix}.grm.N.bin",
"${expected_prefix}.grm.bin",
"${expected_prefix}.grm.id"
]
},
{
assert snapshot(
process.out.grm_files,
process.out.findAll { key, val -> key.startsWith('versions') }
).match()
}
)
}
}

test("homo_sapiens popgen - adjust dense GRM with null fallback value") {
config "./nextflow.config"

when {
process {
"""
input[0] = GCTA_MAKEGRM_DENSE.out.grm_files.map { meta, grm_files -> [meta, grm_files, null] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.grm_files.size() == 1 },
{ assert process.out.grm_files.get(0).get(0).id == "tiny_dense" },
{
def grm_row = process.out.grm_files.get(0)
def expected_prefix = "${grm_row.get(0).id}_adj"
assert grm_row.get(1).collect { file(it).name }.sort() == [
"${expected_prefix}.grm.N.bin",
"${expected_prefix}.grm.bin",
"${expected_prefix}.grm.id"
]
},
{
assert snapshot(
process.out.grm_files,
process.out.findAll { key, val -> key.startsWith('versions') }
).match()
}
)
}
}

test("homo_sapiens popgen - adjust dense GRM fails when meta.id is not GRM basename") {
config "./nextflow.config"

when {
process {
"""
input[0] = GCTA_MAKEGRM_DENSE.out.grm_files.map { meta, grm_files -> [[ id:meta.id + '_mismatched' ], grm_files, 1] }
"""
}
}

then {
assertAll(
{ assert !process.success },
{ assert process.exitStatus != 0 }
)
}
}

test("homo_sapiens popgen - adjust dense GRM fails for malformed GRM tuple") {
config "./nextflow.config"

when {
process {
"""
input[0] = GCTA_MAKEGRM_DENSE.out.grm_files.map { meta, grm_files -> [meta, 1] }
"""
}
}

then {
assert !process.success
}
}

test("homo_sapiens popgen - adjust dense GRM - stub") {
options "-stub"
config "./nextflow.config"

when {
process {
"""
input[0] = GCTA_MAKEGRM_DENSE_STUB.out.grm_files.map { meta, grm_files -> [meta, grm_files, 1] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.grm_files.get(0).get(0).id == "stub_dense" },
{
def grm_row = process.out.grm_files.get(0)
def expected_prefix = "${grm_row.get(0).id}_adj"
assert grm_row.get(1).collect { file(it).name }.sort() == [
"${expected_prefix}.grm.N.bin",
"${expected_prefix}.grm.bin",
"${expected_prefix}.grm.id"
]
},
{
assert snapshot(
process.out.grm_files,
process.out.findAll { key, val -> key.startsWith('versions') }
).match()
}
)
}
}
}
Loading
Loading