我想按比例绘制>50个两组的Venn/Euler图。不仅两个集合的重叠和集合大小本身应该缩放,而且相互比较的各个图的大小也是必要的。
因为我不知道R包允许同时绘制>50个成对的维恩图,所以我计划首先单独绘制它们(例如,使用eulerr),然后使用gridExtra包或类似的工具将它们放在一起。
然而,在这种情况下,各个成对图的大小是不可比较的:
require(gridExtra)
require(eulerr)
fit1 <- euler(c(A=300, B=500, "A&B"=100))
fit2 <- euler(c(A=40, B=70, "A&B"=30))
grid.arrange(plot(fit1), plot(fit2), nrow=1)有没有人知道一个R包或一个包的组合,它可以根据大小绘制几个成对的Venn图?
发布于 2019-01-16 01:22:21
您可以尝试使用grid.arrange的widths参数。您必须确定每个维恩图的总数的比率。在您的示例中,总大小比率为800:110,即7.27,因此如果使用grid.arrange(plot(fit1), plot(fit2), ncol = 2, widths = c(7.27, 1)),则fit2将比fit1小得多。来自ggpubr的ggarrange()函数也应该可以工作。
fit1 <- euler(c(A=300, B=500, "A&B"=100))
fit2 <- euler(c(A=40, B=70, "A&B"=30))
tot1 <- 800
tot2 <- 110
ratio_v <- tot1/tot2
grid.arrange(plot(fit1), plot(fit2), ncol = 2, widths = c(ratio_v, 1))
ggpubr:ggarrange(plotlist = list(plot(fit1), plot(fit2)), ncol = 2, widths = c(ratio_v, 1))

编辑:希望单个成对集具有自己的大小比率,而不是相对于全局最大值的所有内容。这是一个简单的示例,但是您可以编写一个函数来自动为每个示例执行此操作。基本上设置最大列数(我刚刚选择了100),然后将每个比率转换为100。为每个维恩图集创建一行,然后将它们全部rbind到一个矩阵中,并使用layout_matrix参数。
### Make fits
fit1 <- euler(c(A=300, B=500, "A&B"=100))
fit2 <- euler(c(A=40, B=70, "A&B"=30))
fit3 <- euler(c(C=100, D=300, "C&D"=50))
fit4 <- euler(c(C=50, D=80, "C&D"=30))
### Assign totals
tot1 <- 800
tot2 <- 110
tot3 <- 400
tot4 <- 130
### Find ratios
ratioAB_v <- round(tot1/tot2)
ratioCD_v <- round(tot3/tot4)
### Convert ratios
smallAB_v <- round(1/ratioAB_v*100)
smallCD_v <- round(1/ratioCD_v*100)
### Make rows
row1_v <- c(rep(1, (100-smallAB_v)), rep(2, smallAB_v))
row2_v <- c(rep(3, (100-smallCD_v)), rep(4, smallCD_v))
### Make matrix
mat <- rbind(row1_v, row2_v)
### Plot
grid.arrange(plot(fit1), plot(fit2), plot(fit3), plot(fit4), layout_matrix = mat)

https://stackoverflow.com/questions/54202458
复制相似问题