安装并加载所需R包
# install.packages("qqman")
library(qqman)
# 加载并查看示例数据
head(gwasResults)
SNP CHR BP P
1 rs1 1 1 0.9148060
2 rs2 1 2 0.9370754
3 rs3 1 3 0.2861395
4 rs4 1 4 0.8304476
5 rs5 1 5 0.6417455
6 rs6 1 6 0.5190959
基本数据格式:SNP名称,所在染色体,SNP位置,Pvalue值
绘制曼哈顿图
基本使用
manhattan(x, chr = "CHR", bp = "BP", p = "P", snp = "SNP",
col = c("gray10", "gray60"), chrlabs = NULL,
suggestiveline = -log10(1e-05), genomewideline = -log10(5e-08),
highlight = NULL, logp = TRUE, annotatePval = NULL,
annotateTop = TRUE, ...)
常用参数
x 输入数据文件
chr 设置染色体所在的列
bp 设置SNP位置所在的列
p 设置Pvalue值所在的列
snp 设置SNP名称所在的列
col 设置不同染色体上点的颜色
chrlabs 设置染色体的标签名
suggestiveline 设置"suggestive"线的阈值,默认为-log10(1e-5)
genomewideline 设置"genome-wide significant"线的阈值,默认为-log10(5e-8)
highlight 高亮感兴趣的SNP位点
logp 设置是否对Pvalue去log10值
annotatePval 注释低于指定p-value阈值的位点
annotateTop 是否只注释低于指定p-value阈值位点中的top hit
默认绘图
manhattan(gwasResults)
调整相关参数
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"))
绘制单条染色体
manhattan(subset(gwasResults, CHR == 1))
高亮感兴趣的SNP位点
head(snpsOfInterest)
## [1] "rs3001" "rs3002" "rs3003" "rs3004" "rs3005" "rs3006"
manhattan(gwasResults, highlight = snpsOfInterest)
只注释低于指定p-value阈值位点中的top hit
manhattan(gwasResults, annotatePval = 0.01, annotateTop=TRUE)
注释低于指定p-value阈值的所有位点
manhattan(gwasResults, annotatePval = 0.005, annotateTop = FALSE)
绘制QQ图
默认绘图
qq(gwasResults$P)
调整参数
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)
sessionInfo()
## R version 3.5.1 (2018-07-02)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: OS X El Capitan 10.11.3
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
##
## locale:
## [1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] qqman_0.1.4
##
## loaded via a namespace (and not attached):
## [1] compiler_3.5.1 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
## [5] tools_3.5.1 htmltools_0.3.6 yaml_2.2.0 Rcpp_0.12.18
## [9] calibrate_1.7.2 stringi_1.2.4 rmarkdown_1.10 knitr_1.20
## [13] stringr_1.3.1 digest_0.6.16 evaluate_0.11