DESeqDataSetFromMatrix gives a 'dimnames are not identical error' in R 4.0 that worked fine in R 3.6.1.
1
1
Entering edit mode
lessismore ▴ 20
@lessismore
Last seen 9 weeks ago
Italy

The code that used to work in R 3.6.1 is giving me an error in R 4.0. The exact error is discussed in the github thread at github/Bioconductor/SummarizedExperiment/ but I have trouble understanding how to address the issue based on the discussion there. The culprit is the following line:

DESeqDataSetFromMatrix(countData=RNASeqCnts$counts, colData=cData, design=~sex+group)

Which gives the error:

Error in `assays<-`(`*tmp*`, withDimnames = withDimnames, ..., value = `*vtmp*`) : please use 'assay(x, withDimnames=FALSE)) <- value' or 'assays(x, withDimnames=FALSE)) <- value' when the dimnames on the supplied assay(s) are not identical to the dimnames on RangedSummarizedExperiment object 'x' 

The variablle RNASeqCnts$counts is the output of the ReadsPerGene files from STAR. Head of the file looks like this:

                     Samples                                                                                                                                                 
 Tags       PM10LTA PM11LTA PM12LTA PM14LTA PM17RTA PM1LTA PM21LTA                                                                                                 
   ENSMUSG1       0       0       0       0       0      0       0                                                                                                 
   ENSMUSG2       0       0       0       0       0      0       0                                                                                                 
   ENSMUSG3       0       0       2       0       0      0       0                                                                                                 
   ENSMUSG4       0       0       0       0       0      0       0  

Please let me know if dim() information is also needed, and for which variables if that would help. I have included both sessionInfos at the end.

Thank you.

 R version 4.0.0 (2020-04-24)                                                                                                                                                
 Platform: x86_64-pc-linux-gnu (64-bit)                                                                                                                                      
 Running under: Red Hat Enterprise Linux Server release 6.10 (Santiago)                                                                                                      

 Matrix products: default                                                                                                                                                    
 BLAS:   /share/pkg/R/4.0.0_gcc/lib64/R/lib/libRblas.so                                                                                                                      
 LAPACK: /share/pkg/R/4.0.0_gcc/lib64/R/lib/libRlapack.so                                                                                                                    

 locale:                                                                                                                                                                     
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                                                                                                                                
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8                                                                                                                      
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8                                                                                                                     
  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                                                                                                                                   
  [9] LC_ADDRESS=C               LC_TELEPHONE=C                                                                                                                              
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C                                                                                                                         

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

 other attached packages:                                                                                                                                                    
  [1] biomaRt_2.46.0              dplyr_1.0.2                                                                                                                                
  [3] edgeR_3.32.0                limma_3.46.0                                                                                                                               
  [5] DESeq2_1.30.0               SummarizedExperiment_1.20.0                                                                                                                
  [7] Biobase_2.50.0              MatrixGenerics_1.2.0                                                                                                                       
  [9] matrixStats_0.57.0          GenomicRanges_1.42.0                                                                                                                       
 [11] GenomeInfoDb_1.26.2         IRanges_2.24.1                                                                                                                             
 [13] S4Vectors_0.28.1            BiocGenerics_0.36.0                                                                                                                        
 [15] WGCNA_1.69                  fastcluster_1.1.25                                                                                                                         
 [17] dynamicTreeCut_1.63-1   

 loaded via a namespace (and not attached):                                                                                                                                  
  [1] bitops_1.0-6           bit64_4.0.5            progress_1.2.2                                                                                                           
  [4] doParallel_1.0.15      RColorBrewer_1.1-2     httr_1.4.2                                                                                                               
  [7] tools_4.0.0            backports_1.2.1        R6_2.5.0                                                                                                                 
 [10] rpart_4.1-15           Hmisc_4.4-2            DBI_1.1.0                                                                                                                
 [13] colorspace_2.0-0       nnet_7.3-14            prettyunits_1.1.1                                                                                                        
 [16] tidyselect_1.1.0       gridExtra_2.3          curl_4.3                                                                                                                 
 [19] bit_4.0.4              compiler_4.0.0         preprocessCore_1.52.0                                                                                                    
 [22] htmlTable_2.1.0        xml2_1.3.2             DelayedArray_0.16.0                                                                                                      
 [25] scales_1.1.1           checkmate_2.0.0        genefilter_1.72.0                                                                                                        
 [28] askpass_1.1            rappdirs_0.3.1         stringr_1.4.0                                                                                                            
 [31] digest_0.6.25          foreign_0.8-78         XVector_0.30.0                                                                                                           
 [34] base64enc_0.1-3        jpeg_0.1-8.1           pkgconfig_2.0.3                                                                                                          
 [37] htmltools_0.5.0        dbplyr_2.0.0           htmlwidgets_1.5.1                                                                                                        
 [40] rlang_0.4.8            rstudioapi_0.11        RSQLite_2.2.1                                                                                                            
 [43] impute_1.64.0          generics_0.1.0         BiocParallel_1.24.1                                                                                                      
 [46] RCurl_1.98-1.2         magrittr_1.5           GO.db_3.12.1                                                                                                             
 [49] GenomeInfoDbData_1.2.4 Formula_1.2-4          Matrix_1.2-18                                                                                                            
 [52] Rcpp_1.0.5             munsell_0.5.0          lifecycle_0.2.0   
 [55] stringi_1.4.6          zlibbioc_1.36.0        BiocFileCache_1.14.0                                                                                                     
 [58] grid_4.0.0             blob_1.2.1             crayon_1.3.4                                                                                                             
 [61] lattice_0.20-41        splines_4.0.0          annotate_1.68.0                                                                                                          
 [64] hms_0.5.3              locfit_1.5-9.4         knitr_1.28                                                                                                               
 [67] pillar_1.4.4           geneplotter_1.68.0     codetools_0.2-18                                                                                                         
 [70] XML_3.99-0.5           glue_1.4.1             latticeExtra_0.6-29                                                                                                      
 [73] data.table_1.13.6      png_0.1-7              vctrs_0.3.5                                                                                                              
 [76] foreach_1.5.0          openssl_1.4.1          gtable_0.3.0                                                                                                             
 [79] purrr_0.3.4            assertthat_0.2.1       ggplot2_3.3.3                                                                                                            
 [82] xfun_0.14              xtable_1.8-4           survival_3.1-12                                                                                                          
 [85] tibble_3.0.1           iterators_1.0.12       AnnotationDbi_1.52.0                                                                                                     
 [88] memoise_1.1.0          cluster_2.1.0          ellipsis_0.3.1
DESeq2 SummarizedExperiment • 916 views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen 22 hours ago
United States

I'm wondering if you have a valid Bioc installation? Can you run BiocManager::valid()?

At some point I had to change the internal code of DESeq2 to add the withDimnames arguments, but I did so to match the updates to SummarizedExperiment. So if you have a valid installation it shouldn't be an issue.

Alternatively, I guess you could get around this by ensuring the rownames of colData and the colnames of counts are identical.

ADD COMMENT
0
Entering edit mode
BiocManager::valid()

* sessionInfo()

R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.10 (Santiago)

Matrix products: default
BLAS:   /share/pkg/R/4.0.0_gcc/lib64/R/lib/libRblas.so
LAPACK: /share/pkg/R/4.0.0_gcc/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] DESeq2_1.30.0               SummarizedExperiment_1.20.0
 [3] Biobase_2.50.0              MatrixGenerics_1.2.0       
 [5] matrixStats_0.57.0          GenomicRanges_1.42.0       
 [7] GenomeInfoDb_1.26.2         IRanges_2.24.1             
 [9] S4Vectors_0.28.1            BiocGenerics_0.36.0        
[11] WGCNA_1.69                  fastcluster_1.1.25         
[13] dynamicTreeCut_1.63-1      

loaded via a namespace (and not attached):
 [1] httr_1.4.2             bit64_4.0.5            splines_4.0.0         
 [4] foreach_1.5.1          Formula_1.2-4          BiocManager_1.30.10   
 [7] latticeExtra_0.6-29    blob_1.2.1             GenomeInfoDbData_1.2.4
