首页 > 解决方案 > 如何使用 R 获得嵌套和重叠的维恩图?

问题描述

我想以美学的方式对我的数据进行很好的可视化,但我在维恩图设计方面遇到了困难,我已经计算了数据框的重叠,现在我试图将它们放在一起。all_pep=13584, pep_C=1543, Car=1201, NEM=364 Car&NEM=24 "Car" 和 "NEM" 是 "pep_C" 和 "all_pep" 的子组,它们共享 24 的公共部分,所有的子组属于“all_pep”

这就是我想要实现的 https://filebin.net/x5a5a695jp0dy68q

library(grid)
library(futile.logger)
library(VennDiagram)

draw.quad.venn(area1=13584, area2=1543, area3=1201, area4=364,     n12=1543, n13=1201, n14=364, n23=1201, n24=364,
           n34=24, n123=1201, n124=364, n134=24, n234=24, n1234=24, category = rep("",
          4), lwd = rep(2, 4), lty = rep("solid", 4), col =
             rep("black", 4), fill = NULL, alpha = rep(0.5, 4),
           label.col = rep("black", 15), cex = rep(1, 15),
           fontface = rep("plain", 15), fontfamily = rep("serif",
            15), cat.pos = c(-15, 15, 0, 0), cat.dist = c(0.22,
            0.22, 0.11, 0.11), cat.col = rep("black", 4), cat.cex
           = rep(1, 4), cat.fontface = rep("plain", 4),
           cat.fontfamily = rep("serif", 4), cat.just =
             rep(list(c(0.5, 0.5)), 4), rotation.degree = 0,
           rotation.centre = c(0.5, 0.5), ind = TRUE, cex.prop =
             NULL, print.mode = "raw", sigdigs = 3, direct.area =
             FALSE, area.vector = 0)

这不会产生我想要的,所以我尝试了: require(venneuler)

v <- venneuler(c(all_pep=13584, pep_C=1543, Car=1201, NEM=364, "all_pep&pep_C"=1543, "all_pep&Car"=1201, "all_pep_NEM"=364, "pep_C$Car"=1201, "pep_C&NEM"=364,
"Car&NEM"=24, "all_pep&pep_C&Car"=1201, "all_pep&pep_C&NEM"=364,     "all_pep&Car&NEM"=24, "pep_C&Car&NEM"=24, "all_pep&pep_C&Car&NEM"=24))

plot(v)

这也不是我想要的...有什么想法吗?

标签: rvenn-diagram

解决方案


你可以考虑我的nVennR包裹:

> library(nVennR)
> myV <- createVennObj(nSets = 4, sNames = c('all_pep', 'pep_C', 'Car', 'NEM'))
> myV <- setVennRegion(myV, c('all_pep'), 13584)
> myV <- setVennRegion(myV, c('all_pep', 'pep_C'), 1543)
> myV <- setVennRegion(myV, c('all_pep', 'pep_C', 'Car'), 1201)
> myV <- setVennRegion(myV, c('all_pep', 'pep_C', 'NEM'), 364)
> myV <- setVennRegion(myV, c('all_pep', 'pep_C', 'Car', 'NEM'), 24)
> myV <- plotVenn(nVennObj = myV)

结果:

在此处输入图像描述

还有其他输入数据的方法(小插图)和最多六组的Web 界面。Web 界面仅适用于元素列表。


推荐阅读