Skip to content
Closed
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
5 changes: 2 additions & 3 deletions assets/samplesheet.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
sample,fastq_1,fastq_2
SAMPLE_PAIRED_END,/path/to/fastq/files/AEG588A1_S1_L002_R1_001.fastq.gz,/path/to/fastq/files/AEG588A1_S1_L002_R2_001.fastq.gz
SAMPLE_SINGLE_END,/path/to/fastq/files/AEG588A4_S4_L003_R1_001.fastq.gz,
id,vcf,pheno,cov
test,https://raw.githubusercontent.com/nf-core/test-datasets/gwas/data/data_shrink_combined_4500/chr1_to_22_and_X.vcf.bgz,https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/gwas/data/data_phenotypes_and_covariates/example1.pheno,https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/gwas/data/data_phenotypes_and_covariates/example1.covar
16 changes: 10 additions & 6 deletions assets/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,31 @@
"items": {
"type": "object",
"properties": {
"sample": {
"id": {
"type": "string",
"pattern": "^\\S+$",
"errorMessage": "Sample name must be provided and cannot contain spaces",
"meta": ["id"]
},
"fastq_1": {
"vcf": {
"type": "string",
"format": "file-path",
"exists": true,
"pattern": "^\\S+\\.f(ast)?q\\.gz$",
"errorMessage": "FastQ file for reads 1 must be provided, cannot contain spaces and must have extension '.fq.gz' or '.fastq.gz'"
},
"fastq_2": {
"pheno": {
"type": "string",
"format": "file-path",
"exists": true,
"errorMessage": "FastQ file for reads 2 cannot contain spaces and must have extension '.fq.gz' or '.fastq.gz'"
},
"cov": {
"type": "string",
"format": "file-path",
"exists": true,
"pattern": "^\\S+\\.f(ast)?q\\.gz$",
"errorMessage": "FastQ file for reads 2 cannot contain spaces and must have extension '.fq.gz' or '.fastq.gz'"
}
},
"required": ["sample", "fastq_1"]
"required": ["id", "vcf", "pheno"]
}
}
7 changes: 7 additions & 0 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ process {
]
}

withName: 'PLINK_GWAS' {
ext.args = '--allow-no-sex --linear'
publishDir = [
path: { "${params.outdir}/plink_gwas" },
mode: params.publish_dir_mode
]
}
}
10 changes: 10 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"branch": "master",
"git_sha": "f0719ae309075ae4a291533883847c3f7c441dad",
"installed_by": ["modules"]
},
"plink/gwas": {
"branch": "master",
"git_sha": "05954dab2ff481bcb999f24455da29a5828af08d",
"installed_by": ["modules"]
},
"plink/vcf": {
"branch": "master",
"git_sha": "81880787133db07d9b4c1febd152c090eb8325dc",
"installed_by": ["modules"]
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions modules/local/qqman/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::r-qqman=0.1.4"
55 changes: 55 additions & 0 deletions modules/local/qqman/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
process QQMAN {
tag "$meta.id"
label 'process_single'

// TODO nf-core: List required Conda package(s).
// Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10").
// For Conda, the build (i.e. "h9402c20_2") must be EXCLUDED to support installation on different operating systems.
// TODO nf-core: See section in main README for further information regarding finding and adding container addresses to the section below.
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/r-qqman:0.1.4--r341h6115d3f_2':
'biocontainers/r-qqman:0.1.4--r341h6115d3f_2' }"

input:
tuple val(meta), path(assoc)

output:
// TODO nf-core: Named file extensions MUST be emitted for ALL output channels
tuple val(meta), path("*.png"), emit: bam
// TODO nf-core: List additional required output channels/values here
path "versions.yml" , emit: versions

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

script:
// def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
ls
Rscript qqman.R \\
-i mydata.assoc \\
-m my_manhattan.png \\
-q my_qq.png

cat <<-END_VERSIONS > versions.yml
"${task.process}":
qqman: \$(samtools --version |& sed '1!d ; s/samtools //')
END_VERSIONS
"""

stub:
// def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
touch ${prefix}.png

cat <<-END_VERSIONS > versions.yml
"${task.process}":
qqman: \$(samtools --version |& sed '1!d ; s/samtools //')
END_VERSIONS
"""
}
69 changes: 69 additions & 0 deletions modules/local/qqman/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "qqman"
## TODO nf-core: Add a description of the module and list keywords
description: write your description here
keywords:
- sort
- example
- genomics
tools:
- "qqman":
## TODO nf-core: Add a description and other details for the software below
description: "Create Q-Q and manhattan plots for GWAS data from PLINK results."
homepage: "None"
documentation: "None"
tool_dev_url: "None"
doi: ""
licence: ['GPL v3']
identifier:

