Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
library(VennDiagram)
venn.diagram(list(first = c("a", "b", "c"),
second = c("a", "c", "d"),
third = c("a", "d"))
imagetype = "png",
col = "transparent",
filename = "example.png",
height = 2000,
width = 2000,
fill = 1:2)
@MarcinKosinski

This comment has been minimized.

Copy link
Owner Author

@MarcinKosinski MarcinKosinski commented Apr 20, 2016

Real life example with overlap calculations

library(VennDiagram)
library(dplyr)
calculate.overlap(list(DE = read.csv2("output_data/diff_DE_PSC.csv") %>%
                          filter(FDR < 0.01) %>%
                          select(X) %>%
                          unlist %>% as.character(),
                       `_  EB` = read.csv2("output_data/diff_EB_PSC.csv") %>%
                          filter(FDR < 0.01) %>%
                          select(X) %>%
                          unlist %>% as.character(),
                       ECTO = read.csv2("output_data/diff_ECTO_PSC.csv") %>%
                          filter(FDR < 0.01) %>%
                          select(X) %>%
                          unlist %>% as.character(),
                       MESO = read.csv2("output_data/diff_MESO_PSC.csv") %>%
                          filter(FDR < 0.01) %>%
                          select(X) %>%
                          unlist %>% as.character(),
                      # `Other __` = read.csv2("output_data/diff_NoCLASS_PSC.csv") %>%
                       #   filter(FDR < 0.01) %>%
                        #  select(X) %>%
                         # unlist %>% as.character())
                      ) -> overlap

overlap



x <- list(DE = read.csv2("output_data/diff_DE_PSC.csv") %>%
             filter(FDR < 0.01) %>%
             select(X) %>%
             unlist %>% as.character(),
          `EB` = read.csv2("output_data/diff_EB_PSC.csv") %>%
             filter(FDR < 0.01) %>%
             select(X) %>%
             unlist %>% as.character(),
          ECTO = read.csv2("output_data/diff_ECTO_PSC.csv") %>%
             filter(FDR < 0.01) %>%
             select(X) %>%
             unlist %>% as.character(),
          MESO = read.csv2("output_data/diff_MESO_PSC.csv") %>%
             filter(FDR < 0.01) %>%
             select(X) %>%
             unlist %>% as.character()#,
          #`Other __` = read.csv2("output_data/diff_NoCLASS_PSC.csv") %>%
           #  filter(FDR < 0.01) %>%
            # select(X) %>%
             #unlist %>% as.character()
          )

get.venn.partitions(x) -> y
get.venn.partitions(x, force.unique = FALSE)

y[, 6] <- unlist(lapply(y[, 6], paste, collapse = " "))

write.csv2(y,
           file = "output_data/venn_4groups.csv",
           quote = FALSE,
           row.names = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment