Remove intersections with size 0 from VennDiagram produced by "Eulerr" in R

161 Views Asked by At

Was trying to draw a proportional VennDiagram in R using package "Eulerr". However, this package produces intersections with size "0" which I want to remove.

Code to reproduce the problem in R

library(eulerr)
gene_list = list("A" = c("a", "b", "c", "d"),
                 "B" = c("a", "b"),
                 "C" = c("d", "e", "f"))
p <- plot(euler(gene_list),
          quantities = list(type = c("counts"), cex=3),
          labels=list(cex=3))
p

The output I got:

enter image description here

but I want is this: enter image description here

This package does what I want when "A" and "C" do not overlap

library(eulerr)
gene_list = list("A" = c("a", "b", "c", "d"),
                 "B" = c("a", "b"),
                 "C" = c("e", "f"))
p <- plot(euler(gene_list),
          quantities = list(type = c("counts"), cex=3),
          labels=list(cex=3))
p

Works when 'A' and 'C' are disjoint:

enter image description here

But I want to remove area with size 0 from the output plots even when "A" and "C" overlap.

1

There are 1 best solutions below

1
asd-tm On

I can offer the following workaround:

 for(i in seq_along(p$children$canvas.grob$children$diagram.grob.1$children$tags$children)){
   o <- p$children$canvas.grob$children$diagram.grob.1$children$tags$children[[paste0("tag.number.", i)]]
   if(!is.null(o)){
     if ( o$children[[paste0("tag.quantity.",i)]]$label == 0){ 
       o$children[[paste0("tag.quantity.",i)]]$label <- " "
       p$children$canvas.grob$children$diagram.grob.1$children$tags$children[[paste0("tag.number.", i)]] <- o
     }
   }
 }
 p

The result (zeroes are suppressed):

enter image description here