Skip to content

Commit edb919b

Browse files
Added qqman
1 parent 1b1e2c6 commit edb919b

File tree

6 files changed

+253
-0
lines changed

6 files changed

+253
-0
lines changed
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::r-qqman=0.1.4"

modules/local/qqman/main.nf

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
process QQMAN {
2+
tag "$meta.id"
3+
label 'process_single'
4+
5+
// TODO nf-core: List required Conda package(s).
6+
// Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10").
7+
// For Conda, the build (i.e. "h9402c20_2") must be EXCLUDED to support installation on different operating systems.
8+
// TODO nf-core: See section in main README for further information regarding finding and adding container addresses to the section below.
9+
conda "${moduleDir}/environment.yml"
10+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
11+
'https://depot.galaxyproject.org/singularity/r-qqman:0.1.4--r341h6115d3f_2':
12+
'biocontainers/r-qqman:0.1.4--r341h6115d3f_2' }"
13+
14+
input:
15+
tuple val(meta), path(assoc)
16+
17+
output:
18+
// TODO nf-core: Named file extensions MUST be emitted for ALL output channels
19+
tuple val(meta), path("*.png"), emit: bam
20+
// TODO nf-core: List additional required output channels/values here
21+
path "versions.yml" , emit: versions
22+
23+
when:
24+
task.ext.when == null || task.ext.when
25+
26+
script:
27+
// def args = task.ext.args ?: ''
28+
def prefix = task.ext.prefix ?: "${meta.id}"
29+
30+
"""
31+
ls
32+
Rscript qqman.R \\
33+
-i mydata.assoc \\
34+
-m my_manhattan.png \\
35+
-q my_qq.png
36+
37+
cat <<-END_VERSIONS > versions.yml
38+
"${task.process}":
39+
qqman: \$(samtools --version |& sed '1!d ; s/samtools //')
40+
END_VERSIONS
41+
"""
42+
43+
stub:
44+
// def args = task.ext.args ?: ''
45+
def prefix = task.ext.prefix ?: "${meta.id}"
46+
47+
"""
48+
touch ${prefix}.png
49+
50+
cat <<-END_VERSIONS > versions.yml
51+
"${task.process}":
52+
qqman: \$(samtools --version |& sed '1!d ; s/samtools //')
53+
END_VERSIONS
54+
"""
55+
}

modules/local/qqman/meta.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
3+
name: "qqman"
4+
## TODO nf-core: Add a description of the module and list keywords
5+
description: write your description here
6+
keywords:
7+
- sort
8+
- example
9+
- genomics
10+
tools:
11+
- "qqman":
12+
## TODO nf-core: Add a description and other details for the software below
13+
description: "Create Q-Q and manhattan plots for GWAS data from PLINK results."
14+
homepage: "None"
15+
documentation: "None"
16+
tool_dev_url: "None"
17+
doi: ""
18+
licence: ['GPL v3']
19+
identifier:
20+
21+
## TODO nf-core: Add a description of all of the variables used as input
22+
input:
23+
# Only when we have meta
24+
- - meta:
25+
type: map
26+
description: |
27+
Groovy Map containing sample information
28+
e.g. `[ id:'sample1', single_end:false ]`
29+
30+
## TODO nf-core: Delete / customise this example input
31+
- bam:
32+
type: file
33+
description: Sorted BAM/CRAM/SAM file
34+
pattern: "*.{bam,cram,sam}"
35+
ontologies:
36+
- edam: "http://edamontology.org/format_25722"
37+
- edam: "http://edamontology.org/format_2573"
38+
- edam: "http://edamontology.org/format_3462"
39+
40+
41+
## TODO nf-core: Add a description of all of the variables used as output
42+
output:
43+
- bam:
44+
#Only when we have meta
45+
- meta:
46+
type: map
47+
description: |
48+
Groovy Map containing sample information
49+
e.g. `[ id:'sample1', single_end:false ]`
50+
## TODO nf-core: Delete / customise this example output
51+
- "*.bam":
52+
type: file
53+
description: Sorted BAM/CRAM/SAM file
54+
pattern: "*.{bam,cram,sam}"
55+
ontologies:
56+
- edam: "http://edamontology.org/format_25722"
57+
- edam: "http://edamontology.org/format_2573"
58+
- edam: "http://edamontology.org/format_3462"
59+
60+
- versions:
61+
- "versions.yml":
62+
type: file
63+
description: File containing software versions
64+
pattern: "versions.yml"
65+
66+
authors:
67+
- "@FernandoDuarteF"
68+
maintainers:
69+
- "@FernandoDuarteF"

