tralala
tralala

Reputation: 113

how to get a nested and overlapping Venn diagram with R?

I would like to get a nice visualization of my data in esthetic way but I struggle with Venn diagram design, I have calculated the overlaps from data frame and now I trying to put it together. all_pep=13584, pep_C=1543, Car=1201, NEM=364 Car&NEM=24 "Car" and "NEM" are subgroup of "pep_C", as well as "all_pep", they share a common part of 24, all of the subgroups belong to "all_pep"

this is what I would like to achieve 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)

This doesn't produce what I want so I tried: 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)

it's also not what i want... Any ideas, please?

Upvotes: 1

Views: 701

Answers (1)

vqf
vqf

Reputation: 2628

You might consider my nVennR package:

> 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)

And the result:

enter image description here

There are other ways to input the data (vignette) and a web interface for up to six sets. The web interface only works with lists of elements.

Upvotes: 1

Related Questions