<p>I suspect the error is caused by a 'lack' of intersection between &quot;NQLD&quot;, &quot;Nlab&quot;, and &quot;Nsyl&quot;? If you remove &quot;Nlab&quot; from the first query the command appears to complete as expected, e.g.</p>
<pre class="lang-r prettyprint-override"><code>library(UpSetR)
orthogroups_df &lt;- read.table(&quot;~/Desktop/orthogroups.GeneCount.tsv&quot;,
                            header=T, stringsAsFactors = F)
selected_species &lt;- colnames(orthogroups_df)[2:(ncol(orthogroups_df) -1)]
selected_species
#&gt;  [1] &quot;Athaliana_447_Araport11.protein_primaryTranscriptOnly&quot;
#&gt;  [2] &quot;Cann&quot;                                                 
#&gt;  [3] &quot;NQLD&quot;                                                 
#&gt;  [4] &quot;Natt&quot;                                                 
#&gt;  [5] &quot;Ngla&quot;                                                 
#&gt;  [6] &quot;Nlab&quot;                                                 
#&gt;  [7] &quot;Nsyl&quot;                                                 
#&gt;  [8] &quot;Ntab&quot;                                                 
#&gt;  [9] &quot;Ntom&quot;                                                 
#&gt; [10] &quot;Slyc&quot;                                                 
#&gt; [11] &quot;Stub&quot;                                                 
#&gt; [12] &quot;Vvin&quot;
head(orthogroups_df)
#&gt;   Orthogroup Athaliana_447_Araport11.protein_primaryTranscriptOnly Cann NQLD
#&gt; 1  OG0000000                                                     0    0  965
#&gt; 2  OG0000001                                                     0    1    3
#&gt; 3  OG0000002                                                     0    1  313
#&gt; 4  OG0000003                                                     0   93   15
#&gt; 5  OG0000004                                                     1   42    2
#&gt; 6  OG0000005                                                     0    2   61
#&gt;   Natt Ngla Nlab Nsyl Ntab Ntom Slyc Stub Vvin Total
#&gt; 1    0    0    3    0    0    0    0    0    0   968
#&gt; 2    0    0  448    0    0    0    0    0    0   452
#&gt; 3    0    0  120    1    0    1    0    0    0   436
#&gt; 4   21   46   16   33   63   36   25   39   26   413
#&gt; 5   34  109    6    8  154   11    9    4    0   380
#&gt; 6    1   34   44   91   70   43   20    1    0   367
ncol(orthogroups_df)
#&gt; [1] 14
orthogroups_df[orthogroups_df &gt; 0] &lt;- 1

upset(orthogroups_df,
      nsets = ncol(orthogroups_df),
      sets = rev(c(selected_species)),
      queries = list(list(query = intersects,
                          params = list(&quot;NQLD&quot;, &quot;Nsyl&quot;),
                          color = &quot;#238c45&quot;, active = T),
                     list(query = intersects,
                          params = list(&quot;NQLD&quot;, &quot;Nlab&quot;),
                          color = &quot;#ffd977&quot;, active = T)))
</code></pre>
<p><img src="https://i.sstatic.net/sUrHL.png" alt="" /></p>
<p><sup>Created on 2022-11-28 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>
<p>You can see in the plot that &quot;NQLD&quot;, &quot;Nlab&quot;, and &quot;Nsyl&quot; don't appear to have any values in common, i.e. the 'dots' corresponding to those variables aren't joined. So, to fix the error you need to select variables that intersect in your queries.</p>

CC BY-SA 4.0
2022-11-28T11:40:53.433Z
2022-11-28T11:40:53.433Z
jared_mamrot
<p>I have tried to use UpsetR to visualize the input file which can be found <a href="https://cloudstor.aarnet.edu.au/plus/s/OupXC8rF2bDFtRV" rel="nofollow noreferrer">here</a></p>
<pre><code>&gt; library(&quot;UpSetR&quot;)
&gt; orthogroups_df&lt;- read.table(&quot;orthogroups.GeneCount.tsv&quot;,  header=T, stringsAsFactors = F)
&gt; #All species
&gt; selected_species &lt;- colnames(orthogroups_df)[2:(ncol(orthogroups_df) -1)] 
&gt; selected_species
 [1] &quot;Atha&quot; &quot;Cann&quot; &quot;NQLD&quot; &quot;Natt&quot; &quot;Ngla&quot; &quot;Nlab&quot; &quot;Nsyl&quot; &quot;Ntab&quot; &quot;Ntom&quot; &quot;Slyc&quot; &quot;Stub&quot; &quot;Vvin&quot;
&gt; head(orthogroups_df)
  Orthogroup Atha Cann NQLD Natt Ngla Nlab Nsyl Ntab Ntom Slyc Stub Vvin Total
1  OG0000000    0    0  965    0    0    3    0    0    0    0    0    0   968
2  OG0000001    0    1    3    0    0  448    0    0    0    0    0    0   452
3  OG0000002    0    1  313    0    0  120    1    0    1    0    0    0   436
4  OG0000003    0   93   15   21   46   16   33   63   36   25   39   26   413
5  OG0000004    1   42    2   34  109    6    8  154   11    9    4    0   380
6  OG0000005    0    2   61    1   34   44   91   70   43   20    1    0   367
&gt; ncol(orthogroups_df)
[1] 14
&gt; orthogroups_df[orthogroups_df &gt; 0] &lt;- 1
&gt; upset(orthogroups_df, 
+       nsets = ncol(orthogroups_df), 
+       sets = rev(c(selected_species)), 
+       queries = list(list(query = intersects, params = list(&quot;NQLD&quot;, &quot;Nlab&quot;, &quot;Nsyl&quot;), color = &quot;#238c45&quot;, active = T),
+                 list(query = intersects, params = list(&quot;NQLD&quot;, &quot;Nlab&quot;), color = &quot;#ffd977&quot;, active = T)))


Error in `$&lt;-.data.frame`(`*tmp*`, &quot;freq&quot;, value = 45L) : 
  replacement has 1 row, data has 0
</code></pre>
<p>How is it possible to fix the above error?</p>

CC BY-SA 4.0
2022-11-22T17:46:25.940Z
Please provide some reproducible data first. Nobody is going to be able to help otherwise.
user438383
<r><ggplot2><dataframe><upsetr>
replacement has 1 row, data has 0
# replacement has 1 row, data has 0

(Asked by: username_0 on 2022-11-21)

I have tried to use UpsetR to visualize the input file which can be found here
> library("UpSetR")
> orthogroups_df<- read.table("orthogroups.GeneCount.tsv",  header=T, stringsAsFactors = F)
> #All species
> selected_species <- colnames(orthogroups_df)[2:(ncol(orthogroups_df) -1)] 
> selected_species
 [1] "Atha" "Cann" "NQLD" "Natt" "Ngla" "Nlab" "Nsyl" "Ntab" "Ntom" "Slyc" "Stub" "Vvin"
> head(orthogroups_df)
  Orthogroup Atha Cann NQLD Natt Ngla Nlab Nsyl Ntab Ntom Slyc Stub Vvin Total
1  OG0000000    0    0  965    0    0    3    0    0    0    0    0    0   968
2  OG0000001    0    1    3    0    0  448    0    0    0    0    0    0   452
3  OG0000002    0    1  313    0    0  120    1    0    1    0    0    0   436
4  OG0000003    0   93   15   21   46   16   33   63   36   25   39   26   413
5  OG0000004    1   42    2   34  109    6    8  154   11    9    4    0   380
6  OG0000005    0    2   61    1   34   44   91   70   43   20    1    0   367
> ncol(orthogroups_df)
[1] 14
> orthogroups_df[orthogroups_df > 0] <- 1
> upset(orthogroups_df, 
+       nsets = ncol(orthogroups_df), 
+       sets = rev(c(selected_species)), 
+       queries = list(list(query = intersects, params = list("NQLD", "Nlab", "Nsyl"), color = "#238c45", active = T),
+                 list(query = intersects, params = list("NQLD", "Nlab"), color = "#ffd977", active = T)))


Error in `$<-.data.frame`(`*tmp*`, "freq", value = 45L) : 
  replacement has 1 row, data has 0

How is it possible to fix the above error?

**Tags:** r, ggplot2, dataframe, upsetr
> **Comments:**
> **username_1**: Please provide some reproducible data first. Nobody is going to be able to help otherwise.  

---

## 1 answers

### Answer by username_2 on 2022-11-28. Score: 2 | Accepted answer

I suspect the error is caused by a 'lack' of intersection between "NQLD", "Nlab", and "Nsyl"? If you remove "Nlab" from the first query the command appears to complete as expected, e.g.
library(UpSetR)
orthogroups_df <- read.table("~/Desktop/orthogroups.GeneCount.tsv",
                            header=T, stringsAsFactors = F)
selected_species <- colnames(orthogroups_df)[2:(ncol(orthogroups_df) -1)]
selected_species
#>  [1] "Athaliana_447_Araport11.protein_primaryTranscriptOnly"
#>  [2] "Cann"                                                 
#>  [3] "NQLD"                                                 
#>  [4] "Natt"                                                 
#>  [5] "Ngla"                                                 
#>  [6] "Nlab"                                                 
#>  [7] "Nsyl"                                                 
#>  [8] "Ntab"                                                 
#>  [9] "Ntom"                                                 
#> [10] "Slyc"                                                 
#> [11] "Stub"                                                 
#> [12] "Vvin"
head(orthogroups_df)
#>   Orthogroup Athaliana_447_Araport11.protein_primaryTranscriptOnly Cann NQLD
#> 1  OG0000000                                                     0    0  965
#> 2  OG0000001                                                     0    1    3
#> 3  OG0000002                                                     0    1  313
#> 4  OG0000003                                                     0   93   15
#> 5  OG0000004                                                     1   42    2
#> 6  OG0000005                                                     0    2   61
#>   Natt Ngla Nlab Nsyl Ntab Ntom Slyc Stub Vvin Total
#> 1    0    0    3    0    0    0    0    0    0   968
#> 2    0    0  448    0    0    0    0    0    0   452
#> 3    0    0  120    1    0    1    0    0    0   436
#> 4   21   46   16   33   63   36   25   39   26   413
#> 5   34  109    6    8  154   11    9    4    0   380
#> 6    1   34   44   91   70   43   20    1    0   367
ncol(orthogroups_df)
#> [1] 14
orthogroups_df[orthogroups_df > 0] <- 1

upset(orthogroups_df,
      nsets = ncol(orthogroups_df),
      sets = rev(c(selected_species)),
      queries = list(list(query = intersects,
                          params = list("NQLD", "Nsyl"),
                          color = "#238c45", active = T),
                     list(query = intersects,
                          params = list("NQLD", "Nlab"),
                          color = "#ffd977", active = T)))


Created on 2022-11-28 with reprex v2.0.2
You can see in the plot that "NQLD", "Nlab", and "Nsyl" don't appear to have any values in common, i.e. the 'dots' corresponding to those variables aren't joined. So, to fix the error you need to select variables that intersect in your queries.


---