[10] impute_1.64.0          pillar_1.4.7           RSQLite_2.2.2         
[13] backports_1.2.1        lattice_0.20-41        glue_1.4.2            
[16] digest_0.6.27          RColorBrewer_1.1-2     XVector_0.30.0        
[19] checkmate_2.0.0        colorspace_2.0-0       htmltools_0.5.0       
[22] preprocessCore_1.52.1  Matrix_1.3-2           XML_3.99-0.5          
[25] pkgconfig_2.0.3        genefilter_1.72.0      zlibbioc_1.36.0       
[28] xtable_1.8-4           purrr_0.3.4            GO.db_3.12.1          
[31] scales_1.1.1           jpeg_0.1-8.1           BiocParallel_1.24.1   
[34] annotate_1.68.0        htmlTable_2.1.0        tibble_3.0.4          
[37] generics_0.1.0         ggplot2_3.3.3          ellipsis_0.3.1        
[40] nnet_7.3-14            survival_3.2-7         magrittr_2.0.1        
[43] crayon_1.3.4           memoise_1.1.0          doParallel_1.0.16     
[46] foreign_0.8-81         tools_4.0.0            data.table_1.13.6     
[49] lifecycle_0.2.0        stringr_1.4.0          locfit_1.5-9.4        
[52] munsell_0.5.0          DelayedArray_0.16.0    cluster_2.1.0         
[55] AnnotationDbi_1.52.0   compiler_4.0.0         rlang_0.4.10          
[58] grid_4.0.0             RCurl_1.98-1.2         iterators_1.0.13      
[61] rstudioapi_0.13        htmlwidgets_1.5.3      bitops_1.0-6          
[64] base64enc_0.1-3        gtable_0.3.0           codetools_0.2-18      
[67] DBI_1.1.0              R6_2.5.0               gridExtra_2.3         
[70] knitr_1.30             dplyr_1.0.2            bit_4.0.4             
[73] Hmisc_4.4-2            stringi_1.5.3          Rcpp_1.0.5            
[76] geneplotter_1.68.0     vctrs_0.3.6            rpart_4.1-15          
[79] png_0.1-7              tidyselect_1.1.0       xfun_0.20             

Bioconductor version '3.12'

  * 53 packages out-of-date
  * 0 packages too new

create a valid installation with

  BiocManager::install(c(
    "backports", "BH", "callr", "cli", "clipr", "covr", "crosstalk", "devtools",
    "digest", "doParallel", "DT", "foghorn", "foreach", "fs", "gh", "git2r",
    "glue", "htmlwidgets", "httr", "hunspell", "iterators", "jsonlite",
    "knitr", "magrittr", "nloptr", "openssl", "PAIRADISE", "pillar", "pingr",
    "pkgbuild", "pkgdown", "processx", "ps", "R6", "Rcpp", "remotes", "rlang",
    "rmarkdown", "roxygen2", "rprojroot", "rstudioapi", "rvest", "spelling",
    "stringi", "sys", "testthat", "tibble", "tinytex", "usethis", "vctrs",
    "withr", "xfun", "xmlparsedata"
  ), update = TRUE, ask = FALSE)

more details: BiocManager::valid()$too_new, BiocManager::valid()$out_of_date

Warning message:
53 packages out-of-date; 0 packages too new 

I tried running the suggested BiocManager::install() but I always end up with these packages installing with a non-zero status. Is any of them needed for DESeq2?

ADD REPLY
0
Entering edit mode

This could explain the error you are seeing, but if you want to just fix the error without dealing with installation, you can try my alternative approach (remove conflicting names).

ADD REPLY
0
Entering edit mode

Thank you!

ADD REPLY
0
Entering edit mode

Hi Michael,

I have had this issue since the update to the Summarized Experiment and I was checking if there was an update to the issue I've had previously. Until recently I couldn't get my installation to be valid but a recent update to the packages fixed that. Before that I have been keeping a separate R 3.6 installation just for the generation of the DESeq data matrix.

But, now I have a valid installation and according to your answer above, my rownames of colData and the colnames of counts are both identical and I still get this error. Let me know if there is anything else I can do. I'm replying to this comment because it is relevant to the original post, but if the etiquette is to open a new question, I can do that.

Thank you.

