曼哈顿图 CMplot 包的使用

 

001、安装加载包

install.packages("CMplot")
library("CMplot")

 

002、查看测试数据

data(pig60K)    
head(pig60K)

 

003、使用示例数据绘制snp密度图

CMplot(pig60K,plot.type="d",bin.size=1e6,chr.den.col=c("#7CC767", "#088247", "black"),
       file="pdf",file.name="xxxxx",dpi=300,
       main="illumilla_60K",file.output=TRUE,verbose=TRUE,width=9,height=6)

 

004、用自己的数据绘制SNP密度图

dat <- read.table("outcome.map")                               ## 读入map文件
head(dat, 2)
dat <- dat[,c(2,1,4)]

CMplot(dat,plot.type="d",bin.size=1e6,chr.den.col=c("#7CC767", "#088247", "black"),
       file="pdf",file.name="xxxxx",dpi=300,
       main="illumilla_60K",file.output=TRUE,verbose=TRUE,width=9,height=6)       ## 绘图

 

005、绘制环状曼哈顿图

head(pig60K, 3)     ## 使用默认测试数据绘制
CMplot(pig60K,type="p",plot.type="c",chr.labels=paste("Chr",c(1:18,"X","Y"),sep=""),r=0.4,cir.axis=TRUE,
       outward=FALSE,cir.axis.col="black",cir.chr.h=1.3,chr.den.col="black",file="pdf",
       file.name="",dpi=300,file.output=TRUE,verbose=TRUE,width=10,height=10)

 

 006、修改默认数据的环数

head(pig60K, 3)
pig60K <- pig60K[1:5]         ## 去掉了最后一列,即最后一个性状
head(pig60K,3)
CMplot(pig60K,type="p",plot.type="c",chr.labels=paste("Chr",c(1:18,"X","Y"),sep=""),r=0.4,cir.axis=TRUE,
       outward=FALSE,cir.axis.col="black",cir.chr.h=1.3,chr.den.col="black",file="pdf",
       file.name="",dpi=300,file.output=TRUE,verbose=TRUE,width=10,height=10)

 

007、使用自己的数据绘制环状图, 这种图看着有点费劲

fst <- read.table("fst.fst", header = T)          ## 读取数据
options(scipen = 100)                             ## 小数点后100位不适用科学计数法,全局设定
fst$FST <- as.numeric(fst$FST)                    ## 将最后一列的所有的科学计数法转换为数值
fst <- fst[c(2,1,3,4)]                            ## 第一类位snp名称, 第二列为染色体, 第三列位物理位置,第四类为fst值
fst$FST[fst$FST == 0] <- 0.00000001               ## 将第四列的0转换为一个非常小的数值,因为0会报错
CMplot(fst,type="p",plot.type="c",chr.labels=paste("Chr", 1:22, sep=""),r=0.4,cir.axis=TRUE,
       outward=FALSE,cir.axis.col="black",cir.chr.h=1.3,chr.den.col="black",file="pdf",
       file.name="",dpi=300,file.output=TRUE,verbose=TRUE,width=10,height=10)         ## 绘图命令

 

008、矩阵曼哈顿图

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("#7CC767", "#088247", "black"),signal.col=c("#D20A13","#223D6C"),signal.cex=c(1.5,1.5),
       signal.pch=c(19,19),file="jpg",file.name="",dpi=300,file.output=TRUE,verbose=TRUE,
       width=14,height=6)     ## 绘图代码

 

009、用实际数据绘制矩阵曼哈顿图

fst <- read.table("fst.fst", header = T)
fst <- fst[c(2,1,3,4)]
fst$FST[fst$FST == 0] <- 0.00000001
CMplot(fst, 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("#7CC767", "#088247", "black"),signal.col=c("#D20A13","#223D6C"),signal.cex=c(1.5,1.5),
       signal.pch=c(19,19),file="jpg",file.name="",dpi=300,file.output=TRUE,verbose=TRUE,
       width=14,height=6)

 

 

 

 

 

 

 

 

 

 

posted @   小鲨鱼2018  阅读(892)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-05-13 linux 中如何提取最后一列或者最后若干列之外的所有内容
2023-05-13 linux 中 字符串的截取
2023-05-13 linux 中 批量删除文件后缀
2023-05-13 putty 中 设置免密登录远程服务器
2023-05-13 linux 中 查看cpu 信息
2023-05-13 linux 系统中查看总内存、总硬盘、总逻辑CPU数目
2023-05-13 shell中任务递交后修改循环配置文件效果
点击右上角即可分享
微信分享提示