I'm trying to create a 5 set Venn Diagram from a lists of lists of differentially expressed genes (after running DESeq2), and because the easy-to-use R packages allows up to 4 sets, I'm using a ggVennDiagram and ggplot2.
I have 5 sets (A, B, C, D, and E) data frames, and I have created a list (either by selecting only the row.names -where the gene names are- or by selecting data$geneNames), and I'm still facing the same error.
# Verify the length of the Data
len_deq <- (nrow(DEG_A_list))
len_wide <- (nrow(DEG_B_list))
len_bro <- (nrow(DEG_C_list))
len_varie <- (nrow(DEG_D_list))
len_font <- (nrow(DEG_E_list))
y <- list(
A = sample(rownames(DEG_A_list), len_deq),
B = sample(rownames(DEG_B_list), len_wide),
C = sample(rownames(DEG_C_list), len_bro),
D = sample(rownames(DEG_D_list), len_varie),
E = sample(rownames(DEG_E_list), len_font)
)
venn <- Venn(y)
data <- process_data(venn)
ggplot() +
geom_sf(aes(fill=id), data = venn_region(data), show.legend = FALSE) +
geom_sf(color="grey", size = 3, data = venn_setedge(data), show.legend = FALSE) +
geom_sf_text(aes(label = name), fontface = "bold", data = venn_setlabel(data)) +
geom_sf_label(aes(label = name), data = venn_region(data), alpha = 0.5) +
theme_void()
And here's the error:
Error in `geom_sf()`:
! Problem while computing stat.
ℹ Error occurred in the 1st layer.
Caused by error in `compute_layer()`:
! `stat_sf()` requires the following missing aesthetics: geometry
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `geom_sf()`:
! Problem while computing stat.
ℹ Error occurred in the 1st layer.
Caused by error in `compute_layer()`:
! `stat_sf()` requires the following missing aesthetics: geometry
---
Backtrace:
▆
1. ├─base (local) `<fn>`(x)
2. └─ggplot2:::print.ggplot(x)
3. ├─ggplot2::ggplot_build(x)
4. └─ggplot2:::ggplot_build.ggplot(x)
5. └─ggplot2:::by_layer(...)
6. ├─rlang::try_fetch(...)
7. │ ├─base::tryCatch(...)
8. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
9. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
10. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
11. │ └─base::withCallingHandlers(...)
12. └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
13. └─l$compute_statistic(d, layout)
14. └─ggplot2 (local) compute_statistic(..., self = self)
15. └─self$stat$compute_layer(data, self$computed_stat_params, layout)
16. └─ggplot2 (local) compute_layer(..., self = self)
17. └─ggproto_parent(Stat, self)$compute_layer(data, params, layout)
18. └─ggplot2 (local) compute_layer(..., self = self)
Any idea on what I'm doing wrong? Thanks!!!!
geom_sf()
call. Beyond that, please make your code reproducible by providing some example data. Please see the function's help page to get more information about that argument by running?geom_sf