'R: Extra-space in label position. gplots - VennDiagram - venn.diagramm()

I'm facing this little layout problem here with this 3-vector list venn diagram. I specified cat.pos = c(0, 0, 0), cat.dist = c(0.1, 0.1, 0.1) to have all 3 labels at noon above their respective area and at the same distance but I got the 3rd 1 step more above.. It is also farther when no cat.dist vector is passed to the function.

# Get gene lists to do Venn diagram
ids_3883_pvsUNR <- c(paste0("gene",c(1:66)))
ids_3883_pvsCRSP <- c(paste0("gene",c(67:126)))
ids_3884 <- c(paste0("gene",c(1:30,67:85,1001:4054)))

head(ids_3883_pvsUNR)

length(ids_3883_pvsUNR)
length(ids_3883_pvsCRSP)
length(ids_3884)


# 
geneLS <- list(ids_3883_pvsUNR, ids_3883_pvsCRSP, ids_3884)
# We can rename our list vectors
names(geneLS) <- c("Set_1_3883_pvsUNR","Set_1_3883_pvsCRSP", "Set_2_3884RUV")

# Now we can plot a Venn diagram with the VennDiagram R package, as follows:
require("VennDiagram")

VENN.LIST <- geneLS
labels <- c("Set_1_3883\nPat 1,2 vs UNR","Set_1_3883\nPat 1,2 vs 3 CRSP", "Set_2_3884RUV\nPat 3 vs 3 CRSP")
venn.plot <- venn.diagram(VENN.LIST , NULL, fill=c("darkmagenta", "darkblue", "grey"), alpha=c(0.5,0.5,0.5), cex = 2, cat.fontface=4, cat.pos = c(0, 0, 0), cat.dist = c(0.1, 0.1, 0.1), category.names=labels, main="Set_1_May_3883 (P vs UNR or CRSP) vs Set_2_May_3884_RUVcorrected")

# To plot the venn diagram we will use the grid.draw() function to plot the venn diagram
dev.off()
grid.draw(venn.plot)

Does somebody know what is happening here? Thanks for your feedback! Daniel

extra space in label 3 <-> area despite same distance given in parameters



Solution 1:[1]

Try the functions of the ggVennDiagram or ggvenn package. Here are the data

genes <- paste("gene",1:3180,sep="")
x <- list(
  `Set_1_3883\n Pat 1,2 vs UNR` = genes[1:66], 
  `Set_1_3883\n Pat 1,2 vs 3 CRSP` = genes[37:3139], 
  `Set_2_3884RUV\n Pat 3 vs 3 CRSP` = genes[3121:3180]
)

And now the graph

library(ggVennDiagram)
ggVennDiagram(x, label_alpha = 0)+
  scale_fill_gradient(low="gray",high = "blue")

enter image description here

And with the ggvenn package

library(ggvenn)
ggvenn(
  x, 
  fill_color = c("plum1", "blueviolet", "gray"),
  stroke_size = 0.5, set_name_size = 4
)

enter image description here

In both cases they are ggplots so you will have much better control over them.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marek Fiołka