Friday, September 6, 2013

creating Manhattan plot (p-value, -log10(pvalue) or R-square etc) using plantbreeding package


Install recent version of R (R version 3.0.1)

Install plantbreeding. Update to recent release if you have old one.

Default plot expect pvalue as input and produce output in terms of -log10 (pvalue).

# Example data

data12 <- data.frame (snp = 1: 2000*20 , chr = c(rep(1:20, each = 2000)), 
pos= rep(1:2000, 20), pval= rnorm(2000*20, 0.001, 0.005))


manhatton.plot(dataframe = data12, SNPname = "snp", chromosome = "chr", position = "pos",pconv= "-log10",  pvcol = "pval",ymax = "maximum", ymin = 0, gapbp = 500, color=c("hotpink3","dodgerblue4"), line1 = 3, line2 = 5, pch = c(1,20) )


Plotting p-value without log conversion or R-square

plotting simple p-value or R-square 
 data13 <- data.frame (snp = 1: 2000*20 , chr = c(rep(1:20, each = 2000)), 
pos= rep(1:2000, 20), pval= rnorm(2000*20, 0.15, 0.05))

manhatton.plot(dataframe = data13, pconv= "NULL", ylabel = "R-square", SNPname = "snp", chromosome = "chr", position = "pos", pvcol = "pval",ymax = 0.5, ymin = 0, gapbp = 0, color=c("hotpink3","dodgerblue4", "green1"), line1 = 0.05, line2 = 0.1, pch = c(1,18, 21) )


 

# with stripes 
data12 <- data.frame (snp = 1: 2000*20 , chr = c(rep(1:20, each = 2000)), 
pos= rep(1:2000, 20), pval= rnorm(2000*20, 0.001, 0.005))
manhatton.plot(dataframe = data12, SNPname = "snp", chromosome = "chr", 
position = "pos", pvcol = "pval",ymax = "maximum", ymin = 0,  gapbp = 500, 
color=c("hotpink3","dodgerblue4"), line1 = 3, line2 = 5, pch = c(1,20),
stripe= TRUE, stripe.color = c("aliceblue", "cornsilk", "lightgoldenrod") 



Add annotation above or below a threshold 
# with annotation 
manhatton.plot(dataframe = data12, SNPname = "snp", chromosome = "chr", 
position = "pos", pvcol = "pval",ymax = "maximum", ymin = 0,  gapbp = 500, 
color=c("hotpink3","dodgerblue4"), line1 = 3, line2 = 5, pch = c(1,20),
annotate= TRUE, threshold= 6, thresholddir = "upper" )