Closed MartinWitt closed 7 months ago
From the example of #50 , we can do this by several extra configs:
genes <- paste0("gene",1:20)
set.seed(20230406)
gene_list <- list(A = sample(genes,5),
B = sample(genes,5),
C = sample(genes,5),
D = sample(genes,5),
E = sample(genes,5),
F = sample(genes,5),
G = sample(genes,5))
library(ggVennDiagram)
library(ggplot2)
library(dplyr)
venn <- Venn(gene_list)
data <- process_data(venn)
ggplot() +
# 1. region count layer
geom_sf(aes(fill = count), data = venn_region(data)) +
# 2. set edge layer
geom_sf(aes(color = id), data = venn_setedge(data), show.legend = FALSE) +
# 3. set label layer
geom_sf_text(aes(label = name), data = venn_setlabel(data)) +
# 4. region label layer
geom_sf_label(aes(label = count), data = venn_region(data) %>% filter(count != 0), alpha = 0.5) +
theme_void()
The region labels are plotted by the geom_sf_label()
function, if you want to map size to the count of region items, read the count in data
, and set the size
parameter in aes(size = count)
. After this, set the label scale with the scale_size_*
function.
Have a try and give me feedback.
By the way, exporting the figure with exports::graph2ppt()
is also an alternative, as you can change items in PPT much easier without access to some uncommon ggplot functions.
Hey is it possible to scale the label size of each region with the count of it? My current code is the following which produces:
I also took a look at #50, but haven't understood how to do this for my diagram. I am a complete R beginner and help is appreciated.