## TODO nf-core: Add a description of all of the variables used as input
input:
# Only when we have meta
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`

## TODO nf-core: Delete / customise this example input
- bam:
type: file
description: Sorted BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
ontologies:
- edam: "http://edamontology.org/format_25722"
- edam: "http://edamontology.org/format_2573"
- edam: "http://edamontology.org/format_3462"


## TODO nf-core: Add a description of all of the variables used as output
output:
- bam:
#Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
## TODO nf-core: Delete / customise this example output
- "*.bam":
type: file
description: Sorted BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
ontologies:
- edam: "http://edamontology.org/format_25722"
- edam: "http://edamontology.org/format_2573"
- edam: "http://edamontology.org/format_3462"

- versions:
- "versions.yml":
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@FernandoDuarteF"
maintainers:
- "@FernandoDuarteF"
44 changes: 44 additions & 0 deletions modules/local/qqman/qqman.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# Load required packages
suppressPackageStartupMessages({
library(argparse)
library(qqman)
})

# ---- ARGUMENT PARSING ----
parser <- ArgumentParser(description = "Run qqman on a PLINK .assoc file")

parser$add_argument("-i", "--input", required = TRUE,
help = "Input PLINK .assoc file")
parser$add_argument("-m", "--manhattan", default = "manhattan_plot.png",
help = "Output filename for Manhattan plot [default: manhattan_plot.png]")
parser$add_argument("-q", "--qq", default = "qq_plot.png",
help = "Output filename for Q-Q plot [default: qq_plot.png]")

args <- parser$parse_args()

# ---- LOAD DATA ----
assoc_data <- read.table(args$input, header = TRUE)

# Validate required columns
required_cols <- c("CHR", "BP", "SNP", "P")
missing_cols <- setdiff(required_cols, colnames(assoc_data))
if (length(missing_cols) > 0) {
stop(paste("Missing required columns in .assoc file:", paste(missing_cols, collapse = ", ")))
}

# ---- PLOTTING ----

# Manhattan plot
png(args$manhattan, width = 1000, height = 600)
manhattan(assoc_data, main = "Manhattan Plot")
dev.off()

# Q-Q plot
png(args$qq, width = 600, height = 600)
qq(assoc_data$P, main = "Q-Q Plot")
dev.off()

cat("Plots saved:\n")
cat(" Manhattan plot:", args$manhattan, "\n")
cat(" Q-Q plot:", args$qq, "\n")
73 changes: 73 additions & 0 deletions modules/local/qqman/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// TODO nf-core: Once you have added the required tests, please run the following command to build this file:
// nf-core modules test qqman
nextflow_process {

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

tag "modules"
tag "modules_"
tag "qqman"

// TODO nf-core: Change the test name preferably indicating the test-data and file-format used
test("sarscov2 - bam") {

// TODO nf-core: If you are created a test for a chained module
// (the module requires running more than one process to generate the required output)
// add the 'setup' method here.
// You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules).

when {
process {
"""
// TODO nf-core: define inputs of the process here. Example:

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
//TODO nf-core: Add all required assertions to verify the test output.
// See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples.
)
}

}

// TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix.
test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
// TODO nf-core: define inputs of the process here. Example:

input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
//TODO nf-core: Add all required assertions to verify the test output.
)
}

}

}
7 changes: 7 additions & 0 deletions modules/nf-core/plink/gwas/environment.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading