DESeq2 error: "vector: cannot make a vector of mode 'S4'"
1
1
Entering edit mode
ben.langmead ▴ 20
@benlangmead-16833
Last seen 5.6 years ago

I am trying to run the recount2 getting started guide (or a slight adaptation of it to use JHU's SciServer resource) on R 3.4.1 and Bioconductor 3.6.  I get the following output and error:

converting counts to integer mode
estimating size factors
estimating dispersions
gene-wise dispersion estimates: 14 workers
mean-dispersion relationship
final dispersion estimates, fitting model and testing: 14 workers
Error in vector(mode(x), length(NArows)): vector: cannot make a vector of mode 'S4'.
Traceback:

1. DESeq(dds, test = "LRT", reduced = ~gene_target, fitType = "local", 
 .     parallel = T)
2. DESeqParallel(object, test = test, fitType = fitType, betaPrior = betaPrior, 
 .     full = full, reduced = reduced, quiet = quiet, modelMatrix = modelMatrix, 
 .     modelMatrixType = modelMatrixType, BPPARAM = BPPARAM)
3. buildDataFrameWithNARows(mcols(objectNZ), mcols(object)$allZero)
4. DataFrame(lapply(resultsList, function(x) vector(mode(x), length(NArows))))
5. lapply(resultsList, function(x) vector(mode(x), length(NArows)))
6. lapply(resultsList, function(x) vector(mode(x), length(NArows)))
7. lapply(as.list(X), FUN = FUN, ...)
8. lapply(as.list(X), FUN = FUN, ...)
9. FUN(X[[i]], ...)

A more complete listing of the Jupyter notebook session that led to the error is here: http://www.cs.jhu.edu/~langmea/resources/recount_quickstart_error.html.

Any thoughts are much appreciated.

Best, Ben

Session info:

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.5 (Nitrogen)

Matrix products: default
BLAS: /home/idies/miniconda3/lib/R/lib/libRblas.so
LAPACK: /home/idies/miniconda3/lib/R/lib/libRlapack.so

locale:
[1] C

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] DESeq2_1.18.1              SciServer_2.0.0           
 [3] recount_1.4.6              SummarizedExperiment_1.8.1
 [5] DelayedArray_0.4.1         matrixStats_0.53.1        
 [7] Biobase_2.38.0             GenomicRanges_1.30.3      
 [9] GenomeInfoDb_1.14.0        IRanges_2.12.0            
[11] S4Vectors_0.16.0           BiocGenerics_0.24.0       

loaded via a namespace (and not attached):
  [1] colorspace_1.3-2         IRdisplay_0.4.4          qvalue_2.10.0           
  [4] htmlTable_1.9            XVector_0.18.0           base64enc_0.1-3         
  [7] bit64_0.9-5              AnnotationDbi_1.40.0     xml2_1.2.0              
 [10] codetools_0.2-15         splines_3.4.1            geneplotter_1.56.0      
 [13] knitr_1.20               IRkernel_0.8.12          Formula_1.2-1           
 [16] jsonlite_1.5             Rsamtools_1.30.0         annotate_1.56.0         
 [19] cluster_2.0.6            rentrez_1.1.0            readr_1.1.1             
 [22] compiler_3.4.1           httr_1.3.1               backports_1.1.2         
 [25] assertthat_0.2.0         Matrix_1.2-14            lazyeval_0.2.1          
 [28] limma_3.34.9             acepack_1.4.1            htmltools_0.3.6         
 [31] prettyunits_1.0.2        tools_3.4.1              bindrcpp_0.2.2          
 [34] gtable_0.2.0             glue_1.3.0               GenomeInfoDbData_1.0.0  
 [37] reshape2_1.4.3           dplyr_0.7.6              doRNG_1.6.6             
 [40] Rcpp_0.12.17             bumphunter_1.20.0        Biostrings_2.46.0       
 [43] rtracklayer_1.38.3       iterators_1.0.10         stringr_1.3.1           
 [46] rngtools_1.3.1           XML_3.98-1.11            zlibbioc_1.24.0         
 [49] scales_0.5.0             BSgenome_1.46.0          VariantAnnotation_1.24.1
 [52] hms_0.3                  GEOquery_2.46.15         derfinderHelper_1.12.0  
 [55] RColorBrewer_1.1-2       curl_3.2                 memoise_1.1.0           
 [58] gridExtra_2.3            ggplot2_3.0.0            downloader_0.4          
 [61] pkgmaker_0.22            biomaRt_2.34.2           rpart_4.1-13            
 [64] latticeExtra_0.6-28      stringi_1.2.3            RSQLite_2.0             
 [67] genefilter_1.60.0        foreach_1.4.4            RMySQL_0.10.13          
 [70] checkmate_1.8.5          GenomicFeatures_1.28.5   BiocParallel_1.12.0     
 [73] repr_0.15.0              rlang_0.2.1              pkgconfig_2.0.1         
 [76] GenomicFiles_1.14.0      bitops_1.0-6             evaluate_0.10.1         
 [79] lattice_0.20-34          purrr_0.2.4              bindr_0.1.1             
 [82] GenomicAlignments_1.14.1 htmlwidgets_1.0          bit_1.1-12              
 [85] tidyselect_0.2.4         plyr_1.8.4               magrittr_1.5            
 [88] R6_2.2.2                 Hmisc_4.0-3              pbdZMQ_0.3-2            
 [91] DBI_1.0.0                pillar_1.2.2             foreign_0.8-67          
 [94] survival_2.42-6          RCurl_1.95-4.11          nnet_7.3-12             
 [97] tibble_1.4.2             crayon_1.3.4             derfinder_1.12.0        
