> install.packages('VennDiagram') > library(VennDiagram) > A = 1:150 > B = c(121:170,300:320) > C = c(20:40,141:200) > Length_A<> > Length_B<> > Length_C<> > Length_AB<> > Length_BC<> > Length_AC<> > Length_ABC<> > T<-venn.diagram(list(a=a,b=b),filename=null,lwd=1,lty=2, ,col="">-venn.diagram(list(a=a,b=b),filename=null,lwd=1,lty=2,> > grid.draw(T) > T<> > grid.draw(T) >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) 这种方式画的图与第一种方式画出结果一样!接下来利用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) 傻瓜式代码如下: > install.packages('VennDiagram') > library(VennDiagram) > A <- c('c',="" 'd',="" 'b',="" 'e')="">-> > B <- c('c',="" 'e',="" 'b',="">-> > C <- c('c',="" 'e',="" 'x',="">-> > 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。 > D <- c('c',="" 'd',="" 'b',="" 'e')="">-> > E <- c('c',="" 'f',="" 'g',="">-> > F <- c('c',="" 'h',="" 'x',="">-> >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) > A<- sample(1:1000,="" 400,="" replace="FALSE)">-> > B<- sample(1:1000,="" 600,="" replace="">-> > C<- sample(1:1000,="" 350,="" replace="">-> > D<- sample(1:1000,="" 550,="" replace="">-> > 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) > A<- sample(letters,="" 18,="" replace="">-> > B<- sample(letters,="" 20,="" replace="">-> > C<- sample(letters,="" 22,="" replace="">-> > D<- sample(letters,="" 19,="" replace="">-> > 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) > 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) 当然韦恩图会画,最重要的还是要会分析! |
|