4-way Venn diagram in R?

I am trying to make a 4-Way Venn Diagram in R. I have this data that I want to put in a diagram:

enter image description here

Can someone give me a suggestion on how to do this? I am trying to use the vennDiagram () function, but this does not work because it is a 4way diagram.

I am also trying to use the VennDiagram package, but actually confuse how the data is "distributed" to the right place on the diagram. I am using this code:

library (VennDiagram)
venn.diagram(
    x=list(
    I=c(1:18,19:31,32:119,125:129,130:192,193:144,145:326,327:373),
    VI=c(516:542,510:515,420:497,498:509,145:326,327:373,130:192,193:144),
    II=c(19:31,32:119,145:326,327:373,374:378,378:419,420:497,498:509),
    III=c(506:509,378:419,32:119,125:129,130:192,145:326,420:497,510:515)
    ),
    filename = "4Way_Venn.tiff",
    col = "black",
    lty = "dotted",
    lwd = 4,
    fill = c("cornflowerblue", "green", "yellow", "darkorchid1"),
    alpha = 0.50,
    label.col = c("orange", "white", "darkorchid4", "white", "white", "white", 
                  "white", "white", "darkblue", "white", "white", "white", 
                  "white", "darkgreen", "white"),
    cex = 2.5,
    fontfamily = "serif",
    fontface = "bold",
    cat.col = c("darkblue", "darkgreen", "orange", "darkorchid4"),
    cat.cex = 2.5,
    cat.fontfamily = "serif"
    );

Can anyone help me? perhaps with a simpler solution than the one that uses the VennDiagram package.

+3
source share
4 answers

, , "" venn? c1 '' c4 ' venn, venneuler package:

require(venneuler)
#here I replicate your data
#because it repeatable, you can use `rep` function to generate it
c1 <- rep(c(0,1),each=8)
c2 <- rep(c(0,1),each=4,times=2)
c3 <- rep(c(0,1),each=2,times=4)
c4 <- rep(c(0,1),times=8)
#put your data into matrix
m <- as.matrix(data.frame(C1=c1,C2=c2,C3=c3,C4=c4))
#plot it
v = venneuler(m)
plot(v)

enter image description here

+3

: 4 ( ) Venn , ​​, , , . , , , , . , , .
, : venneuler, GOA, require(sos); ???venn , , .

+3
0

nVennR (0.2.0) :

1) , ,

myV <- plotVenn(list(I=c(1:18,19:31,32:119,125:129,130:192,193:144,145:326,327:373), 
IV=c(516:542,510:515,420:497,498:509,145:326,327:373,130:192,193:144), 
II=c(19:31,32:119,145:326,327:373,374:378,378:419,420:497,498:509), 
III=c(506:509,378:419,32:119,125:129,130:192,145:326,420:497,510:515)),
setColors = c("cornflowerblue", "green", "yellow", "darkorchid1"), borderWidth=3, opacity=0.2)

Result

2)

myV2 <- createVennObj(nSets = 4, sNames = c("c1", "c2", "c3", "c4"), sSizes = c(26, 27, 4, 6, 5, 12, 42, 78, 18, 52, 4, 63, 13, 47, 88, 182))
myV2 <- plotVenn(nVennObj = myV2)

Result2

One of the advantages of the first approach is that elements in each area can be requested:

getVennRegion(myV, c("I", "III"))
[1] 125 126 127 128 129
0
source

All Articles