R语言 产生3向Venn,其中较大的圆圈代表样本量的其余部分

v09wglhw  于 2023-05-04  发布在  其他
关注(0)|答案(1)|浏览(164)

我想创建一个3路维恩图和一个更大的圆圈后面代表样本量。
双向文氏图示例,其中较大的圆圈表示样本量:

library("VennDiagram")

grid.newpage()
venn_AB <- draw.triple.venn(area1=count_A, area2=count_B, area3=count_sample, n12 = count_AB, 
                                  n23 =count_B, n13 =count_A, n123=count_AB,
                                  category=c("A",
                                             "B",
                                             "Sample Size"),
                                  col="Purple",fill=c("Red","Blue", "Yellow"), lty = "dashed", print.mode = c('raw', 'percent'))

维恩图(AB)

然而,当我将相同的技术应用于三向维恩图时:

grid.newpage()
venn_ABC = draw.quad.venn(area1=count_A, area2=count_B, area3=count_C, 
                               area4 =count_sample, n12=count_AB, n23=count_BC, n13=count_AC, 
                               n14= count_A,n24=count_B, n34=count_C, n123=count_ABC, 
                               n124=count_AB, n234=count_BC, n134=count_AC, n1234=count_ABC, 
                               category=c("A",
                                          "B",
                                          "C",
                                          "Sample size"),
                               col="Purple",fill=c("Red","Blue","Orange","Yellow"),lty="dashed",print.mode = c('raw', 'percent'))

维恩图

我得到一个四向叶图。
预期文氏图

有没有办法在R中产生预期的结果?

tmb3ates

tmb3ates1#

任何广义维恩图生成器都应该这样做,即使结果在美学上不是很令人愉快。技巧是添加一个集合,该集合是其他集合的并集。例如,您可以尝试在eulerr中执行此操作。使用我自己的nVennR包(https://github.com/vqf/nVennR),您可以执行以下操作:

> library(nVennR)
> setall <- c(1, 2, 3, 5, 6, 7, 8, 9, 10, 'r', 's', 't')
> seta <- c(1, 2, 3, 5, 6)
> setb <- c(1, 7, 8, 9)
> setc <- c(2, 5, 9, 10)
> myV <- plotVenn(list(A=seta, B=setb, C=setc, U=setall), setColors=c('red', 'green', 'blue', 'grey'), opacity=0.4)

结果,

灰色的集合是宇宙,下面的圆圈表示不在集合a,B或c中的元素(在示例中,'r','s'和't ')。

相关问题