<p>The error is telling you that there isn't any Infected column on the model.matrix.
Check the column names of <code>mm</code>. Also not sure that having two <code>~</code> will work well.</p>

CC BY-SA 4.0
2021-03-31T02:16:18.583Z
I did notice the ~~ mistake thanks for pointing it out.
Angus Campbell
CC BY-SA 4.0
2021-03-29T08:12:17.493Z
2021-03-29T08:12:17.493Z
llrs
<p>I am getting a rather strange error from topTable.    When I run my code I get <code>Error in fit$coefficients[, coef] : subscript out of bounds</code> from topTable as if it is not recognizing the condition I am asking it to return the top ten DEGs of. I have provided a bit more context and some descriptions of my variables below.  Let me know if you need any more information or if anything is unclear.</p>
<p><strong>Variables:</strong></p>
<p><code>dge</code> is a DGEList object of RNA seq data.</p>
<p><code>dge$counts</code> is the raw counts.</p>
<p><code>dge$samples$dge_meta</code> is the metadata and log2 transformed counts.</p>
<pre><code>&gt; colnames(dge<span class="math-container">$samples$</span>dge_meta)
 [1] &quot;Lab.sample.ID&quot;                                              
 [2] &quot;Accession.Number&quot;                                           
 [3] &quot;Alias.used.in.some.figures&quot;                                 
 [4] &quot;Developmental.stage&quot;                                        
 [5] &quot;Infected&quot;                                                   
 [6] &quot;Batch&quot;                                                      
 [7] &quot;Trimmed&quot;                                                    
 [8] &quot;Number.of.reads.that.pass.Illumina.filter&quot;                  
 [9] &quot;Total.number.of.reads.mapped&quot;                               
[10] &quot;%.of.total.reads.mapped&quot;                                    
[11] &quot;Reads.mapped.to.T..cruzi.Esmeraldo.haplotype&quot;               
[12] &quot;Reads.mapped.to.hg19&quot;                                       
[13] &quot;%.of.mapped.reads.belonging.to.T..cruzi.Esmeraldo.haplotype&quot;
[14] &quot;%.of.mapped.reads.belonging.to.hg19&quot;                        
[15] &quot;sample&quot;                                                     
[16] &quot;hpi&quot;
</code></pre>
<p>Lastly <code>keep_it</code> is a binary vector used to filter our zero count genes.</p>
<p><strong>Code:</strong></p>
<pre><code>mm &lt;- model.matrix(~~hpi*Infected, data = dge<span class="math-container">$samples$</span>dge_meta) #making our design matrix

more_than_1cpm_model &lt;- voom(dge$counts[keep_it,], mm, plot = TRUE) #this one is filtered by the 25% greater than 1 cpm

cutoff &lt;-  1e-05

empBayesfit &lt;- eBayes(fit_gt1cpm)

topTable(empBayesfit,
         coef = c(&quot;Infected&quot;),
         p.value = cutoff, number = 10)
