R包 CMplot

官网链接
https://github.com/YinLiLin/CMplot

A high-quality drawing tool designed for Manhattan plot of genomic analysis

Installation

CMplot is available on CRAN, so it can be installed with the following R code:

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

There are two example datasets attached in CMplot, users can export and view the details by following R code:

> data(pig60K)   #calculated p-values by MLM
> data(cattle50K)   #calculated SNP effects by rrblup
> 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> head(cattle50K)SNP chr    pos Somatic cell score  Milk yield Fat percentage
1 SNP1   1  59082        0.000244361 0.000484255    0.001379210
2 SNP2   1 118164        0.000532272 0.000039800    0.000598951
3 SNP3   1 177246        0.001633058 0.000311645    0.000279427
4 SNP4   1 236328        0.001412865 0.000909370    0.001040161
5 SNP5   1 295410        0.000090700 0.002202973    0.000351394
6 SNP6   1 354493        0.000110681 0.000342628    0.000105792

As the example datasets, the first three columns are names, chromosome, position of SNPs respectively, the rest of columns are the pvalues of GWAS or effects of GS/GP for traits, the number of traits is unlimited.
Note: if plotting SNP_Density, only the first three columns are needed.

Now CMplot could handle not only Genome-wide association study results, but also SNP effects, Fst, tajima’s D and so on.


Total 50~ parameters are available in CMplot, typing ?CMplotcan get the detail function of all parameters.


Citation

Please cite the website https://github.com/YinLiLin/R-CMplot


SNP-density plot

> CMplot(pig60K,type="p",plot.type="d",bin.size=1e6,chr.den.col=c("darkgreen", "yellow", "red"),file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=9,height=6)
# users can personally set the windowsize and the min/max of legend by:
# bin.size=1e6
# bin.range=c(min, max)
# memo: add a character to the output file name
# chr.labels: change the chromosome names


Circular-Manhattan plot

(1) Genome-wide association study(GWAS)

> CMplot(pig60K,type="p",plot.type="c",chr.labels=paste("Chr",c(1:18,"X","Y"),sep=""),r=0.4,cir.legend=TRUE,outward=FALSE,cir.legend.col="black",cir.chr.h=1.3,chr.den.col="black",file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=10,height=10)

> CMplot(pig60K,type="p",plot.type="c",r=0.4,col=c("grey30","grey60"),chr.labels=paste("Chr",c(1:18,"X","Y"),sep=""),threshold=c(1e-6,1e-4),cir.chr.h=1.5,amplify=TRUE,threshold.lty=c(1,2),threshold.col=c("red","blue"),signal.line=1,signal.col=c("red","green"),chr.den.col=c("darkgreen","yellow","red"),bin.size=1e6,outward=FALSE,file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=10,height=10)#Note:
1. if signal.line=NULL, the lines that crosse circles won't be added.
2. if the length of parameter 'chr.den.col' is not equal to 1, SNP density that counts the number of SNP within given size('bin.size') will be plotted around the circle.

(2) Genomic Selection/Prediction(GS/GP)

> CMplot(cattle50K,type="p",plot.type="c",LOG10=FALSE,outward=TRUE,col=matrix(c("#4DAF4A",NA,NA,"dodgerblue4","deepskyblue",NA,"dodgerblue1", "olivedrab3", "darkgoldenrod1"), nrow=3, byrow=TRUE),chr.labels=paste("Chr",c(1:29),sep=""),threshold=NULL,r=1.2,cir.chr.h=1.5,cir.legend.cex=0.5,cir.band=1,file="jpg", memo="",dpi=300,chr.den.col="black",file.output=TRUE,verbose=TRUE,width=10,height=10)#Note: parameter 'col' can be either vector or matrix, if a matrix, each trait can be plotted in different colors.


Single_track Rectangular-Manhattan plot

Genome-wide association study(GWAS)

> CMplot(pig60K,type="p",plot.type="m",LOG10=TRUE,threshold=NULL,file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6,chr.labels.angle=45)
# 'chr.labels.angle': adjust the angle of labels of x-axis (-90 < chr.labels.angle < 90).

Amplify signals on pch, cex and col

