怎么画出漂亮的曼哈顿图

在生物和统计学上,做频率统计、突变分布、GWAS关联分析的时候,经常会看到一些非常漂亮的manhattan plot,能够对候选位点的分布和数值一目了然。见下图:

1.jpg

怎么样,是不是很好看呢?其实这种图我们也是可以画出来的。

利用R中的 CMplot 就可以绘制出曼哈顿图哦!

具体操作如下:

CMplot 包链接:https://github.com/YinLiLin/R-CMplot

安装并加载CMplot包

install.packages("CMplot")
library(CMplot)
#(optional)if you want to use the latest version:
#source("https://raw.githubusercontent.com/YinLiLin/R-CMplot/master/R/CMplot.r")

加载示例数据

> data(pig60K)   #calculated p-values by MLM
> head(pig60K)

         
SNP Chromosome Position    trait1     trait2     trait3
1 ALGA0000009          1    52297 0.7738187 0.51194318 0.51194318
2 ALGA0000014          1    79763 0.7738187 0.51194318 0.51194318
3 ALGA0000021          1   209568 0.7583016 0.98405289 0.98405289
4 ALGA0000022          1   292758 0.7200305 0.48887140 0.48887140
5 ALGA0000046          1   747831 0.9736840 0.22096836 0.22096836
6 ALGA0000047          1   761957 0.9174565 0.05753712 0.05753712

第一列数据是SNP的名称,第二列是SNP所在染色体,第三列是SNP的位置, 后面几列为不同性状的P值,每种性状单独一列。

CMplot绘图

> CMplot(pig60K, plot.type="m", multracks=TRUE, threshold=c(1e-6,1e-4),threshold.lty=c(1,2),
        threshold.lwd=c(
1,1), threshold.col=c("black","grey"), amplify=TRUE,bin.size=1e6,
        chr.den.col=c(
"darkgreen", "yellow", "red"), signal.col=c("red","green"),signal.cex=c(1,1),
        file=
"jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE)

结果如下:

2.jpg

3.jpg

最后附上CMplot使用方法及常用参数:

CMplot(Pmap, col=c("#377EB8", "#4DAF4A", "#984EA3", "#FF7F00"),
      bin.size=
1e6, bin.max=NULL, pch=19, band=1, cir.band=0.5, H=1.5,
      ylim=
NULL, cex.axis=1, plot.type="b", multracks=FALSE, cex=c(0.5,1,1),
      r=
0.3, xlab="Chromosome", ylab=expression(-log[10](italic(p))), xaxs="i",
      yaxs=
"r", outward=FALSE, threshold = NULL, threshold.col="red",
      threshold.lwd=
1, threshold.lty=2, amplify= TRUE, chr.labels=NULL,
      signal.cex =
1.5, signal.pch = 19, signal.col="red", signal.line=1,
      cir.
chr=TRUE, cir.chr.h=1.5, chr.den.col=c("darkgreen", "yellow", "red")
      , cir.legend=
TRUE, cir.legend.cex=0.6, cir.legend.col="black",
      LOG10=
TRUE, box=FALSE, conf.int.col="grey", file.output=TRUE,
      file=
"jpg", dpi=300, memo="")

常用参数

Pmap    输入数据文件
col 设置不同染色体中点的颜色
cex 设置点的大小
pch 设置点的形状
band    设置不同染色体之间的间隔
H   设置每个圈的高度
ylim    设置y轴的范围
bin.size    设置SNP密度图中的窗口大小
cex.axis    设置坐标轴字体和标签字体的大小
plot.type   设置不同的绘图类型,可以设定为 "d", "c", "m", "q" or "b"
multracks   设置是否需要绘制多个track
r   设置圈的半径大小
xlab    设置x轴标签
ylab    设置y轴标签
outward 设置点的朝向是否向外
threshold   设置阈值并添加阈值线
threshold.col   设置阈值线的颜色
threshold.lwd   设置阈值线的宽度
threshold.lty   设置阈值线的类型
amplify 设置是否放大显著的点
signal.cex   设置显著点的大小
signal.pch   设置显著点的形状
signal.col   设置显著点的颜色
chr.labels   设置染色体的标签
chr.den.col 设置SNP密度图的颜色
cir.band    设置环状曼哈度图中不同染色体之间的间隔
cir.chr 设置是否显示染色体的边界
cir.chr.h   设置染色体边界的高度
cir.legend   设置是否显示图例
cir.legend.cex   设置图例字体的大小
cir.legend.col   设置图例的颜色
LOG10   设置是否对p-valuelog10对数
conf.int.col    设置QQ图中置信区间的颜色
file.output 设置是否输出图片
file    设置输出图片的格式,可以设定为"jpg", "pdf", "tiff"
dpi 设置输出图片的分辨度
memo    设置输出图片文件的名字

CMplot就讲到这了,有兴趣的老师赶快试一下吧!

分享