<p>You need to generate a list of gene ID vectors to feed into <code>upset</code>. 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 <code>fromList</code> function that does just this.</p>

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

<pre class="lang-r prettyprint-override"><code>library("UpSetR")

tmp &lt;- mtcars

tmp$car &lt;- rownames(mtcars)
list &lt;- lapply(colnames(mtcars), function(x) {
  tmp[tmp[[x]] &gt; median(tmp[[x]]), "car"]
})
names(list) &lt;- colnames(mtcars)

upset(fromList(list))
</code></pre>

<p><img src="https://i.sstatic.net/xwRHJ.png" alt=""></p>

<p><sup>Created on 2019-10-17 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.3.0)</sup></p>

CC BY-SA 4.0
2019-10-17T15:38:46.100Z
2019-10-17T15:38:46.100Z
alan ocallaghan
<p>I wrote a <a href="https://github.com/sdmiller93/Public_Scripts/blob/master/up_down_flat.R" rel="nofollow noreferrer">script</a> to create the binary data frame with my differential expression data. If it is of any help to anyone:</p>

CC BY-SA 4.0
2019-09-17T01:35:37.460Z
2019-09-17T01:35:37.460Z
sdmiller93
<p>I have a <code>data.frame</code> of <code>27 000 x 17</code> and I want to feed it into <code>UpSetR</code> program, but getting the error:</p>

<blockquote>
  <p>Error in start_col:end_col : argument of length 0</p>
</blockquote>

<p>My <code>data.frame</code> looks like that:</p>

<p><a href="https://i.sstatic.net/dzQ7h.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dzQ7h.png" alt="enter image description here"></a></p>

<p>And the <code>upSetR</code> code that I am using:</p>

<pre><code>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))
</code></pre>

<p>What am I doing wrong here? Any suggestions would be greatly appreciated.</p>

<blockquote>
  <p>Update</p>
</blockquote>

<p>I found here a similar issue: </p>

<p><a href="https://plus.google.com/109635504520741246387/posts/Etujrp6sU1Q" rel="nofollow noreferrer">https://plus.google.com/109635504520741246387/posts/Etujrp6sU1Q</a></p>

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

CC BY-SA 3.0
2018-04-14T13:33:38.367Z
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
CC BY-SA 3.0
2018-04-14T19:37:38.460Z
upsetR takes as input a data.table in the long format. I found [this example/code](http://crazyhottommy.blogspot.de/2016/01/upset-plot-for-overlapping-chip-seq.html) very helpful when I first started using upsetR.
fridaymeetssunday
CC BY-SA 3.0
2018-04-14T21:00:53.790Z
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
CC BY-SA 3.0
2018-04-14T21:13:23.497Z
I am pretty confused but the problem is rather definite: I need to represent groups, their similarity, as an UpSet plot.
Nikita Vlasenko
CC BY-SA 3.0
2018-04-15T17:43:58.477Z
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
<r><upsetr>
How can I use UpSet plot for expression/RNA-seq data
# How can I use UpSet plot for expression/RNA-seq data

(Asked by: username_0 on 2018-04-13)

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: 
https://plus.google.com/109635504520741246387/posts/Etujrp6sU1Q
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...

**Tags:** r, upsetr
> **Comments:**
> **username_1**: 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.  
> **username_2**: upsetR takes as input a data.table in the long format. I found [this example/code](http://crazyhottommy.blogspot.de/2016/01/upset-plot-for-overlapping-chip-seq.html) very helpful when I first started using upsetR.  
> **username_0**: 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.  
> **username_0**: I am pretty confused but the problem is rather definite: I need to represent groups, their similarity, as an UpSet plot.  
> **username_3**: 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.  

---

## 2 answers

### Answer by username_4 on 2019-10-17. Score: 2

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)


---

### Answer by username_5 on 2019-09-17. Score: 1

I wrote a [script](https://github.com/sdmiller93/Public_Scripts/blob/master/up_down_flat.R) to create the binary data frame with my differential expression data. If it is of any help to anyone:


---

