Error in SummarizedExperiment
2
0
Entering edit mode
Talpham • 0
@e4d6761d
Last seen 6 days ago
Belgium

I have installed DESeq2 version 1.36.0

samples <- colnames(txi$counts)

group <- as.factor(c("control","control","control","control","control","diet","diet","diet","diet","diet",
                               "control","control","control","control","control","diet","diet","diet","diet","diet","diet")) 
coldata <- data.frame(samples,
                 group,
                 stringsAsFactors = F)

coldata <- coldata[,c("samples","group")]
coldata$samples <- factor(coldata$samples)
coldata$group <- factor(coldata$group)
rownames(coldata) <- sub("fb", "", rownames(coldata))
all(rownames(coldata$samples) %in% colnames(txi))

all(rownames(coldata) == colnames(txi)) 
 TRUE

library(DESeq2)
ddsTxi <- DESeqDataSetFromTximport(txi,
                                   colData = coldata,
                                   design = ~ group)

I get in the final line:

Error in SummarizedExperiment(assays = SimpleList(counts = countData), : 
the rownames and colnames of the supplied assay(s) must be NULL or identical to those of the SummarizedExperiment object
(or derivative) to construct

4. stop(wmsg("the ", what, " of the supplied assay(s) must be NULL ", "or identical to those of the ", class(ans), " object ", "(or derivative) to construct"))
3. SummarizedExperiment(assays = SimpleList(counts = countData), colData = colData, ...)
2.DESeqDataSetFromMatrix(countData = counts, colData = colData, design = design, ...)
1.DESeqDataSetFromTximport(txi, colData = coldata, design = ~group) > sessionInfo( )

> sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

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

other attached packages:
 [1] DESeq2_1.36.0               SummarizedExperiment_1.26.0 MatrixGenerics_1.8.0        matrixStats_0.62.0          GenomicRanges_1.48.0       
 [6] GenomeInfoDb_1.32.1         IRanges_2.30.0              S4Vectors_0.34.0            tximportData_1.24.0         readr_2.1.2                
[11] edgeR_3.38.0                limma_3.52.0                dplyr_1.0.8                 magrittr_2.0.3              tximport_1.24.0            
[16] biomaRt_2.52.0              GEOquery_2.64.0             Biobase_2.56.0              BiocGenerics_0.42.0        

loaded via a namespace (and not attached):
  [1] Mus.musculus_1.3.1                        rappdirs_0.3.3                            rtracklayer_1.55.4                       
  [4] ggthemes_4.2.4                            Glimma_2.6.0                              tidyr_1.2.0                              
  [7] ggplot2_3.3.5                             bit64_4.0.5                               knitr_1.39                               
 [10] irlba_2.3.5                               DelayedArray_0.22.0                       data.table_1.14.2                        
 [13] rpart_4.1.16                              hwriter_1.3.2.1                           KEGGREST_1.36.0                          
 [16] RCurl_1.98-1.6                            AnnotationFilter_1.20.0                   generics_0.1.2                           
 [19] GenomicFeatures_1.48.0                    org.Mm.eg.db_3.15.0                       preprocessCore_1.58.0                    
 [22] ScaledMatrix_1.4.0                        RSQLite_2.2.12                            bit_4.0.4                                
 [25] tzdb_0.3.0                                webshot_0.5.3                             lubridate_1.8.0                          
 [28] xml2_1.3.3                                assertthat_0.2.1                          tidyverse_1.3.1                          
 [31] viridis_0.6.2                             oligo_1.60.0                              xfun_0.30                                
 [34] hms_1.1.1                                 evaluate_0.15                             fansi_1.0.3                              
 [37] restfulr_0.0.13                           progress_1.2.2                            readxl_1.4.0                             
 [40] dbplyr_2.1.1                              igraph_1.3.1                              DBI_1.1.2                                
 [43] geneplotter_1.74.0                        htmlwidgets_1.5.4                         purrr_0.3.4                              
 [46] ellipsis_0.3.2                            backports_1.4.1                           hgu95acdf_2.18.0                         
 [49] annotate_1.74.0                           sparseMatrixStats_1.8.0                   vctrs_0.4.1                              
 [52] SingleCellExperiment_1.18.0               ensembldb_2.20.0                          abind_1.4-5                              
 [55] beadarray_2.46.0                          withr_2.5.0                               cachem_1.0.6                             
 [58] gcrma_2.68.0                              vroom_1.5.7                               checkmate_2.1.0                          
 [61] GenomicAlignments_1.32.0                  prettyunits_1.1.1                         scran_1.24.0                             
 [64] TxDb.Mmusculus.UCSC.mm10.knownGene_3.10.0 svglite_2.1.0                             cluster_2.1.3                            
 [67] lazyeval_0.2.2                            crayon_1.5.1                              genefilter_1.78.0                        
 [70] pkgconfig_2.0.3                           vipor_0.4.5                               ProtGenerics_1.28.0                      
 [73] nnet_7.3-17                               rlang_1.0.2                               ecolicdf_2.18.0                          
 [76] lifecycle_1.0.1                           SpikeInSubset_1.36.0                      filelock_1.0.2                           
 [79] BeadDataPackR_1.48.0                      affyio_1.66.0                             ALLMLL_1.36.0                            
 [82] BiocFileCache_2.4.0                       modelr_0.1.8                              rsvd_1.0.5                               
 [85] cellranger_1.1.0                          graph_1.74.0                              base64_2.0                               
 [88] Matrix_1.4-1                              carData_3.0-5                             hgu133bcdf_2.18.0                        
 [91] affyPLM_1.71.0                            reprex_2.0.1                              base64enc_0.1-3                          
 [94] beeswarm_0.4.0                            png_0.1-7                                 viridisLite_0.4.0                        
 [97] rjson_0.2.21                              bitops_1.0-7                              hgu133plus2cdf_2.18.0                    
[100] Biostrings_2.64.0                         blob_1.2.3                                DelayedMatrixStats_1.18.0                
[103] stringr_1.4.0                             jpeg_0.1-9                                beachmat_2.12.0                          
[106] scales_1.2.0                              memoise_2.0.1                             plyr_1.8.7                               
[109] hexbin_1.28.2                             zlibbioc_1.42.0                           compiler_4.2.0                           
[112] factoextra_1.0.7                          kableExtra_1.3.4                          dqrng_0.3.0                              
[115] BiocIO_1.6.0                              RColorBrewer_1.1-3                        illuminaio_0.38.0                        
[118] Rsamtools_2.12.0                          cli_3.3.0                                 affy_1.74.0                              
[121] XVector_0.36.0                            oligoClasses_1.58.0                       htmlTable_2.4.0                          
[124] Formula_1.2-4                             MASS_7.3-56                               hgu95av2.db_3.13.0                       
[127] tidyselect_1.1.2                          vsn_3.64.0                                forcats_0.5.1                            
[130] stringi_1.7.6                             mouse4302cdf_2.18.0                       yaml_2.3.5                               
[133] BiocSingular_1.12.0                       askpass_1.1                               locfit_1.5-9.5                           
[136] latticeExtra_0.6-29                       ggrepel_0.9.1                             grid_4.2.0                               
[139] tools_4.2.0                               soybeancdf_2.18.0                         parallel_4.2.0                           
[142] rstudioapi_0.13                           bluster_1.6.0                             foreach_1.5.2                            
[145] foreign_0.8-82                            metapod_1.4.0                             arrayQualityMetrics_3.52.0               
[148] gridExtra_2.3                             Rtsne_0.16                                digest_0.6.29                            
[151] BiocManager_1.30.17                       ff_4.0.5                                  Rcpp_1.0.8.3                             
[154] car_3.0-12                                broom_0.8.0                               setRNG_2022.4-1                          
[157] scuttle_1.6.0                             pd.hg.u133.plus.2_3.12.0                  OrganismDbi_1.38.0                       
[160] httr_1.4.2                                AnnotationDbi_1.58.0                      colorspace_2.0-3                         
[163] rvest_1.0.2                               fs_1.5.2                                  XML_3.99-0.9                             
[166] splines_4.2.0                             statmod_1.4.36                            RBGL_1.72.0                              
[169] scater_1.24.0                             multtest_2.52.0                           ArrayExpress_1.56.0                      
[172] systemfonts_1.0.4                         xtable_1.8-4                              jsonlite_1.8.0                           
[175] R6_2.5.1                                  Hmisc_4.7-0                               pillar_1.7.0                             
[178] htmltools_0.5.2                           affxparser_1.68.0                         glue_1.6.2                               
[181] fastmap_1.1.0                             BiocParallel_1.30.0                       BiocNeighbors_1.14.0                     
[184] gridSVG_1.7-4                             codetools_0.2-18                          utf8_1.2.2                               
[187] lattice_0.20-45                           tibble_3.1.6                              curl_4.3.2                               
[190] ggbeeswarm_0.6.0                          ggfortify_0.4.14                          GO.db_3.15.0                             
[193] openssl_2.0.0                             survival_3.3-1                            rmarkdown_2.14                           
[196] ecoliLeucine_1.36.0                       munsell_0.5.0                             GenomeInfoDbData_1.2.8                   
[199] iterators_1.0.14                          haven_2.5.0                               reshape2_1.4.4                           
[202] gtable_0.3.0
DESeq2 • 249 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 5 hours ago
United States

Check related posts:

https://www.google.com/search?q=the+rownames+and+colnames+of+the+supplied+assay(s)+deseq2

ADD COMMENT
0
Entering edit mode

Thank you, the labels are the same. Also it has runned once randomly when running line per line, I've tried again but get the error every time

ADD REPLY
0
Entering edit mode

The error is from SummarizedExperiment, and it won't return as an error if the labels were the same -- it's not stochastic. It's just an internal check in SummarizedExperiment, that you don't have mislabelled colData.

ADD REPLY
0
Entering edit mode

Thank you, but when I run:

all(rownames(coldata) == colnames(txi))

it returns TRUE, next also some more information about the variables, where would the mistake be then?

> colnames(txi)
NULL
> rownames(coldata)
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21"
> rownames(txi)
NULL
> colnames(coldata)
[1] "samples" "group"  
> coldata
      samples   group
1  SRR2067497 control
2  SRR2067498 control
3  SRR2067499 control
4  SRR2067500 control
5  SRR2067501 control
6  SRR2067502    diet
7  SRR2067503    diet
8  SRR2067504    diet
9  SRR2067505    diet
10 SRR2067506    diet
11 SRR2067507 control
12 SRR2067508 control
13 SRR2067510 control
14 SRR2067511 control
15 SRR2067512 control
16 SRR2067513    diet
17 SRR2067514    diet
18 SRR2067515    diet
19 SRR2067516    diet
20 SRR2067517    diet
21 SRR2067518    diet
ADD REPLY
0
Entering edit mode

Your all(rownames(coldata) == colnames(txi)) results in NULL which is expected because txi is a list and lists do not have rownames. Be also careful with all(), it returns TRUE if you compare anything to NULL, like all(NULL=="foo"). What you must check is that colnames(txi$counts) == rownames(colData) and that is likely not the case. Better use identical() rather than all(), as the above behaviour of returning TRUE is one annoying pitfall of that function.

ADD REPLY
0
Entering edit mode

Yes indeed thanks! This is what I get:

Error in SummarizedExperiment(assays = SimpleList(counts = countData),  : 
  the rownames and colnames of the supplied assay(s) must be NULL or identical to those of the SummarizedExperiment object
  (or derivative) to construct
> colnames(txi$counts) == rownames(colData)
logical(0)
> colnames(txi$counts)
 [1] "SRR2067497" "SRR2067498" "SRR2067499" "SRR2067500" "SRR2067501" "SRR2067502" "SRR2067503" "SRR2067504" "SRR2067505" "SRR2067506" "SRR2067507"
[12] "SRR2067508" "SRR2067510" "SRR2067511" "SRR2067512" "SRR2067513" "SRR2067514" "SRR2067515" "SRR2067516" "SRR2067517" "SRR2067518"
> rownames(colData)
NULL

Then what do I need to change so that the function runs on my system?

ADD REPLY
0
Entering edit mode

Sorry corrected version:

> colnames(txi$counts) == rownames(coldata)
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> colnames(txi$counts)
 [1] "SRR2067497" "SRR2067498" "SRR2067499" "SRR2067500" "SRR2067501" "SRR2067502" "SRR2067503" "SRR2067504" "SRR2067505" "SRR2067506"
[11] "SRR2067507" "SRR2067508" "SRR2067510" "SRR2067511" "SRR2067512" "SRR2067513" "SRR2067514" "SRR2067515" "SRR2067516" "SRR2067517"
[21] "SRR2067518"
> rownames(coldata)
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21"
ADD REPLY
0
Entering edit mode
Talpham • 0
@e4d6761d
Last seen 6 days ago
Belgium

I was able to fix it by just changing rownames(coldata) to match colnames(txi$counts):

coldata <- data.frame(samples,
                 group,
                 stringsAsFactors = F)
coldata$samples <- factor(coldata$samples)
coldata$group <- factor(coldata$group)

rownames(coldata) <- colnames(txi$counts)

ddsTxi <- DESeqDataSetFromTximport(txi,
                                   colData = coldata,
                                   design = ~ group)
ADD COMMENT

Login before adding your answer.

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