> CMplot(pig60K, plot.type="m", col=c("grey30","grey60"), LOG10=TRUE, ylim=c(2,12), threshold=c(1e-6,1e-4),threshold.lty=c(1,2), threshold.lwd=c(1,1), threshold.col=c("black","grey"), amplify=TRUE,chr.den.col=NULL, signal.col=c("red","green"), signal.cex=c(1.5,1.5),signal.pch=c(19,19),file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6)#Note: if the ylim is setted, then CMplot will only plot the points among this interval,
#       ylim can be vector or list, if it is a list, different traits can be assigned with
#       different range at y-axis.

Attach chromosome density on the bottom of Manhattan plot

> CMplot(pig60K, plot.type="m", LOG10=TRUE, ylim=NULL, 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.5,1.5),signal.pch=c(19,19),file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6)#Note: if the length of parameter 'chr.den.col' is bigger than 1, SNP density that counts the number of SNP within given size('bin.size') will be plotted.

Highlight a group of SNPs on pch, cex, type, and col

> signal <- pig60K$Position[which.min(pig60K$trait2)]
> SNPs <- pig60K$SNP[pig60K$Chromosome==13 & pig60K$Position<(signal+1000000)&pig60K$Position>(signal-1000000)]
> CMplot(pig60K, plot.type="m",LOG10=TRUE,col=c("grey30","grey60"),highlight=SNPs,highlight.col="green",highlight.cex=1,highlight.pch=19,file="jpg",memo="",chr.border=TRUE,dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6)
#Note:
'highlight' could be vector or list, if it is a vector, all traits will use the same highlighted SNPs index,
if it is a list, the length of the list should equal to the number of traits.
highlight.col, highlight.cex, highlight.pch can be value or vector, if its length equals to the length of highlighted SNPs,
each SNPs have its special colour, size and shape.

> SNPs <-  pig60K[pig60K$trait2 < 1e-4, 1]
> CMplot(pig60K,type="h",plot.type="m",LOG10=TRUE,highlight=SNPs,highlight.type="p",highlight.col=NULL,highlight.cex=1.2,highlight.pch=19,file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6,band=0.6)

> SNPs <-  pig60K[pig60K$trait2 < 1e-4, 1]
> CMplot(pig60K,type="p",plot.type="m",LOG10=TRUE,highlight=SNPs,highlight.type="h",col=c("grey30","grey60"),highlight.col="darkgreen",highlight.cex=1.2,highlight.pch=19,file="jpg",dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6)

Visualize only one chromosome

> CMplot(pig60K[pig60K$Chromosome==13, ], plot.type="m",LOG10=TRUE,col=c("grey60"),highlight=SNPs,highlight.col="green",highlight.cex=1,highlight.pch=19,file="jpg",memo="", threshold=c(1e-6,1e-4),threshold.lty=c(1,2),threshold.lwd=c(1,2), width=9,height=6,threshold.col=c("red","blue"),amplify=FALSE,dpi=300,file.output=TRUE,verbose=TRUE)

add genes or SNP names around the highlighted SNPs

> SNPs <- pig60K[pig60K[,5] < (0.05 / nrow(pig60K)), 1]
> genes <- paste("GENE", 1:length(SNPs), sep="_")
> set.seed(666666)
> CMplot(pig60K[,c(1:3,5)], plot.type="m",LOG10=TRUE,col=c("grey30","grey60"),highlight=SNPs,highlight.col=c("red","blue","green"),highlight.cex=1,highlight.pch=c(15:17), highlight.text=genes,      highlight.text.col=c("red","blue","green"),threshold=0.05/nrow(pig60K),threshold.lty=2,   amplify=FALSE,file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,width=14,height=6)
#Note:
'highlight', 'highlight.text', 'highlight.text.xadj', 'highlight.text.yadj' could be vector or list, if it is a vector,
all traits will use the same highlighted SNPs index and text, if it is a list, the length of the list should equal to the number of traits.
the order of 'highlight.text' must be consistent with 'highlight'
highlight.text.cex: value or vecter, control the size of added text
highlight.text.font: value or vecter, control the font of added text
highlight.text.xadj: value or vecter or list for multiple traits, -1, 0, 1 limited, control the position of text around the highlighted SNPs,-1(left), 0(center), 1(right)
highlight.text.yadj: value or vector or list for multiple traits, same as above, -1(down), 0(center), 1(up)

