1
0
Entering edit mode
7.9 years ago

Hi! I am trying to plot a QQplot with results from a gwas runned with plink. I would like to know how can I add the tipical grey shadow showing confidence interval (95%CI). I can not find it. Does someone know?

My plot looks like that:

assoc<-read.table("all_SNPs_assoc.txt",header=TRUE,dec=".")
png("QQplot.png")
a<-assoc$SNP n<-length(a) the<-(-1*log(pchisq(rchisq(n,df=1),df=1,lower.tail=F),base=10)) # pchisq gives de distribution function # rchisq generates random deviates act<-(-1*log(assoc$P[a],base=10))
qqplot(the,act,main="QQplot assoc",xlab="Expected -log p",ylab="Observed -log p")
qqline(probs=0.05)
abline(0,1)
dev.off()


Thanks!

qqplot R • 5.0k views
0
Entering edit mode
7.9 years ago
Ahill ★ 1.9k

See the R snpStats package. In the manual, page 29, there is a function qq.chisq() which will provide a QQ plot including a grey confidence band. The confidence band is added using the polygon() function.

0
Entering edit mode

Thanks Ahill! But now, with my code like this:

assoc<-read.table("all_SNPs_assoc.txt",header=TRUE,dec=".")
png("QQplot.png")
P<-assoc_allSNPs_mperm\$P
qq.chisq(-2 * log(P), df = 2, conc=c(0.05, 0.95))
abline(0,1)
dev.off()


It provides a nice plot, but with x and y axis in chi-squared values and I need it in expected -log pvalues. In my data I just have p-values that are the values that I give to variable P. How can I have the x and y axis with the original p-values and not converted to chi-squared values? Or there is some kind of qq.pval() function? Thanks.

0
Entering edit mode

Don't worry! I found GWASTools package from bioconductor which solved my problem. Thanks for all.