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.


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.


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)

         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`.
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`.
  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) ...
  • 1
    $\begingroup$ Why does that get downvoted? It contains code and obviously invested effort, being on-topic. At least add a comment what you do not like. This random downvoting thing is so toxic. As for the question, I would run filterByExpr rather than a custom filter, this is probably a bit more reliable. Please show the requested colnames of mm. $\endgroup$ – ATpoint Mar 29 at 8:55
  • $\begingroup$ @ATpoint Its very annoying as a newcomer to bioinformatics and r and to get that kind of response. I appreciate your comment. I solved the problem on my own, partly it was because of a typo (I had two ~~) but also I had changed something in 'dge$samples$dge_meta' without realizing it. $\endgroup$ – Angus Campbell Mar 31 at 2:16
  • $\begingroup$ @ATpoint I downvoted the question and I left an answer (not a comment). Why you question the upvotes too? I don't find the question useful as there are many questions about similar, if not exact, error online. AngusCampbell if you don't want downvotes you can post your questions on support.bioconductor.org were it's not possible to downvote. $\endgroup$ – llrs Mar 31 at 7:41
  • $\begingroup$ @IIrs If you feel a question is similar to another answer, flag it as such and provide a link to the question you belive provides the answer. Moderators will then close my question or leave it up as other may find it useful. Personally when I search my error with "topTable subscript out of bounds" it is the only question that is returned by that search. This is why I posted the question, nothing came up before when I searched it. ATpoint was not directing criticism at you, the user was commenting on the fact that it seems strange to down vote a question with clear effort invested. $\endgroup$ – Angus Campbell Mar 31 at 20:28
  • $\begingroup$ @IIrs stack is meant to be a community where we can learn from errors receive feedback. Frankly the way you have answered was sarcastic, I didn't say anything but there are politer ways to respond. Also the voting system is ammonized for a reason to prevent personal confrontations in the comments. So its fine to downvote, and leave a reason for the downvote as its fine for ATpoint to comment on the validity of that downvote but I think by trying to personally go after users you disagree with is not constructive. $\endgroup$ – Angus Campbell Mar 31 at 20:33

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.

  • $\begingroup$ I did notice the ~~ mistake thanks for pointing it out. $\endgroup$ – Angus Campbell Mar 31 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.