[100] uuid_0.1-2               progress_1.2.0           locfit_1.5-9.1          
[103] grid_3.4.1               data.table_1.11.4        blob_1.1.1              
[106] digest_0.6.15            xtable_1.8-2             tidyr_0.8.1             
[109] munsell_0.5.0            registry_0.5
deseq2 • 1.4k views
ADD COMMENT
3
Entering edit mode
@mikelove
Last seen 9 hours ago
United States

It looks like the bug is from some code I have where I build out the rowData / mcols after dealing with rows that have all zeros for all samples (that’s this buildDataFrameWithNARows). It’s having trouble with one of the columns in mcols(dds) which is not a simple mode (numeric, logical, character) but instead S4. So it’s a bug on my end (in version 1.18).

One quick fix would be to filter out genes with all zeros so DESeq2 doesn’t have to manually deal with this S4 column (I think this will work, maybe not), or  to see which column of mcols(dds) is a complex object and if it’s not necessary to remove it or convert it to something simpler. E.g.:

lapply(mcols(dds), class)
mcols(dds)$symbol <- unlist(lapply(mcols(dds)$symbol, paste, collapse=","))

Note: this appears to not be a bug in the current release branch (or if that is not the case, let me know and I'll address it).

ADD COMMENT
2
Entering edit mode

I'm trying to recreate this bug with this rse_gene object in the release branch of Bioc (3.7):

suppressPackageStartupMessages(library(DESeq2))
load("rse_gene.Rdata")
rse_gene$condition <- factor(rep(1:2,each=6))
dds <- DESeqDataSet(rse_gene, ~condition)
dds <- DESeq(dds)
# or
dds <- DESeq(dds, reduced=~1, test="LRT")
# or 
dds <- DESeq(dds, reduced=~1, test="LRT", parallel=TRUE)

This doesn't give an error for me on the current release, so DESeq2 v1.20.

I have Bioc 3.6 on a different machine, so I can test this later, but I won't be able to provide a fix because the previous release branches are frozen.

ADD REPLY
1
Entering edit mode

Your workaround that string-izes the `$symbol` column works like a charm, thank you!

 

I'm subject to these particular versions because the folks who run SciServer use the bioconda Bioconductor distribution and I don't think the latest R/Bioconductor versions are available there yet (https://github.com/bioconda/bioconda-recipes/issues/8947).  Anyway, I'm grateful for this very quick help!

ADD REPLY
0
Entering edit mode

Thanks for providing a workaround Mike and for debugging this together with Ben!

Best,

Leo

ADD REPLY

Login before adding your answer.

Traffic: 725 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6