评论

收藏

[R语言] R语言绘制弦状图

编程语言 编程语言 发布于:2021-06-29 22:08 | 阅读数:545 | 评论:0

  
1.数据
DSC0000.png


2.程序代码
library(statnet)
library(circlize)
data<-read.csv("Bacteria otu.csv",header = T,row=1)
my.data<-as.matrix(data)
row.names(my.data)<-c("A1","B1","C1","D1")
colnames<-c("Proteobacteria","Actinobacteria","Bacteroidetes","Cyanobacteria","Firmicutes","Planctomycetes","Verrucomicrobia","Chloroflexi","Chlorobi","Thermomicrobia","Others")
grid.col=NULL
grid.col[c("A1","B1","C1","D1")]=c("blue","black","orenge","chocolate")
grid.col[colnames(my.data)]=c("lavender","khaki","mistyrose","siennal","skyblue","brownl","gold","maroon","scalmon","moccasin","wheat")
circos.par(gap.degree=c(rep(2,nrow(my.data)-1),10,rep(2,ncol(my.data)-1),10),start.degree=180)
chordDiagram(my.data,directional=TRUE,diffHeight=0.06,grid.col=grid.col,transparency=0.5)
legend("right",pch = 20,legend = colname(my.data),col = grid.col[colnames(my.data)],bty = "n",cex=1,pt.cex=3,border="black")
pdf(file="circlize.pdf",width=8,height=5,pointsize=8)
chordDiagram(my.data,directional=TRUE,diffHeight=0.06,grid.col=grid.col,transparency=0.5)
legend("right",pch=20,legend=colnames(my.data),col=grid.col[colnames(my.data)],bty="n",cex=1,pt.cex=3,border="black")
  3.图形效果
DSC0001.png


  
关注下面的标签,发现更多相似文章