comparison manhattan.R @ 0:c4bf5e913c2e draft default tip

"planemo upload commit b1883bac95e73fc6ffe2a36db3115ad5e5a1eba4"
author iuc
date Fri, 11 Oct 2019 17:31:09 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c4bf5e913c2e
1 options( show.error.messages=F, error = function () { cat( geterrmessage(), file=stderr() ); q( "no", 1, F ) } )
2
3 # we need that to not crash galaxy with an UTF8 error on German LC settings.
4 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
5
6 suppressPackageStartupMessages({
7 library(GWASTools)
8 library(optparse)
9 })
10 option_list <- list(
11 make_option(c("-f", "--file"), type="character", help="RInput GWAS file"),
12 make_option("--pval", type="integer", help="Pvalue column"),
13 make_option("--chromosome", type="integer", help="Chromosome column"),
14 make_option("--ymin", type="double", help="Min y value"),
15 make_option("--ymax", type="double", help="Max y value"),
16 make_option("--trunc", help="Show truncation lines", action="store_true"),
17 make_option("--sig", type="double", help="Significance level for lines"),
18 make_option("--thin", type="double", help="Thinning value", action="store_true", dest="thin"),
19 make_option("--ppb", type="integer", help="Points per bin, if thinning value is specified", action="store_true"))
20 args <- parse_args(OptionParser(option_list=option_list))
21 file <- args$file
22 data <- read.table(args$file, header=TRUE)
23 pval <- data[,args$pval]
24 chromosome <- data[,args$chromosome]
25 if(!is.null(args$ymin) & !is.null(args$ymax)){
26 ylimit <- c(args$ymin,args$ymax)
27 }else if(xor(!is.null(args$ymin), !is.null(args$ymax))){
28 print("If specifying range, both ymin and ymax must be set")
29 ylimit <- NULL
30 }else{
31 ylimit <- NULL
32 }
33 if(is.null(args$trunc)){
34 trunc <- FALSE
35 }else{
36 trunc <- TRUE
37 }
38 if(!is.null(args$sig)){
39 sig <- args$sig
40 }else{
41 sig <- NULL
42 }
43 if(!is.null(args$thin)){
44 thin = args$thin
45 if(thin == 0){
46 thin = NULL
47 }
48 }else{
49 thin <- FALSE
50 }
51 if(!is.null(thin) & !is.null(args$ppb)){
52 ppb = args$ppb
53 }
54 pdf("manhattan.pdf")
55 if(isFALSE(thin)){
56 manhattanPlot(pval, chromosome, ylim=ylimit, trunc.lines=trunc, signif=sig)
57 }else{
58 manhattanPlot(pval, chromosome, ylim=ylimit, trunc.lines=trunc, signif=sig, thinThreshold = thin, pointsPerBin = ppb)
59 }
60 invisible(dev.off())