modules/local/qqman/qqman.R

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
# Load required packages
3+
suppressPackageStartupMessages({
4+
library(argparse)
5+
library(qqman)
6+
})
7+
8+
# ---- ARGUMENT PARSING ----
9+
parser <- ArgumentParser(description = "Run qqman on a PLINK .assoc file")
10+
11+
parser$add_argument("-i", "--input", required = TRUE,
12+
help = "Input PLINK .assoc file")
13+
parser$add_argument("-m", "--manhattan", default = "manhattan_plot.png",
14+
help = "Output filename for Manhattan plot [default: manhattan_plot.png]")
15+
parser$add_argument("-q", "--qq", default = "qq_plot.png",
16+
help = "Output filename for Q-Q plot [default: qq_plot.png]")
17+
18+
args <- parser$parse_args()
19+
20+
# ---- LOAD DATA ----
21+
assoc_data <- read.table(args$input, header = TRUE)
22+
23+
# Validate required columns
24+
required_cols <- c("CHR", "BP", "SNP", "P")
25+
missing_cols <- setdiff(required_cols, colnames(assoc_data))
26+
if (length(missing_cols) > 0) {
27+
stop(paste("Missing required columns in .assoc file:", paste(missing_cols, collapse = ", ")))
28+
}
29+
30+
# ---- PLOTTING ----
31+
32+
# Manhattan plot
33+
png(args$manhattan, width = 1000, height = 600)
34+
manhattan(assoc_data, main = "Manhattan Plot")
35+
dev.off()
36+
37+
# Q-Q plot
38+
png(args$qq, width = 600, height = 600)
39+
qq(assoc_data$P, main = "Q-Q Plot")
40+
dev.off()
41+
42+
cat("Plots saved:\n")
43+
cat(" Manhattan plot:", args$manhattan, "\n")
44+
cat(" Q-Q plot:", args$qq, "\n")
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// TODO nf-core: Once you have added the required tests, please run the following command to build this file:
2+
// nf-core modules test qqman
3+
nextflow_process {
4+
5+
name "Test Process QQMAN"
6+
script "../main.nf"
7+
process "QQMAN"
8+
9+
tag "modules"
10+
tag "modules_"
11+
tag "qqman"
12+
13+
// TODO nf-core: Change the test name preferably indicating the test-data and file-format used
14+
test("sarscov2 - bam") {
15+
16+
// TODO nf-core: If you are created a test for a chained module
17+
// (the module requires running more than one process to generate the required output)
18+
// add the 'setup' method here.
19+
// 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).
20+
21+
when {
22+
process {
23+
"""
24+
// TODO nf-core: define inputs of the process here. Example:
25+
26+
input[0] = [
27+
[ id:'test', single_end:false ], // meta map
28+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
29+
]
30+
"""
31+
}
32+
}
33+
34+
then {
35+
assertAll(
36+
{ assert process.success },
37+
{ assert snapshot(process.out).match() }
38+
//TODO nf-core: Add all required assertions to verify the test output.
39+
// See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples.
40+
)
41+
}
42+
43+
}
44+
45+
// TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix.
46+
test("sarscov2 - bam - stub") {
47+
48+
options "-stub"
49+
50+
when {
51+
process {
52+
"""
53+
// TODO nf-core: define inputs of the process here. Example:
54+
55+
input[0] = [
56+
[ id:'test', single_end:false ], // meta map
57+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
58+
]
59+
"""
60+
}
61+
}
62+
63+
then {
64+
assertAll(
65+
{ assert process.success },
66+
{ assert snapshot(process.out).match() }
67+
//TODO nf-core: Add all required assertions to verify the test output.
68+
)
69+
}
70+
71+
}
72+
73+
}

workflows/gwas.nf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include { softwareVersionsToYAML } from '../subworkflows/nf-core/utils_nfcore_pi
1010
include { methodsDescriptionText } from '../subworkflows/local/utils_nfcore_gwas_pipeline'
1111
include { PLINK_VCF } from '../modules/nf-core/plink/vcf/main'
1212
include { PLINK_GWAS } from '../modules/nf-core/plink/gwas/main'
13+
include { QQMAN } from '../modules/local/qqman/main'
1314

1415
/*
1516
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -61,6 +62,10 @@ workflow GWAS {
6162
[[],[]],
6263
)
6364

65+
QQMAN (
66+
PLINK_GWAS.out.qassoc
67+
)
68+
6469
//
6570
// Collate and save software versions
6671
//

0 commit comments

Comments
 (0)