Genomic Selection/Prediction(GS/GP) or other none p-values

> CMplot(cattle50K, plot.type="m", band=0.5, LOG10=FALSE, ylab="SNP effect",threshold=0.015,threshold.lty=2, threshold.lwd=1, threshold.col="red", amplify=TRUE, width=14,height=6,signal.col=NULL, chr.den.col=NULL, file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,cex=0.8)
#Note: if signal.col=NULL, the significant SNPs will be plotted with original colors.

> cattle50K[,4:ncol(cattle50K)] <- apply(cattle50K[,4:ncol(cattle50K)], 2, function(x) x*sample(c(1,-1), length(x), rep=TRUE))
> CMplot(cattle50K, type="h",plot.type="m", band=0.5, LOG10=FALSE, ylab="SNP effect",ylim=c(-0.02,0.02),threshold.lty=2, threshold.lwd=1, threshold.col="red", amplify=FALSE,cex=0.6,chr.den.col=NULL, file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE)#Note: Positive and negative values are acceptable.

Multi_tracks Rectangular-Manhattan plot

SNPs <- list(pig60K$SNP[pig60K$trait1<1e-6],pig60K$SNP[pig60K$trait2<1e-6],pig60K$SNP[pig60K$trait3<1e-6]
)
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","blue"),signal.cex=1, file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,highlight=SNPs, highlight.text=SNPs, highlight.text.cex=1.4)
#Note: if you are not supposed to change the color of signal, please set signal.col=NULL and highlight.col=NULL.

a. all traits in one axes:

b. all traits in separated axes:


Single_track Q-Q plot

> CMplot(pig60K,plot.type="q",box=FALSE,file="jpg",memo="",dpi=300,conf.int=TRUE,conf.int.col=NULL,threshold.col="red",threshold.lty=2,file.output=TRUE,verbose=TRUE,width=5,height=5)

Multi_tracks Q-Q plot

> pig60K$trait1[sample(1:nrow(pig60K), round(nrow(pig60K)*0.80))] <- NA
> pig60K$trait2[sample(1:nrow(pig60K), round(nrow(pig60K)*0.25))] <- NA
> CMplot(pig60K,plot.type="q",col=c("dodgerblue1", "olivedrab3", "darkgoldenrod1"),threshold=1e-6,ylab.pos=2,signal.pch=c(19,6,4),signal.cex=1.2,signal.col="red",conf.int=TRUE,box=FALSE,multracks=TRUE,cex.axis=2,file="jpg",memo="",dpi=300,file.output=TRUE,verbose=TRUE,ylim=c(0,8),width=5,height=5)

a. all traits in a axes:

b. all traits in separated axes:


