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/filtergrmwithkeep/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/filtergrmwithkeep/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
process GCTA_FILTERGRMWITHKEEP {
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)
tuple val(meta2), path(keep_file)

output:
tuple val(meta), path("*_unrel.grm.*"), emit: filtered_grm
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}"

"""

gcta \\
--grm ${meta.id} \\
--keep ${keep_file} \\
--make-grm \\
--out ${prefix}_unrel \\
--thread-num ${task.cpus} \\
${extra_args}
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}_unrel.grm.id
touch ${prefix}_unrel.grm.bin
touch ${prefix}_unrel.grm.N.bin
"""
}
83 changes: 83 additions & 0 deletions modules/nf-core/gcta/filtergrmwithkeep/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "gcta_filtergrmwithkeep"
description: Filter a dense GRM to the individuals listed in a keep file
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
e.g. `[ id:'plink_simulated' ]`
`meta.id` is required and is the dense GRM basename contract used by `gcta --grm`.
Input files must therefore be staged as `<meta.id>.grm.id`, `<meta.id>.grm.bin`, and `<meta.id>.grm.N.bin`.
- grm_files:
type: file
description: Dense GRM file bundle
pattern: "*.grm.*"
ontologies: []
- - meta2:
type: map
description: |
Groovy map containing keep-file metadata
e.g. `[ id:'plink_simulated_keep' ]`
- keep_file:
type: file
description: Keep file listing the individuals to retain
pattern: "*.{keep,txt,id}"
ontologies:
- edam: "http://edamontology.org/format_2330"

output:
filtered_grm:
- - meta:
type: map
description: |
Groovy map containing dense GRM metadata
e.g. `[ id:'plink_simulated' ]`
`meta.id` is preserved from the input dense GRM basename contract.
- "*_unrel.grm.*":
type: file
description: Filtered GRM file bundle
pattern: "*_unrel.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"
145 changes: 145 additions & 0 deletions modules/nf-core/gcta/filtergrmwithkeep/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "gcta"
tag "gcta/filtergrmwithkeep"
tag "gcta/makegrm"
tag "gcta/removerelatedsubjects"

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

input[0] = [
[ id:'plink_simulated_dense' ],
file('plink_simulated.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)
]
]
"""
}
}

run("GCTA_REMOVERELATEDSUBJECTS", alias: "GCTA_REMOVERELATEDSUBJECTS_KEEP") {
script "../../removerelatedsubjects/main.nf"
process {
"""
dense_grm = GCTA_MAKEGRM_DENSE.out.grm_files
.map { meta, grm_files -> [[ id:meta.id ], grm_files] }

input[0] = dense_grm
"""
}
}
}

test("homo_sapiens popgen - filter dense GRM with keep file") {
config "./nextflow.config"

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

then {
assertAll(
{ assert process.success },
{ assert process.out.filtered_grm.size() == 1 },
{ assert process.out.filtered_grm.get(0).get(0).id == "plink_simulated_dense" },
{
assert snapshot(
process.out.filtered_grm
).match("filtered_grm")
},
{
def row = process.out.filtered_grm.get(0)
assert row.get(1).every { file(it).exists() }
assert row.get(1).collect { file(it).name }.sort() == [
"plink_simulated_dense_unrel.grm.N.bin",
"plink_simulated_dense_unrel.grm.bin",
"plink_simulated_dense_unrel.grm.id"
]
},
{ assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match("versions") }
)
}
}

test("homo_sapiens popgen - fail when meta id does not match dense GRM basename") {
config "./nextflow.config"

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

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

test("homo_sapiens popgen - filter dense GRM with keep file - stub") {
options "-stub"
config "./nextflow.config"

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

then {
assertAll(
{ assert process.success },
{ assert process.out.filtered_grm.size() == 1 },
{ assert process.out.filtered_grm.get(0).get(0).id == "plink_simulated_dense" },
{
assert snapshot(
process.out.filtered_grm
).match("stub_filtered_grm")
},
{
def row = process.out.filtered_grm.get(0)
assert row.get(1).every { file(it).exists() }
assert row.get(1).collect { file(it).name }.sort() == [
"plink_simulated_dense_unrel.grm.N.bin",
"plink_simulated_dense_unrel.grm.bin",
"plink_simulated_dense_unrel.grm.id"
]
},
{ assert snapshot(process.out.findAll { key, val -> key.startsWith('versions') }).match("stub_versions") }
)
}
}
}
80 changes: 80 additions & 0 deletions modules/nf-core/gcta/filtergrmwithkeep/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"versions": {
"content": [
{
"versions_gcta": [
[
"GCTA_FILTERGRMWITHKEEP",
"gcta",
"1.94.1"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-21T00:31:58.734112033"
},
"stub_filtered_grm": {
"content": [
[
[
{
"id": "plink_simulated_dense"
},
[
"plink_simulated_dense_unrel.grm.N.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
"plink_simulated_dense_unrel.grm.bin:md5,d41d8cd98f00b204e9800998ecf8427e",
"plink_simulated_dense_unrel.grm.id:md5,d41d8cd98f00b204e9800998ecf8427e"
]
]
]
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-05-15T23:16:45.31350454"
},
"filtered_grm": {
"content": [
[
[
{
"id": "plink_simulated_dense"
},
[
"plink_simulated_dense_unrel.grm.N.bin:md5,06b73ea8bae8f1e5f5d4de33dbd2c75e",
"plink_simulated_dense_unrel.grm.bin:md5,b1f124463eecbae86840a6651eec372d",
"plink_simulated_dense_unrel.grm.id:md5,ca8c0bded6951fdd3bf0dddc97b6df6b"
]
]
]
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-05-15T23:14:49.332143185"
},
"stub_versions": {
"content": [
{
"versions_gcta": [
[
"GCTA_FILTERGRMWITHKEEP",
"gcta",
"1.94.1"
]
]
}
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.10.4"
},
"timestamp": "2026-03-21T00:32:15.282563791"
}
}
3 changes: 3 additions & 0 deletions modules/nf-core/gcta/filtergrmwithkeep/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/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
Loading
Loading