Search code examples
rmatrixvectorvenn-diagramsignificance

How to do R Vennerable Venn Diagram from Binary Matrices?


Inspection of the basic examples shows that the Vennerable input must a list of vectors here. So I do the following where I take there binary p-value matrices, and try to create a Venn diagram based on their common characteristics

library("Vennerable")
library('limma') # vennCounts, vennDiagram
library("psych")

ids <- seq(1,11)
M.cor <- cor(mtcars)
colnames(M.cor) <- ids
rownames(M.cor) <- ids

p.mat <- psych::corr.test(M.cor, adjust = "none", ci = F)

alpha <- 0.000000005

lista <- list(
  as.vector(p.mat[["p"]] < alpha), 
  as.vector(p.mat[["r"]] < alpha),
  as.vector(p.mat[["t"]] < alpha)
  )
# List of 3 vectors    

Vstem <- Venn(lista)

plot(Vstem, doWeights = TRUE, type = "circles")

Fig. 1 Output wrong

enter image description here

Expected output: Vennerable Venn diagram of three circles

STOUT

List of 3
 $ : logi [1:121] TRUE TRUE TRUE FALSE FALSE FALSE ...
 $ : logi [1:121] FALSE TRUE TRUE TRUE FALSE TRUE ...
 $ : logi [1:121] FALSE TRUE TRUE TRUE FALSE TRUE ...
Formal class 'Venn' [package "Vennerable"] with 2 slots
  ..@ IndicatorWeight : int [1:8, 1:4] 0 1 0 1 0 1 0 1 0 0 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:8] "000" "100" "010" "110" ...
  .. .. ..$ : chr [1:4] "1" "2" "3" ".Weight"
  ..@ IntersectionSets:List of 8
  .. ..$ 000: NULL
  .. ..$ 100: NULL
  .. ..$ 010: NULL
  .. ..$ 110: NULL
  .. ..$ 001: NULL
  .. ..$ 101: NULL
  .. ..$ 011: NULL
  .. ..$ 111: logi [1:2] TRUE FALSE

R: 3.3.1
OS: Debian 8.5


Solution

  • user20650's answer in comment

    lista <- list(
      which(p.mat[["p"]] < alpha), #as.vector(p.mat[["p"]] < alpha), 
      which(p.mat[["r"]] < alpha), #as.vector(p.mat[["r"]] < alpha),
      which(p.mat[["t"]] < alpha) #as.vector(p.mat[["t"]] < alpha)
      )
    

    Output

    enter image description here

    Ticket: #39 and #40