Open main menu

Genome Analysis Wiki β

Changes

Code Sample: Generating QQ Plots in R

166 bytes added, 14:14, 12 November 2013
A Fancier QQ Plot by Matthew Flickinger
ylab=expression(paste("Observed (",-log[10], " p-value)")),
draw.conf=TRUE, conf.points=1000, conf.col="lightgray", conf.alpha=.05,
already.transformed=FALSE, pch=20, aspect="iso", prepanel=prepanel.qqunif,
par.settings=list(superpose.symbol=list(pch=pch)), ...) {
stop("pvalue vector is not numeric, can't draw plot")
if (any(is.na(unlist(pvalues)))) stop("pvalue vector contains NA values, can't draw plot")
if (already.transformed==FALSE) { if (any(unlist(pvalues)==0)) stop("pvalue vector contains zeros, can't draw plot") } else { if (any(unlist(pvalues)<0)) stop("-log10 pvalue vector contains negative values, can't draw plot") }
gc()
prepanel.origin qqunif= function(x,y,...) {
A = list()
A$xlim = range(x, y)*1.02
#draw the plot
xyplot(pvalues~exp.x, groups=grp, xlab=xlab, ylab=ylab, aspect=aspect,
prepanel=prepanel.origin, scales=list(axs="i"), pch=pch,
panel = function(x, y, ...) {
if (draw.conf) {