# How can I use UpSet plot for expression/RNA-seq data

I have a data.frame of 27 000 x 17 and I want to feed it into UpSetR program, but getting the error:

Error in start_col:end_col : argument of length 0

My data.frame looks like that:

And the upSetR code that I am using:

upset(df, nsets = 4, number.angles = 30, point.size = 3.5, line.size = 2,
mainbar.y.label = "Gene Intersections", sets.x.label = "Genes Per Group",
text.scale = c(1.3, 1.3, 1, 1, 2, 0.75))


What am I doing wrong here? Any suggestions would be greatly appreciated.

Update

I found here a similar issue:

They say that the input should be binary. But then, how can I calculate this binary matrix from the rlog-data? I am not sure...

• UpSet plots are in many ways similar to Venn diagrams, in that the represent some sort of metric for group overlap. What I expect you want to do is get the number of DE genes in various comparisons and put those numbers into an UpSet plot. – Devon Ryan Apr 14 '18 at 13:33
• upsetR takes as input a data.table in the long format. I found this example/code very helpful when I first started using upsetR. – fridaymeetssunday Apr 14 '18 at 19:37
• I need to get the binary matrix to be able to feed it into the UpSetR. Right now I have a matrix where rows are genes and columns are groups. Somehow for each gene I need to set a threshold value to convert it to binary ‘expressed/not expressed’ probably. Groups are vectors of numbers, so I need to find their intersection somehow. I do not know which software or R package do that: I would not want to do it manually. – Nikita Vlasenko Apr 14 '18 at 21:00
• I am pretty confused but the problem is rather definite: I need to represent groups, their similarity, as an UpSet plot. – Nikita Vlasenko Apr 14 '18 at 21:13
• I think, it would be good to rephrase your question to match your ultimate goal something like "How can I use UpSet plot for expression/RNA-seq?". Say what is you sample and why you want to do the UpSet plot. – Kamil S Jaron Apr 15 '18 at 17:43

You need to generate a list of gene ID vectors to feed into upset. In the example below, I am selecting observations (genes) which have an level above the median level. You could also choose only genes above the 3rd quartile, etc. You then need to convert these from a list of character vectors to a presence/absence matrix. UpSetR has a fromList function that does just this.

In future, be more specific about what you want to achieve and supply example data for people to work with.

library("UpSetR")

tmp <- mtcars

tmp\$car <- rownames(mtcars)
list <- lapply(colnames(mtcars), function(x) {
tmp[tmp[[x]] > median(tmp[[x]]), "car"]
})
names(list) <- colnames(mtcars)

upset(fromList(list))


Created on 2019-10-17 by the reprex package (v0.3.0)

I wrote a script to create the binary data frame with my differential expression data. If it is of any help to anyone: