Skip to content
Draft
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
10 changes: 10 additions & 0 deletions modules/nf-core/hdl/h2/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
- dnachun
dependencies:
- conda-forge::r-base=4.3.1
- conda-forge::r-data.table=1.15.4
- dnachun::r-hdl=1.4.0
35 changes: 35 additions & 0 deletions modules/nf-core/hdl/h2/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
process HDL_H2 {
tag "hdl_h2_${meta.id}"
label 'process_medium'
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'oras://community.wave.seqera.io/library/r-base_r-data.table_r-hdl:a2553504418194cc' :
'community.wave.seqera.io/library/r-base_r-data.table_r-hdl:cb9d70356e12d034' }"

input:
tuple val(meta), path(sumstats)
tuple val(meta2), path(hdl_ref_panel_dir)

output:
tuple val(meta), path("${meta.id}.h2.tsv"), emit: heritability_results
tuple val(meta), path("${meta.id}.hdl.log"), emit: h2_log
tuple val("${task.process}"), val("hdl"), val("1.4.0"), emit: versions_hdl, topic: versions

when:
task.ext.when == null || task.ext.when

script:
template 'hdl_h2.R'

stub:
"""
cat <<EOF_STUB > ${meta.id}.h2.tsv
trait\th2\tse\tp\teigen_use
${meta.id}\t0.2100\t0.0300\t0.00010\tautomatic
EOF_STUB

cat <<EOF_STUB > ${meta.id}.hdl.log
Stub HDL h2 run for ${meta.id}
EOF_STUB
"""
}
62 changes: 62 additions & 0 deletions modules/nf-core/hdl/h2/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: hdl_h2
description: Estimate SNP heritability from GWAS summary statistics using HDL.h2
keywords:
- hdl
- heritability
- gwas
tools:
- hdl:
description: High-definition likelihood method for genetic correlation and heritability from summary statistics
homepage: https://github.com/zhenin/HDL
documentation: https://github.com/zhenin/HDL/wiki
input:
- - meta:
type: map
description: Metadata map for the trait input. The `meta.id` value is used to label output files.
- sumstats:
type: file
description: Canonicalized GWAS summary statistics for the trait in `meta.id`.
- - meta2:
type: map
description: Metadata map for the HDL reference panel directory.
- hdl_ref_panel_dir:
type: directory
description: Directory containing HDL LD reference panel files.
output:
heritability_results:
- - meta:
type: map
description: Propagated trait metadata map.
- ${meta.id}.h2.tsv:
type: file
description: Tab-delimited HDL heritability summary output.
h2_log:
- - meta:
type: map
description: Propagated trait metadata map.
- ${meta.id}.hdl.log:
type: file
description: HDL heritability run log.
versions_hdl:
- - ${task.process}:
type: string
description: Name of the process
- hdl:
type: string
description: Name of the tool
- 1.4.0:
type: string
description: Version of the HDL R package bundled for the module
topics:
versions:
- - ${task.process}:
type: string
description: Name of the process
- hdl:
type: string
description: Name of the tool
- 1.4.0:
type: string
description: Version of the HDL R package bundled for the module
authors:
- andongni
41 changes: 41 additions & 0 deletions modules/nf-core/hdl/h2/templates/hdl_h2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env Rscript

suppressPackageStartupMessages({
library(data.table)
})

parse_hdl_ext_args <- function(raw_ext_args = "${task.ext.args ?: ''}") {
tryCatch(
eval(parse(text = sprintf("list(%s)", raw_ext_args))),
error = function(e) stop(sprintf("Failed to parse task.ext.args as R named arguments: %s", conditionMessage(e)))
)
}

if (!requireNamespace("HDL", quietly = TRUE)) {
stop("R package 'HDL' is not installed. Install HDL in the runtime container/environment.")
}

gwas <- fread("${sumstats}", data.table = FALSE)
hdl_ext_args <- parse_hdl_ext_args()

call_args <- c(
list(
gwas.df = gwas,
LD.path = "${hdl_ref_panel_dir}",
output.file = "${meta.id}.hdl.log"
),
hdl_ext_args
)

result <- do.call(HDL::HDL.h2, call_args)

out <- data.frame(
trait = "${meta.id}",
h2 = as.numeric(result[["h2"]]),
se = as.numeric(result[["h2.se"]]),
p = as.numeric(result[["P"]]),
eigen_use = as.character(result[["eigen.use"]]),
stringsAsFactors = FALSE
)

