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.