1
$\begingroup$

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()
<error/dplyr_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()
<error/dplyr_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:
     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) ...
$\endgroup$
0

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ I did notice the ~~ mistake thanks for pointing it out. $\endgroup$ Mar 31, 2021 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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