大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

如何使用R语言来绘制韦恩图

这篇文章主要介绍“如何使用R语言来绘制韦恩图”,在日常操作中,相信很多人在如何使用R语言来绘制韦恩图问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何使用R语言来绘制韦恩图”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

站在用户的角度思考问题,与客户深入沟通,找到北湖网站设计与北湖网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广、申请域名、网络空间、企业邮箱。业务覆盖北湖地区。

> install.packages("VennDiagram")

> library(VennDiagram)

> A = 1:150

> B = c(121:170,300:320)

> C = c(20:40,141:200)

> Length_A<-length(A)

> Length_B<-length(B)

> Length_C<-length(C)

> Length_AB<-length(intersect(A,B))

> Length_BC<-length(intersect(B,C))

> Length_AC<-length(intersect(A,C))

> Length_ABC<-length(intersect(intersect(A,B),C))

> T<-venn.diagram(list(A=A,B=B),filename=NULL,lwd=1,lty=2, ,col=c('red','green'),fill=c('red','green'),cat.col=c('red','green'),rotation.degree=90)

> grid.draw(T)

如何使用R语言来绘制韦恩图

> T<-venn.diagram(list(A=A,B=B,C=C),filename=NULL,lwd=1,lty=2,col=c('red','green','blue') ,fill=c('red','green','blue'),cat.col=c('red','green','blue'),reverse=TRUE)

> grid.draw(T)

如何使用R语言来绘制韦恩图

>draw.pairwise.venn(area1=Length_A,area2=Length_B,cross.area=Length_AB,category=c('A','B'),lwd=rep(1,1),lty=rep(2,2),col=c('red','green'),fill=c('red','green'),cat.col=c('red','green'),rotation.degree=90)

如何使用R语言来绘制韦恩图

这种方式画的图与第一种方式画出结果一样!接下来利用draw.triple.venn绘制三个集合的韦恩图

> draw.triple.venn(area1=Length_A, area2=Length_B, area3=Length_C,n12=Length_AB, n23=Length_BC, n13=Length_AC, n123=Length_ABC,category = c('A','B','C'),col=c('red','green','blue'),fill=c('red','green','blue'),cat.col=c('red','green','blue')

,reverse = FALSE)

如何使用R语言来绘制韦恩图

傻瓜式代码如下:

> install.packages("VennDiagram")

> library(VennDiagram)

> A <- c("C", "D", "B", "E") #生成三个不同的集合

> B <- c("C", "E", "B", "A")

> C <- c("C", "E", "X", "Y")

> venn.diagram(x=list(Tumor=A, Organoids=B, Primary=C), "My1.png", height = 450, width = 450, resolution =300, imagetype="png", col="white", fill=c(colors()[616], colors()[38], colors()[468]), alpha=c(0.6, 0.6, 0.6), lwd=c(1, 1, 1), cex=0, cat.dist=c(-0.07, -0.07, -0.05), cat.pos=c(300, 60, 180), cat.cex=0.45) #height、width、resolution等的含义参考help()函数即可了解,这里备注下“My 1.png“是图片保存文件名称,倘若不想以文件的形式保存,则filename必须为空,即filename=NULL。

如何使用R语言来绘制韦恩图

> D <- c("C", "D", "B", "E") #生成三个不同的组合

> E <- c("C", "F", "G", "K")

> F <- c("C", "H", "X", "Y")

>venn.diagram(x=list(Tumor=D, Organoids=F,Primary=E), "My2.png", height = 450, width = 450, resolution =300, imagetype="png", col="gray",fill=c(colors()[148], colors()[589], colors()[116]), alpha=c(0.6, 0.6, 0.6), lwd=0.5, cex=0, cat.dist=c(-0.07, -0.07, -0.05), cat.pos=c(100, 260, 0),cat.cex=0.45, cat.col="black", rotation.degree=180)

如何使用R语言来绘制韦恩图

> A<- sample(1:1000, 400, replace = FALSE) #生成四个不同的组合

> B<- sample(1:1000, 600, replace = FALSE)

> C<- sample(1:1000, 350, replace = FALSE)

> D<- sample(1:1000, 550, replace = FALSE)

> venn.diagram(x= list(A = A,D = D,B = B,C = C), filename = "My3.png", height = 450, width = 450,resolution =300, imagetype="png", col ="transparent", fill =c("cornflowerblue","green","yellow","darkorchid1"),alpha = 0.5, label.col = c("orange", "white","darkorchid4", "white", "white", "white",    "white", "white","darkblue", "white", "white", "white","white", "darkgreen", "white"), cex = 0.45,fontfamily = "serif", fontface = "bold",cat.col =c("darkblue", "darkgreen", "orange","darkorchid4"), cat.cex = 0.45,cat.pos = 0, cat.dist = 0.07,cat.fontfamily = "serif", rotation.degree = 270)

如何使用R语言来绘制韦恩图

> A<- sample(LETTERS, 18, replace = FALSE)

> B<- sample(LETTERS, 20, replace = FALSE)

> C<- sample(LETTERS, 22, replace = FALSE)

> D<- sample(LETTERS, 19, replace = FALSE)

> venn.diagram(x= list(A = A,D = D,B = B,C = C), filename = "My4.png", height = 450, width = 450,resolution =300, imagetype="png", col="transparent",fill=c("cornflowerblue","green","yellow","darkorchid1"),alpha = 0.50, cex=0.45, cat.cex=0.45)

如何使用R语言来绘制韦恩图

> venn.diagram(x =list(A = A,D = D,B = B,C = C), filename = "My5.png", height = 450, width= 450, resolution =300, imagetype="png", lwd=0.6, fill =c("cornflowerblue","green","yellow","darkorchid1"),cex=0.45, cat.cex=0.45)

如何使用R语言来绘制韦恩图

当然韦恩图会画,最重要的还是要会分析!

到此,关于“如何使用R语言来绘制韦恩图”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


新闻名称:如何使用R语言来绘制韦恩图
网页网址:http://dzwzjz.com/article/pjgpps.html
在线咨询
服务热线
服务热线:028-86922220
TOP