</code></pre>
<p><strong>Error message:</strong></p>
<pre><code>Error in fit$coefficients[, coef] : subscript out of bounds
</code></pre>
<p>To understand the context better I ran rlang::last_error and rlang::last_trace as well.</p>
<pre><code>&gt; rlang::last_error()
&lt;error/dplyr_error&gt;
arrange() failed at implicit mutate() step. 
* Problem with `mutate()` input `..1`.
x Input `..1` must be a vector, not a `standardGeneric` object.
i Input `..1` is `samples`.
Backtrace:
Run `rlang::last_trace()` to see the full context.
&gt; rlang::last_trace()
&lt;error/dplyr_error&gt;
arrange() failed at implicit mutate() step. 
* Problem with `mutate()` input `..1`.
x Input `..1` must be a vector, not a `standardGeneric` object.
i Input `..1` is `samples`.
Backtrace:
     x
  1. +-dplyr::arrange(x, samples)
  2. +-dplyr:::arrange.data.frame(x, samples)
  3. | \-dplyr:::arrange_rows(.data, dots)
  4. |   +-base::withCallingHandlers(...)
  5. |   +-dplyr::transmute(new_data_frame(.data), !!!quosures)
  6. |   \-dplyr:::transmute.data.frame(new_data_frame(.data), !!!quosures)
  7. |     +-dplyr::mutate(.data, ..., .keep = &quot;none&quot;)
  8. |     \-dplyr:::mutate.data.frame(.data, ..., .keep = &quot;none&quot;)
  9. |       \-dplyr:::mutate_cols(.data, ...)
 10. |         +-base::withCallingHandlers(...)
 11. |         \-mask$eval_all_mutate(quo)
 12. +-dplyr:::abort_glue(...)
 13. | +-rlang::exec(abort, class = class, !!!data)
 14. | \-(function (message = NULL, class = NULL, ..., trace = NULL, parent = NULL, ...
 15. |   \-rlang:::signal_abort(cnd)
 16. |     \-base::signalCondition(cnd)
 17. +-(function (e) ...
 18. | \-rlang::abort(...)
 19. |   \-rlang:::signal_abort(cnd)
 20. |     \-base::signalCondition(cnd)
 21. \-(function (cnd) ...
</code></pre>

<r><rna-seq><limma>
Toptable error, wont recognize condition
# Toptable error, wont recognize condition

(Asked by: username_0 on 2021-03-29)

I am getting a rather strange error from topTable.    When I run my code I get Error in fit$coefficients[, coef] : subscript out of bounds from topTable as if it is not recognizing the condition I am asking it to return the top ten DEGs of. I have provided a bit more context and some descriptions of my variables below.  Let me know if you need any more information or if anything is unclear.
Variables:
dge is a DGEList object of RNA seq data.
dge$counts is the raw counts.
dge$samples$dge_meta is the metadata and log2 transformed counts.
> colnames(dge$samples$dge_meta)
 [1] "Lab.sample.ID"                                              
 [2] "Accession.Number"                                           
 [3] "Alias.used.in.some.figures"                                 
 [4] "Developmental.stage"                                        
 [5] "Infected"                                                   
 [6] "Batch"                                                      
 [7] "Trimmed"                                                    
 [8] "Number.of.reads.that.pass.Illumina.filter"                  
 [9] "Total.number.of.reads.mapped"                               
[10] "%.of.total.reads.mapped"                                    
[11] "Reads.mapped.to.T..cruzi.Esmeraldo.haplotype"               
[12] "Reads.mapped.to.hg19"                                       
[13] "%.of.mapped.reads.belonging.to.T..cruzi.Esmeraldo.haplotype"
[14] "%.of.mapped.reads.belonging.to.hg19"                        
[15] "sample"                                                     
[16] "hpi"

Lastly keep_it is a binary vector used to filter our zero count genes.
Code:
mm <- model.matrix(~~hpi*Infected, data = dge$samples$dge_meta) #making our design matrix

more_than_1cpm_model <- voom(dge$counts[keep_it,], mm, plot = TRUE) #this one is filtered by the 25% greater than 1 cpm

cutoff <-  1e-05

empBayesfit <- eBayes(fit_gt1cpm)

topTable(empBayesfit,
         coef = c("Infected"),
         p.value = cutoff, number = 10)

Error message:
Error in fit$coefficients[, coef] : subscript out of bounds

To understand the context better I ran rlang::last_error and rlang::last_trace as well.
> rlang::last_error()

arrange() failed at implicit mutate() step. 
* Problem with `mutate()` input `..1`.
x Input `..1` must be a vector, not a `standardGeneric` object.
i Input `..1` is `samples`.
Backtrace:
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()

arrange() failed at implicit mutate() step. 
* Problem with `mutate()` input `..1`.
x Input `..1` must be a vector, not a `standardGeneric` object.
i Input `..1` is `samples`.
Backtrace:
     x
  1. +-dplyr::arrange(x, samples)
  2. +-dplyr:::arrange.data.frame(x, samples)
  3. | \-dplyr:::arrange_rows(.data, dots)
  4. |   +-base::withCallingHandlers(...)
  5. |   +-dplyr::transmute(new_data_frame(.data), !!!quosures)
  6. |   \-dplyr:::transmute.data.frame(new_data_frame(.data), !!!quosures)
  7. |     +-dplyr::mutate(.data, ..., .keep = "none")
  8. |     \-dplyr:::mutate.data.frame(.data, ..., .keep = "none")
  9. |       \-dplyr:::mutate_cols(.data, ...)
 10. |         +-base::withCallingHandlers(...)
 11. |         \-mask$eval_all_mutate(quo)
 12. +-dplyr:::abort_glue(...)
 13. | +-rlang::exec(abort, class = class, !!!data)
 14. | \-(function (message = NULL, class = NULL, ..., trace = NULL, parent = NULL, ...
 15. |   \-rlang:::signal_abort(cnd)
 16. |     \-base::signalCondition(cnd)
 17. +-(function (e) ...
 18. | \-rlang::abort(...)
 19. |   \-rlang:::signal_abort(cnd)
 20. |     \-base::signalCondition(cnd)
 21. \-(function (cnd) ...

**Tags:** r, rna-seq, limma

---

## 1 answers

### Answer by username_1 on 2021-03-29. Score: 1 | Accepted answer

The error is telling you that there isn't any Infected column on the model.matrix.
Check the column names of `mm`. Also not sure that having two `~` will work well.

> **Comments:**
> **username_0**: I did notice the ~~ mistake thanks for pointing it out.  

---

