Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-17T15:38:46.100Z
Answers.LastActivityDate: 2019-10-17T15:38:46.100Z
Answers.UserDisplayName: alan ocallaghan
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-17T01:35:37.460Z
Answers.LastActivityDate: 2019-09-17T01:35:37.460Z
Answers.UserDisplayName: sdmiller93
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-14T13:33:38.367Z
Comments.Text: 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.
Comments.UserDisplayName: Devon Ryan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-14T19:37:38.460Z
Comments.Text: 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.
Comments.UserDisplayName: fridaymeetssunday
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-14T21:00:53.790Z
Comments.Text: 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.
Comments.UserDisplayName: Nikita Vlasenko
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-14T21:13:23.497Z
Comments.Text: I am pretty confused but the problem is rather definite: I need to represent groups, their similarity, as an UpSet plot.
Comments.UserDisplayName: Nikita Vlasenko
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-15T17:43:58.477Z
Comments.Text: 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.
Comments.UserDisplayName: Kamil S Jaron
Tags: <r><upsetr>
Title: How can I use UpSet plot for expression/RNA-seq data
ThreadText: # 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:
  
  [![enter image description here](https://i.sstatic.net/dzQ7h.png)](https://i.sstatic.net/dzQ7h.png)
  
  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.
  
  ```r
  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))
  
  ```
  
  ![](https://i.sstatic.net/xwRHJ.png)
  
  Created on 2019-10-17 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)
  
  
  ---
  
  ### Answer by username_5 on 2019-09-17. Score: 1
  
  I wrote a [script](https://github.com/username_5/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:
  
  
  ---
  
  