GWAS相关的曼哈顿图-SNP密度图相关推荐

  1. Py之seaborn:数据可视化seaborn库(二)的组合图可视化之密度图/核密度图分布可视化、箱型图/散点图、小提琴图/散点图组合可视化的简介、使用方法之最强攻略(建议收藏)

    Py之seaborn:数据可视化seaborn库(二)的组合图可视化之密度图/核密度图分布可视化.箱型图/散点图.小提琴图/散点图组合可视化的简介.使用方法之最强攻略(建议收藏) 目录 二.组合图可视 ...

  2. Py之matplotlibseaborn :matplotlibseaborn绘图的高级进阶之高级图可视化(基础图(直方图等),箱线图、密度图、小提琴图等)简介、案例应用之详细攻略

    Py之matplotlib&seaborn :matplotlib&seaborn绘图的高级进阶之高级图可视化(基础图(直方图等),箱线图.密度图.小提琴图等)简介.案例应用之详细攻略 ...

  3. 数据为北太平洋柔鱼两年(1,2)的生物学采样数据,根据此数据完成 (1) 按年描述柔鱼的体重和胴长数据(如均值,方差,级差,分位数等),并进行绘 制(如直方图、箱线图,密度图等)。

    三.数据为北太平洋柔鱼两年(1,2)的生物学采样数据,根据此数据完成 (1) 按年描述柔鱼的体重和胴长数据(如均值,方差,级差,分位数等),并进行绘 制(如直方图.箱线图,密度图等). library ...

  4. 如何用Seaborn描绘线图,分面网格关联图,密度图,连接图,热力图,线性回归图,分面网格绘图

    事前准备请看之前的文章0o0! 线图 data = {'apple':[4,0,7,8],'orange':[3,5,6,7],'bananas':[6,4,5,3] } df = pd.DataFr ...

  5. Py之seaborn:数据可视化seaborn库(三)的矩阵图可视化之jointplot/JointGrid/pairplot/PairGrid/FacetGrid密度图等的函数源代码详解之最强攻略

    Py之seaborn:数据可视化seaborn库(三)的矩阵图可视化之jointplot/JointGrid/pairplot/PairGrid/FacetGrid折线图/柱状图+散点图/矩形密度图的 ...

  6. seaborn分布数据可视化:直方图|密度图|散点图

    系统自带的数据表格(存放在github上https://github.com/mwaskom/seaborn-data),使用时通过sns.load_dataset('表名称')即可,结果为一个Dat ...

  7. 密集人群计数 密度图回归 原理

    密集人群计数,现在大家都使用密度图(density map)来进行预测人数: 发现这篇简书文章对于密度图的原理讲解的比较详细,故搬来学习: https://www.jianshu.com/p/a100 ...

  8. 在R中对李克特量表(likert)数据进行可视化描述性统计分析,热力图、密度图、柱状图

    在R中对李克特量表带数据进行可视化描述性统计分析 李克特量表是一种常用的社会调查问卷模式.常规论文中对多级的李克特量表数据大多计算均值来进行描述性统计分析,但均值较难表现样本整体分布状况,R中like ...

  9. 如何用Seaborn描绘柱状图(条形图),箱线图,小提琴图,分类散点图,分面网格分类图,散点图(3)

    柱状图 x = ['金融','农业','制造业','新能源'] y = [163,86,125,58] sns.barplot(x,y) y = ['金融','农业','制造业','新能源'] x = ...

  10. 小提琴统计图_箱形图和小提琴图

    箱形图(Box-plot) 又称为盒须图.盒式图或箱线图,是一种用作显示一组数据分散情况资料的统计图,因形状如箱子而得名.它能显示出一组数据的最大值.最小值.中位数.及上下四分位数. 箱形图绘制须使用 ...

最新文章

  1. linux检查邮件命令,Linux:mail的邮件收发及查看
  2. jvm性能调优实战 - 27亿级数据量的实时分析引擎,为啥频繁发生Full GC
  3. Nginx+Tomcat负载均衡访问网页出现报错HTTP Status 400 – 错误的请求
  4. keil5函数 默认返回值_Python中如何调用random()函数
  5. java当中递归打印目录树
  6. linux构建基于mac的vlan,通过CLI配置交换机的基于MAC的VLAN组
  7. 在过去的12个月(2016)里,你用到的最多的算法或方法是什么?
  8. 员工管理系统————员工修改模块
  9. 340-写一个银行转账死锁问题并且解决
  10. 国密(2)-- SM2签名和加密算法介绍
  11. windows server2012 r2修改密码
  12. securecrt 远程映射端口
  13. T-SQL - 习题02_将数据表year|month|amount查询成year|m1|m2|m3|m4的样式
  14. 更改电脑用户名(可更改C:\Users\用户名)
  15. 深度学习FPGA实现基础知识17(图像处理卷积运算 矩阵卷积)
  16. 《网站分析实战--如何以数据驱动决策,提升网站价值》学习笔记
  17. 如何让我们的人生,拥有更多的可能性?
  18. 购买阿里云服务器后怎么用?针对新手的阿里云服务器教程
  19. 双机热备与负载均衡区别
  20. OtoStudio可视化界面开发示例

热门文章

  1. 优动漫PAINT拾色器功能介绍
  2. 十分钟带你解读Effective C++(导读)
  3. 移位运算(无符号移位运算,有符号移位运算)
  4. 使用matlab在图片上画框,并保存
  5. 做了5年研发效能度量,我的6点思考
  6. Exchange2013中POP3和IMAP4
  7. 《类》《this指针》《构造函数》《析构函数》《拷贝构造函数》《赋值运算符重载》
  8. c++哈利波特游戏(流行的版本的破解版)
  9. 搭建并实现智能DNS
  10. Java成员变量调用方法赋值问题