annotate manhattan.R @ 0:7a8a21c5a57f draft default tip

"planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
author iuc
date Thu, 08 Oct 2020 17:28:43 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
1 options(show.error.messages = F, error = function() {
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
2 cat(geterrmessage(), file = stderr()); q("no", 1, F)
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
3 }
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
4 )
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
5
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
6 # we need that to not crash galaxy with an UTF8 error on German LC settings.
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
8
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
9 suppressPackageStartupMessages({
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
10 library(qqman)
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
11 library(optparse)
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
12 })
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
13 option_list <- list(
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
14 make_option(c("-f", "--file"), type = "character", help = "Input file"),
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
15 make_option("--pval", type = "character",
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
16 help = "Pvalue column name", default = "P"),
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
17 make_option("--chr", type = "character",
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
18 help = "Chromosome column name", default = "CHR"),
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
19 make_option("--bp", type = "character",
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
20 help = "Chromosomal position column name", default = "BP"),
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
21 make_option("--snp", type = "character",
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
22 help = "Snp name column name", default = "SNP"),
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
23 make_option("--name", type = "character",
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
24 help = "Plot name", default = "Manhattan Plot"))
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
25 args <- parse_args(OptionParser(option_list = option_list))
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
26 file <- args$file
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
27 pvalcol <- args$pval
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
28 chrcol <- args$chr
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
29 bpcol <- args$bp
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
30 snpcol <- args$snp
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
31 name <- as.character(args$name)
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
32 data <- read.table(args$file, header = TRUE)
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
33 pdf("manhattan.pdf")
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
34 manhattan(data, chr = chrcol, bp = bpcol,
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
35 p = pvalcol, snp = snpcol, main = name)
7a8a21c5a57f "planemo upload commit 3126d8d1bdf88d13a8d168020bdf03dbb2dd1c0b"
iuc
parents:
diff changeset
36 invisible(dev.off())