data format for ggupset
1
0
Entering edit mode
4.2 years ago
linjc.xmu ▴ 30

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 • 1.6k views
ADD COMMENT
0
Entering edit mode

Provide example data.

ADD REPLY
4
Entering edit mode
4.2 years ago

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)
ADD COMMENT

Login before adding your answer.

Traffic: 2593 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6