This is a test version of Biostars. For the public version, visit https://www.biostars.org.
data format for ggupset

Dear All, I am trying to learn ggupset for upset plotting. Does anyone know how to convert custom data set to fit with ggupset? I have 8 lists of DEGs with gene names at first column, and log2FC at second column. How can I combine them in to one data set and use it for ggupset plot? Thank you very much.

r

Provide example data.

1 answer

According to your question, I guess that you want to count the number of DEGs in common between your 8 conditions with UpSetR since it would be a nightmare with Venn Diagrams. You don't need ggupset for that, UpSetR might be a better solution since data preparation is much more straightforward. Moreover, UpSetR displays the size of the sets, which might come handy in this kind of DEG analysis.

Here's a simple example using 3 data frames. Log2 Fold Change (l2r) columns are given in the datasets but aren't used in the analysis (so you can directly use that code), for more datasets, consider using lists and do.call for the rbind.

library("reshape2")
library("UpSetR")

#### DUMMY DATA GENERATION

data1 <- data.frame( c( "gene1","gene2","gene3","gene4","gene5" ),
                     c( 1, 0, 0, 1, 1 ),
                     c( 2.14, -0.1, 0.3, 2.5, 2.8 ) )
colnames(data1)    <- c( "id","dif","l2r" )
data1["condition"] <- "condition1"


data2 <- data.frame( c( "gene1", "gene2", "gene3", "gene4", "gene5" ),
                     c( 0, 1, 1, 1, 1 ),
                     c( 0.4, -1.8, 2.6, 2.7, 4.2 ) )
colnames(data2)    <- c( "id","dif","l2r" )
data2["condition"] <- "condition2"


data3 <- data.frame( c( "gene1","gene2","gene3","gene4","gene5" ),
                     c( 0, 0, 1, 1, 1 ),
                     c( 0.4, -0.2, 4.8, 3.2, 5.1 ) )
colnames(data3)    <- c("id","dif","l2r")
data3["condition"] <- "condition3"

#### DATA PREPARATION

all_conditions <- rbind(data1,data2,data3)
all_conditions <- as.data.frame(dcast(all_conditions, id ~ condition, value.var = "dif"))

#### UPSET PLOT

UpSetR::upset(all_conditions)

Log in to answer this question.