firmo23
firmo23

Reputation: 8404

Issues with Label positions, shape and overlap colors in Venn diagrams

I have the data below:

dc <- c("CACNA1C",  "CACNA1D",  "KCNN4",    "CACNA1F",  "CACNA1D",  "CACNA1C",  "GNRHR",    "CD80",     "CD86",     "ITGA2B"  )
tc <- c("CACNA1C",  "CACNA1D",  "CACNA1C",  "CACNA1D",  "CACNA1F",  "KCNN4",    "APP",      "GNRHR",    "CD86",     "CD80"    )

and I want to create a Venn diagram using the VennDiagram package.

library(VennDiagram)
Vt <- venn.diagram(
  x = list(
    DC_Dataset=dc,
    TC_Dataset=tc
  ),
  #filename = "1B-double_Venn.tiff",
  main = "Targets",
  main.cex = 3,
  filename = NULL,
  lwd = 4,
  fill = c("cornflowerblue", "green"),
  alpha = 0.75,
  label.col = "black",
  cex = 2,
  fontfamily = "sansserif",
  fontface = "bold",
  cat.col = c("black", "black"),
  cat.cex = 1.5,
  cat.fontfamily = "sansserif",
  cat.fontface = "bold",
  cat.dist = c(0.03, 0.03),
  cat.pos = c(-20, 14)
)

grid.newpage()
grid.draw(Vt)

enter image description here

I have 3 issues:

  1. The shapes are ovals rather than circles.Can this be changed or is the default shape?

  2. It would be nice to locate these labels more centrally within the bodies of the 2 shapes. With cat.pos = c(-20, 14) I can move the 2 labels left or right but not upside-down.

  3. I don’t like that the unique part of the TC dataset, with 1 unique value, is the same color as the overlap region.Ideally, in the updated script, if e.g. purple and green are selected as the 2 regions’ colors, then a third color could be used as the overlap color.

Answer to any of these questions would be really helpful.

Upvotes: 2

Views: 4174

Answers (1)

Julius Vainora
Julius Vainora

Reputation: 48211

  1. It all depends on the scaling of your window/output picture. Setting length to width ratio to 1:1 gives a circle.

  2. cat.pos isn't about left and right:

Vector giving the position (in degrees) of each category name along the circle, with 0 at 12 o'clock

Also, cat.dist is useful for this:

Vector giving the distance (in npc units) of each category name from the edge of the circle (can be negative)

  1. The colors are not the same. They are really similar, though, due to high value of alpha and blue being "close" to green. It doesn't seem to be possible to specify the third color, but it kind of makes sense that the resulting color is a mix of the other two.

That said, you could do something like this:

Vt <- venn.diagram(
  x = list(
    DC_Dataset=dc,
    TC_Dataset=tc
  ),
  main = "Targets",
  main.cex = 3,
  filename = NULL,
  lwd = 4,
  fill = c("red", "blue"), # Modified
  alpha = 0.4, # Modified
  label.col = "black",
  cex = 2,
  fontfamily = "sansserif",
  fontface = "bold",
  cat.col = c("black", "black"),
  cat.cex = 1.5,
  cat.fontfamily = "sansserif",
  cat.fontface = "bold",
  cat.dist = c(-0.1, -0.1), # Modified
  cat.pos = c(-90, 90) # Modified
)
grid.newpage()
grid.draw(Vt)

enter image description here

Upvotes: 3

Related Questions