曼哈顿图 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 @ 2024-05-13 09:59  小鲨鱼2018  阅读(178)  评论(0编辑  收藏  举报