> dds_data <- DESeqDataSetFromMatrix(RNASeqCnts$counts, colData=cData, design=designF)  
converting counts to integer mode                     
Error in `assays<-`(`*tmp*`, withDimnames = withDimnames, ..., value = `*vtmp*`) :                                                            
please use 'assay(x, withDimnames=FALSE)) <- value' or 'assays(x,      
withDimnames=FALSE)) <- value' when the dimnames on the supplied       
assay(s) are not identical to the dimnames on                          
RangedSummarizedExperiment object 'x'  



 > colnames(RNASeqCnts$counts) == rownames(cData)                                                                                                                                   

[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

 > cData

                   sampleName group subject n.cells                                                                                                                             
 101_S3_R1_001   101_S3_R1_001    AD       1      10                                                                                                                             
 104_S10_R1_001 104_S10_R1_001    AD       2      10                                                                                                                             
 13_S4_R1_001     13_S4_R1_001     C       1       1                                                                                                                             
 14_S7_R1_001     14_S7_R1_001    AD       2       1                                                                                                                             
 31_S1_R1_001     31_S1_R1_001    AD       1       3                                                                                                                             
 33_S5_R1_001     33_S5_R1_001     C       1       3                                                                                                                             
 34_S8_R1_001     34_S8_R1_001    AD       2       3                                                                                                                             
 51_S2_R1_001     51_S2_R1_001    AD       1       5                                                                                                                             
 53_S6_R1_001     53_S6_R1_001     C       1       5                                                                                                                             
 54_S9_R1_001     54_S9_R1_001    AD       2       5  

> colnames(RNASeqCnts$counts)                                                                                                                                                    
  [1] "101_S3_R1_001"  "104_S10_R1_001" "13_S4_R1_001"   "14_S7_R1_001"                                                                                                          
  [5] "31_S1_R1_001"   "33_S5_R1_001"   "34_S8_R1_001"   "51_S2_R1_001"                                                                                                          
  [9] "53_S6_R1_001"   "54_S9_R1_001"

> BiocManager::valid()                                                                                                                                                          
 [1] TRUE                                
ADD REPLY
1
Entering edit mode

Try restarting your R session. I think this was limited to those with mixed installations.

We’ve never had this issue on the bioc build machines for example.

If that fails you can remove dimnames from the count matrix, and then add rownames after.

ADD REPLY
0
Entering edit mode

Restarting the R session did not work. But your other suggestion worked. Thank you.

For the future readers, addition of the following lines worked.

rnaSeqCnts.dimnames <-  dimnames(rnaSeqCnts)                                                                                                                                     
dimnames(rnaSeqCnts) <- c()                                                                                                                                                      

designF <- as.formula(~group)                                                                                                                                                    
dds_data <- DESeqDataSetFromMatrix(rnaSeqCnts$counts, colData=cData, design=designF)            
dimnames(dds_data) <- rnaSeqCnts.dimnames                                 
ADD REPLY
0
Entering edit mode

Excuse me,Sir. I wonder which location should I put these word in?

ADD REPLY
0
Entering edit mode
> sessionInfo()                                                                                                                                                                 
 R version 4.0.4 (2021-02-15)                                                                                                                                                    
 Platform: x86_64-pc-linux-gnu (64-bit)                                                                                                                                          
 Running under: Red Hat Enterprise Linux Server release 6.10 (Santiago)                                                                                                          

 Matrix products: default                                                                                                                                                        
 BLAS:   /share/pkg/R/4.0.4_gcc/lib64/R/lib/libRblas.so                                                                                                                          
 LAPACK: /share/pkg/R/4.0.4_gcc/lib64/R/lib/libRlapack.so                                                                                                                        

 locale:                                                                                                                                                                         
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C                                                                                                                                    
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8                                                                                                                          
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8                                                                                                                         
  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                                                                                                                                       
  [9] LC_ADDRESS=C               LC_TELEPHONE=C                                                                                                                                  
 [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C                                                                                                                             

 attached base packages:                                                                                                                                                         
 [1] parallel  stats4    stats     graphics  grDevices utils     datasets                                                                                                        
 [8] methods   base                                         
ADD REPLY
0
Entering edit mode
other attached packages:                                                                                                                                                        
      [1] gridExtra_2.3               dplyr_1.0.7                                                                                                                                    
      [3] biomaRt_2.46.3              edgeR_3.32.1                                                                                                                                   
      [5] limma_3.46.0                ggplot2_3.3.5                                                                                                                                  
      [7] DESeq2_1.30.1               SummarizedExperiment_1.20.0                                                                                                                    
      [9] Biobase_2.50.0              MatrixGenerics_1.2.1                                                                                                                           
     [11] matrixStats_0.61.0          GenomicRanges_1.42.0                                                                                                                           
     [13] GenomeInfoDb_1.26.7         IRanges_2.24.1                                                                                                                                 
     [15] S4Vectors_0.28.1            BiocGenerics_0.36.1                                                                                                                            
     [17] reshape_0.8.8               clusterProfiler_3.18.1  

    loaded via a namespace (and not attached):                                                                                                                                      
      [1] fgsea_1.16.0           colorspace_2.0-2       ellipsis_0.3.2                                                                                                               
      [4] qvalue_2.22.0          XVector_0.30.0         farver_2.1.0                                                                                                                 
      [7] graphlayouts_0.7.1     ggrepel_0.9.1          bit64_4.0.5                                                                                                                  
     [10] AnnotationDbi_1.52.0   fansi_0.5.0            scatterpie_0.1.7                                                                                                             
     [13] xml2_1.3.2             splines_4.0.4          cachem_1.0.6                                                                                                                 
     [16] GOSemSim_2.16.1        geneplotter_1.68.0     polyclip_1.10-0                                                                                                              
     [19] annotate_1.68.0        dbplyr_2.1.1           GO.db_3.12.1                                                                                                                 
     [22] ggforce_0.3.3          BiocManager_1.30.16    compiler_4.0.4                                                                                                               
     [25] httr_1.4.2             rvcheck_0.2.1          assertthat_0.2.1                                                                                                             
     [28] Matrix_1.3-4           fastmap_1.1.0          tweenr_1.0.2                                                                                                                 
     [31] prettyunits_1.1.1      tools_4.0.4            igraph_1.2.7                                                                                                                 
     [34] gtable_0.3.0           glue_1.4.2             GenomeInfoDbData_1.2.4                                                                                                       
     [37] reshape2_1.4.4         DO.db_2.9              rappdirs_0.3.3                                                                                                               
     [40] fastmatch_1.1-3        Rcpp_1.0.7             enrichplot_1.10.2                                                                                                            
     [43] vctrs_0.3.8            ggraph_2.0.5           stringr_1.4.0                                                                                                                
     [46] lifecycle_1.0.1        XML_3.99-0.8           DOSE_3.16.0                                                                                                                  
     [49] zlibbioc_1.36.0        MASS_7.3-54            scales_1.1.1                                                                                                                 
     [52] tidygraph_1.2.0        hms_1.1.1              RColorBrewer_1.1-2                                                                                                           
     [55] curl_4.3.2             memoise_2.0.0          downloader_0.4                                                                                                               
     [58] ggfun_0.0.4            yulab.utils_0.0.4      stringi_1.7.5                                                                                                                
     [61] RSQLite_2.2.8          genefilter_1.72.1      BiocParallel_1.24.1                                                                                                          
     [64] rlang_0.4.12           pkgconfig_2.0.3        bitops_1.0-7                                                                                                                 
     [67] lattice_0.20-45        purrr_0.3.4            cowplot_1.1.1                                                                                                                
     [70] shadowtext_0.0.9       bit_4.0.4              tidyselect_1.1.1                                                                                                             
     [73] plyr_1.8.6             magrittr_2.0.1         R6_2.5.1                                                                                                                     
     [76] generics_0.1.1         DelayedArray_0.16.3    DBI_1.1.1                                                                                                                    
     [79] pillar_1.6.4           withr_2.4.2            survival_3.2-13                                                                                                              
     [82] RCurl_1.98-1.5         tibble_3.1.5           crayon_1.4.2                                                                                                                 
     [85] utf8_1.2.2             BiocFileCache_1.14.0   viridis_0.6.2                                                                                                                
     [88] progress_1.2.2         locfit_1.5-9.4         grid_4.0.4                                                                                                                   
     [91] data.table_1.14.2      blob_1.2.2             digest_0.6.28                                                                                                                
     [94] xtable_1.8-4           tidyr_1.1.4            openssl_1.4.5                                                                                                                
     [97] munsell_0.5.0          viridisLite_0.4.0      askpass_1.1  
ADD REPLY

Login before adding your answer.

Traffic: 470 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