postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图

注意:最新版的qqman程序包是基于R 3.2.5版本开发的,所以使用该程序包之前注意更新R软件到最新版本,同时安装最新版的qqman程序包。虽然以前版本的R也能运行相关程序,但是部分功能显示不够完善。
以下内容因为格式问题将源网页内容稍加调整
Intro to the qqman package
The qqman package includes functions for creating manhattan plots and q-q plots from GWAS results. ThegwasResults data.frame included with the package has simulated results for 16,470 SNPs on 22 chromosomes. Take a look at the data:
> str(gwasResults)
'data.frame':16470 obs. of5 variables:
$ SNP: chr"rs1" "rs2" "rs3" "rs4" ...
$ CHR: int1 1 1 1 1 1 1 1 1 1 ...
$ BP: int1 2 3 4 5 6 7 8 9 10 ...
$ P: num0.915 0.937 0.286 0.83 0.642 ...
$ zscore: num0.107 0.0789 1.0666 0.2141 0.4653 ...复制代码
How many SNPs on each chromosome?
> as.data.frame(table(gwasResults$CHR))
Var1 Freq
11 1500
22 1191
33 1040
44945
55877
66825
77784
88750
99721
1010696
1111674
1212655
1313638
1414622
1515608
1616595
1717583
1818572
1919562
2020553
2121544
2222535复制代码Creating manhattan plots
Now, let's make a basic manhattan plot.
manhattan(gwasResults)复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:50:15 上传
下载附件 (145.41 KB)
We can also pass in other graphical parameters. Let's add a title (main=), increase the y-axis limit (ylim=), reduce the point size to 60% (cex=), and reduce the font size of the axis labels to 90% (cex.axis=). While we're at it, let's change the colors (col=), remove the suggestive and genome-wide significance lines, and supply our own labels for the chromosomes:
manhattan(gwasResults, main = "Manhattan Plot", ylim = c(0, 10), cex = 0.6, cex.axis = 0.9, col = c("blue4","orange3"), suggestiveline = F, genomewideline = F, chrlabs = c(1:20, "P", "Q"))复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:05 上传
下载附件 (155.07 KB)
Now, let's look at a single chromosome:
manhattan(subset(gwasResults, CHR == 1))复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:06 上传
下载附件 (81.5 KB)
Let's highlight some SNPs of interest on chromosome 3. The 100 SNPs we're highlighting here are in a character vector called snpsOfInterest. You'll get a warning if you try to highlight SNPs that don't exist.
> str(snpsOfInterest)
chr [1:100] "rs3001" "rs3002" "rs3003" "rs3004" "rs3005" ...
> manhattan(gwasResults, highlight = snpsOfInterest)复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:08 上传
下载附件 (147.22 KB)
We can combine highlighting and limiting to a single chromosome, and use the xlim graphical parameter to zoom in on a region of interest (between position 200-500):
manhattan(subset(gwasResults, CHR == 3), highlight = snpsOfInterest, xlim = c(200, 500), main = "Chr 3")复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:09 上传
下载附件 (41.56 KB)
Finally, the manhattan function can be used to plot any value, not just p-values. Here, we'll simply call the function passing to the p= argument the name of the column we want to plot instead of the default “P” column. In this example, let's create a test statistic (“zscore”), plot that instead of p-values, change the y-axis label, and remove the default log transformation. We'll also remove the genomewide and suggestive lines because these are only meaningful if you're plotting -log10(p-values).
# Add test statistics
> gwasResults
head(gwasResults)
SNP CHR BPPzscore
1 rs111 0.9148 0.10698
2 rs212 0.9371 0.07895
3 rs313 0.2861 1.06663
4 rs414 0.8304 0.21413
5 rs515 0.6417 0.46526
6 rs616 0.5191 0.64474复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:11 上传
下载附件 (288.6 KB)
A few notes on creating manhattan plots:Run str(gwasResults). Notice that the gwasResults data.frame has SNP, chromosome, position, and p-value columns named SNP, CHR, BP, and P. If you're creating a manhattan plot and your column names are different, you'll have to pass the column names to the chr=, bp=, p=, and snp= arguments. See help(manhattan) for details.
The chromosome column must be numeric. If you have “X,” “Y,” or “MT” chromosomes, you'll need to rename these 23, 24, 25, etc. You can modify the source code (e.g., fix(manhattan)) to change the line designating the axis tick labels (labs
If you'd like to change the color of the highlight or the suggestive/genomewide lines, you'll need to modify the source code. Search for col="blue", col="red", or col="green3" to modify the suggestive line, genomewide line, and highlight colors, respectively.Creating Q-Q plots
Creating Q-Q plots is straightforward - simply supply a vector of p-values to the qq() function.
qq(gwasResults$P)复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:14 上传
下载附件 (33.3 KB)
We can otionally supply many other graphical parameters.
qq(gwasResults$P, main = "Q-Q plot of GWAS p-values", xlim = c(0, 7), ylim = c(0, 12), pch = 18, col = "blue4", cex =1.5, las = 1)复制代码
postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图
文章图片

2016-4-30 16:51:16 上传
【postgwas|postgwas r语言_如何用R绘制GWAS研究的Manhattan图及QQ图】下载附件 (39.45 KB)

    推荐阅读