yanlinlin82 / ggvenn

Venn Diagram by ggplot2, with really easy-to-use API.
Other
167 stars 25 forks source link

Prepare personal data #18

Closed larry1995 closed 3 years ago

larry1995 commented 3 years ago

Hi Yan,

I am using your ggvenn for my own data analysis. However, I can't convert my dataset from the list “a" to dataframe "d" as you showed on your GitHub. Could you tell me how to convert this list to the tibble?

image

yanlinlin82 commented 3 years ago

Hi, @larry1995

Thank you for your interest in ggvenn!

Yes, ggvenn processes list and data.frame input data in different ways. So far, there is no easy way to convert between them. Maybe it is a good idea to provide such functions in ggvenn.

Would you please try like this:

library(tidyverse)
library(ggvenn)

a <- list(CEH = c("AT1G01010", "AT1G01060"),
          EDSCEH = c("AT1G01060", "AT1G01110", "AT1G01340"),
          CEHEDSvsCEH = c("AT1G02230", "AT1G13620"))  # for demo

d <- tibble(name = unique(unlist(a)))
for (name in names(x)) d[, name] <- d$name %in% x[[name]]

ggvenn(d)
larry1995 commented 3 years ago

Hi @yanlinlin82 ,

Awesome. It works for me. I really appreciate your help.

yanlinlin82 commented 3 years ago

Two functions list_to_data_frame() and data_frame_to_list() were added into ggvenn (9156936).