Incorrect color mapping to Venn diagram with ggvenn in R

60 Views Asked by At

I want to color each segment of a Venn diagram with four conditions according to color scale (see below). However, the colors do not map to the correct sections and are way off from what I want. How can I fix this?

library(ggVennDiagram)
library(ggplot2)

genes <- paste0("gene",1:40)

gene_list <- list(
  A = genes[1:10],
  B = genes[1:20],
  C = genes[5:15],
  D = genes[30:40]
)

colorGroups <- c(A = "#45B6AA", B = "#D45176", C = "#91A6CE", D = "#86AD4C")          
# use colorRampPalette to create function that interpolates colors 
colfunc <- colorRampPalette(colorGroups)
# call function and create vector of 15 colors
col <- colfunc(15)

ggvenn::ggvenn(data = gene_list,
                       fill_alpha = 0.5,
                       fill_color = col,
                       show_percentage = FALSE)

Resulting Venn diagram

The colorRampPalette works as expected, however the colors are not mapped correctly. For example, section C is grey (default), but it should actually be green.

0

There are 0 best solutions below