fwrite(out, "${meta.id}.h2.tsv", sep = "\t", quote = FALSE, na = "NA")
64 changes: 64 additions & 0 deletions modules/nf-core/hdl/h2/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
nextflow_process {

name "Test Process HDL_H2"
script "../main.nf"
config "./nextflow.config"
process "HDL_H2"
tag "modules"
tag "modules_nfcore"
tag "hdl"
tag "hdl/h2"

test("trait1 - real") {
when {
process {
"""
input[0] = tuple(
[id: "trait1"],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/sumstats/trait1_canonical.tsv", checkIfExists: true)
)
input[1] = tuple(
[id: "hdl_reference"],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/hdl/reference", checkIfExists: true)
)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.heritability_results.size() == 1 },
{ assert process.out.h2_log.size() == 1 },
{ assert process.out.versions_hdl.size() == 1 }
)
}
}

test("trait1 - stub") {
options "-stub"
when {
process {
"""
input[0] = tuple(
[id: "trait1"],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/sumstats/trait1_canonical.tsv", checkIfExists: true)
)
input[1] = tuple(
[id: "hdl_reference"],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/popgen/hdl/reference", checkIfExists: true)
)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert process.out.heritability_results.size() == 1 },
{ assert process.out.h2_log.size() == 1 },
{ assert process.out.versions_hdl.size() == 1 }
)
}
}
}
8 changes: 8 additions & 0 deletions modules/nf-core/hdl/h2/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
params {
modules_testdata_base_path = System.getenv("NF_MODULES_TESTDATA_BASE_PATH") ?: "https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/"
}

docker {
enabled = true
runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64'
}
10 changes: 10 additions & 0 deletions modules/nf-core/hdl/rg/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
- dnachun
dependencies:
- conda-forge::r-base=4.3.1
- conda-forge::r-data.table=1.15.4
- dnachun::r-hdl=1.4.0
36 changes: 36 additions & 0 deletions modules/nf-core/hdl/rg/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
process HDL_RG {
tag "hdl_rg_${meta.id}_${meta2.id}"
label 'process_medium'
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'oras://community.wave.seqera.io/library/r-base_r-data.table_r-hdl:a2553504418194cc' :
'community.wave.seqera.io/library/r-base_r-data.table_r-hdl:cb9d70356e12d034' }"

input:
tuple val(meta), path(sumstats1)
tuple val(meta2), path(sumstats2)
tuple val(meta3), path(hdl_ref_panel_dir)

output:
tuple val(meta), val(meta2), path("${meta.id}.${meta2.id}.rg.tsv"), emit: correlation_results
tuple val(meta), val(meta2), path("${meta.id}.${meta2.id}.hdl.log"), emit: rg_log
tuple val("${task.process}"), val("hdl"), val("1.4.0"), emit: versions_hdl, topic: versions

when:
task.ext.when == null || task.ext.when

script:
template 'hdl_rg.R'

stub:
"""
cat <<EOF_STUB > ${meta.id}.${meta2.id}.rg.tsv
trait1\ttrait2\trg\tse\tp\th2_trait1\th2_trait2\tcovariance\teigen_use
${meta.id}\t${meta2.id}\t0.3500\t0.0700\t0.00001\t0.2000\t0.1800\t0.0600\tautomatic
EOF_STUB

cat <<EOF_STUB > ${meta.id}.${meta2.id}.hdl.log
Stub HDL rg run for ${meta.id} and ${meta2.id}
EOF_STUB
"""
}
74 changes: 74 additions & 0 deletions modules/nf-core/hdl/rg/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: hdl_rg
description: Estimate pairwise genetic correlation from GWAS summary statistics using HDL.rg
keywords:
- hdl
- genetic correlation
- gwas
tools:
- hdl:
description: High-definition likelihood method for genetic correlation and heritability from summary statistics
homepage: https://github.com/zhenin/HDL
documentation: https://github.com/zhenin/HDL/wiki
input:
- - meta:
type: map
description: Metadata map for the first trait input. The `meta.id` value is used as the first trait label.
- sumstats1:
type: file
description: Canonicalized GWAS summary statistics for the first trait.
- - meta2:
type: map
description: Metadata map for the second trait input. The `meta2.id` value is used as the second trait label.
- sumstats2:
type: file
description: Canonicalized GWAS summary statistics for the second trait.
- - meta3:
type: map
description: Metadata map for the HDL reference panel directory.
- hdl_ref_panel_dir:
type: directory
description: Directory containing HDL LD reference panel files.
output:
correlation_results:
- - meta:
type: map
description: Propagated first-trait metadata map.
- meta2:
type: map
description: Propagated second-trait metadata map.
- ${meta.id}.${meta2.id}.rg.tsv:
type: file
description: Tab-delimited HDL genetic correlation summary output.
rg_log:
- - meta:
type: map
description: Propagated first-trait metadata map.
- meta2:
type: map
description: Propagated second-trait metadata map.
- ${meta.id}.${meta2.id}.hdl.log:
type: file
description: HDL genetic-correlation run log.
versions_hdl:
- - ${task.process}:
type: string
description: Name of the process
- hdl:
type: string
description: Name of the tool
- 1.4.0:
type: string
description: Version of the HDL R package bundled for the module
topics:
versions:
- - ${task.process}:
type: string
description: Name of the process
- hdl:
type: string
description: Name of the tool
- 1.4.0:
type: string
description: Version of the HDL R package bundled for the module
authors:
- andongni
Loading
Loading