satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

more elements supplied than there are to replace in `CreateSeuratObject ` #7886

Closed Zepeng-Mu closed 1 year ago

Zepeng-Mu commented 1 year ago

Hello, I ran into this error in my analysis while trying to create a seurat object.

Error in slot(object = object, name = "cells")[[layer]] <- cells : 
  more elements supplied than there are to replace

After some digging around, I really cannot find the problem but I have two weird examples. Example 1:

5 x 5 Matrix of class "dgeMatrix"
           GT-1337#TTGTTGTGTGGTTCTA-1 GT-1337#CACCTGTAGCGCCTAC-1 GT-1337#GGTAGGATCCACACCT-1 GT-1337#TGAATCGCAGTCAGCC-1 GT-1337#AAACTCGAGTAACATG-1
AL645608.1                 0.29221528                 0.31227080                 0.25614743                 0.29471803                 0.24878674
TAS1R3                     0.09000983                 0.06624738                 0.09898664                 0.10404130                 0.04557835
GABRD                      0.10202076                 0.16383755                 0.10861730                 0.08874482                 0.13566796
TPRG1L                     0.54266769                 0.55560437                 0.55678034                 0.52099377                 0.55068407
TP73                       0.24617513                 0.30511484                 0.28986984                 0.23138580                 0.28617269

when I supplied this 5x5 matrix seuratATAC <- Seurat::CreateSeuratObject(counts = mat) I got the error message.

Example 2:

5 x 5 Matrix of class "dgeMatrix"
           S1#TGTACGATCCCACTTG-1 PBMC6#CTCAGCTGTGCGTCCA-1 PBMC9#CTCTAGCTCCGGCTGA-1 09359-20#TGTAAGCAGAGAATTC-1 PBMC6#ACATGCAGTAGCTGTT-1
AL645608.1             0.1833513               0.10863962               0.17011062                  0.16223860               0.10499600
TAS1R3                 0.1717894               0.12093541               0.11618537                  0.17105643               0.08492607
GABRD                  0.1131130               0.06958097               0.08512984                  0.08811115               0.07111929
TPRG1L                 0.5323750               0.52560439               0.53989914                  0.57927888               0.58164124
TP73                   0.2415078               0.22201853               0.17999146                  0.21227913               0.21189479

This is also a small 5x5 matrix, but running seuratATAC <- Seurat::CreateSeuratObject(counts = mat) gives no error.

I'm wondering what could be the reason behind different outcomes for these toy examples. There could be something bigger under the hood but I have no clue. This is the session info:

─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.0 (2022-04-22)
 os       Ubuntu 22.04.2 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Etc/UTC
 date     2023-10-09
 rstudio  2023.03.1+446 Cherry Blossom (server)
 pandoc   3.1.3 @ /scratch/midway3/zepengmu/miniconda3/envs/R42/bin/pandoc

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package                     * version    date (UTC) lib source
 abind                         1.4-5      2016-07-21 [1] CRAN (R 4.2.0)
 ArchR                       * 1.0.3      2023-02-18 [1] Github (GreenleafLab/ArchR@55ab73e)
 ArchRWrappers               * 0.0.1.0000 2023-07-07 [1] local
 batchelor                   * 1.12.3     2022-06-23 [1] Bioconductor
 beachmat                      2.12.0     2022-04-26 [1] Bioconductor
 Biobase                     * 2.56.0     2022-04-26 [1] Bioconductor
 BiocGenerics                * 0.42.0     2022-04-26 [1] Bioconductor
 BiocIO                        1.8.0      2022-11-01 [1] Bioconductor
 BiocNeighbors                 1.14.0     2022-04-26 [1] Bioconductor
 BiocParallel                  1.30.4     2022-10-11 [1] Bioconductor
 BiocSingular                  1.12.0     2022-04-26 [1] Bioconductor
 Biostrings                    2.64.1     2022-08-18 [1] Bioconductor
 bitops                        1.0-7      2021-04-24 [1] CRAN (R 4.2.0)
 BSgenome                      1.66.3     2023-02-16 [1] Bioconductor
 BSgenome.Hsapiens.UCSC.hg19   1.4.3      2022-09-12 [1] Bioconductor
 cachem                        1.0.8      2023-05-01 [1] CRAN (R 4.2.3)
 Cairo                         1.6-0      2022-07-05 [1] CRAN (R 4.2.1)
 callr                         3.7.3      2022-11-02 [1] CRAN (R 4.2.3)
 circlize                      0.4.15     2022-05-10 [1] CRAN (R 4.2.0)
 cli                           3.6.1      2023-03-23 [1] CRAN (R 4.2.3)
 clue                          0.3-63     2022-11-19 [1] CRAN (R 4.2.0)
 cluster                       2.1.4      2022-08-22 [1] CRAN (R 4.2.3)
 codetools                     0.2-19     2023-02-01 [1] CRAN (R 4.2.3)
 colorspace                    2.1-0      2023-01-23 [1] CRAN (R 4.2.3)
 ComplexHeatmap              * 2.12.1     2022-08-09 [1] Bioconductor
 cowplot                       1.1.1      2020-12-30 [1] CRAN (R 4.2.0)
 crayon                        1.5.2      2022-09-29 [1] CRAN (R 4.2.3)
 data.table                  * 1.14.8     2023-02-17 [1] CRAN (R 4.2.3)
 DelayedArray                  0.22.0     2022-04-26 [1] Bioconductor
 DelayedMatrixStats            1.18.2     2022-10-13 [1] Bioconductor
 deldir                        1.0-9      2023-05-17 [1] CRAN (R 4.2.3)
 devtools                    * 2.4.5      2022-10-11 [1] CRAN (R 4.2.1)
 digest                        0.6.33     2023-07-07 [1] CRAN (R 4.2.0)
 doParallel                    1.0.17     2022-02-07 [1] CRAN (R 4.2.0)
 dotCall64                     1.0-2      2022-10-03 [1] CRAN (R 4.2.0)
 dplyr                       * 1.1.3      2023-09-03 [1] CRAN (R 4.2.0)
 ellipsis                      0.3.2      2021-04-29 [1] CRAN (R 4.2.3)
 fansi                         1.0.4      2023-01-22 [1] CRAN (R 4.2.3)
 fastDummies                   1.7.3      2023-07-06 [1] CRAN (R 4.2.0)
 fastmap                       1.1.1      2023-02-24 [1] CRAN (R 4.2.3)
 fitdistrplus                  1.1-8      2022-03-10 [1] CRAN (R 4.2.0)
 forcats                     * 1.0.0      2023-01-29 [1] CRAN (R 4.2.3)
 foreach                       1.5.2      2022-02-02 [1] CRAN (R 4.2.3)
 fs                            1.6.3      2023-07-20 [1] CRAN (R 4.2.0)
 future                        1.28.0     2022-09-02 [1] CRAN (R 4.2.0)
 future.apply                  1.9.1      2022-09-07 [1] CRAN (R 4.2.0)
 generics                      0.1.3      2022-07-05 [1] CRAN (R 4.2.3)
 GenomeInfoDb                * 1.34.9     2023-02-02 [1] Bioconductor
 GenomeInfoDbData              1.2.8      2022-09-10 [1] Bioconductor
 GenomicAlignments             1.34.1     2023-03-09 [1] Bioconductor
 GenomicRanges               * 1.50.2     2022-12-16 [1] Bioconductor
 GetoptLong                    1.0.5      2020-12-15 [1] CRAN (R 4.2.0)
 ggplot2                     * 3.4.3      2023-08-14 [1] CRAN (R 4.2.0)
 ggrepel                       0.9.3      2023-06-28 [1] Github (slowkow/ggrepel@4584949)
 ggridges                      0.5.4      2022-09-26 [1] CRAN (R 4.2.0)
 GlobalOptions                 0.1.2      2020-06-10 [1] CRAN (R 4.2.0)
 globals                       0.16.1     2022-08-28 [1] CRAN (R 4.2.0)
 glue                          1.6.2      2022-02-24 [1] CRAN (R 4.2.3)
 goftest                       1.2-3      2021-10-07 [1] CRAN (R 4.2.0)
 gridExtra                   * 2.3        2017-09-09 [1] CRAN (R 4.2.3)
 gtable                      * 0.3.4      2023-08-21 [1] CRAN (R 4.2.0)
 gtools                      * 3.9.4      2022-11-27 [1] CRAN (R 4.2.0)
 hms                           1.1.3      2023-03-21 [1] CRAN (R 4.2.3)
 htmltools                     0.5.6      2023-08-10 [1] CRAN (R 4.2.0)
 htmlwidgets                   1.6.2      2023-03-17 [1] CRAN (R 4.2.3)
 httpuv                        1.6.11     2023-05-11 [1] CRAN (R 4.2.3)
 httr                          1.4.7      2023-08-15 [1] CRAN (R 4.2.0)
 ica                           1.0-3      2022-07-08 [1] CRAN (R 4.2.0)
 igraph                        1.3.4      2022-07-19 [1] CRAN (R 4.2.0)
 IRanges                     * 2.32.0     2022-11-01 [1] Bioconductor
 irlba                         2.3.5.1    2022-10-03 [1] CRAN (R 4.2.0)
 iterators                     1.0.14     2022-02-05 [1] CRAN (R 4.2.3)
 jsonlite                      1.8.7      2023-06-29 [1] CRAN (R 4.2.0)
 KernSmooth                    2.23-21    2023-05-03 [1] CRAN (R 4.2.3)
 later                         1.3.1      2023-05-02 [1] CRAN (R 4.2.3)
 lattice                       0.21-8     2023-04-05 [1] CRAN (R 4.2.3)
 lazyeval                      0.2.2      2019-03-15 [1] CRAN (R 4.2.3)
 leiden                        0.4.3      2022-09-10 [1] CRAN (R 4.2.0)
 lifecycle                     1.0.3      2022-10-07 [1] CRAN (R 4.2.3)
 listenv                       0.8.0      2019-12-05 [1] CRAN (R 4.2.0)
 lmtest                        0.9-40     2022-03-21 [1] CRAN (R 4.2.0)
 lubridate                   * 1.9.2      2023-02-10 [1] CRAN (R 4.2.3)
 magrittr                    * 2.0.3      2022-03-30 [1] CRAN (R 4.2.3)
 MASS                          7.3-60     2023-05-04 [1] CRAN (R 4.2.3)
 Matrix                      * 1.6-1.1    2023-09-18 [1] CRAN (R 4.2.0)
 MatrixGenerics              * 1.8.1      2022-06-26 [1] Bioconductor
 matrixStats                 * 1.0.0      2023-06-02 [1] CRAN (R 4.2.3)
 memoise                       2.0.1      2021-11-26 [1] CRAN (R 4.2.3)
 mime                          0.12       2021-09-28 [1] CRAN (R 4.2.3)
 miniUI                        0.1.1.1    2018-05-18 [1] CRAN (R 4.2.3)
 munsell                       0.5.0      2018-06-12 [1] CRAN (R 4.2.3)
 nabor                         0.5.0      2018-07-11 [1] CRAN (R 4.2.0)
 nlme                          3.1-162    2023-01-31 [1] CRAN (R 4.2.3)
 parallelly                    1.32.1     2022-07-21 [1] CRAN (R 4.2.0)
 patchwork                   * 1.1.2.9000 2023-02-20 [1] Github (thomasp85/patchwork@c14c960)
 pbapply                       1.7-2      2023-06-27 [1] CRAN (R 4.2.0)
 pbmcapply                   * 1.5.1      2022-12-30 [1] Github (kvnkuang/pbmcapply@c302c2e)
 pillar                        1.9.0      2023-03-22 [1] CRAN (R 4.2.3)
 pkgbuild                      1.4.2      2023-06-26 [1] CRAN (R 4.2.3)
 pkgconfig                     2.0.3      2019-09-22 [1] CRAN (R 4.2.3)
 pkgload                       1.3.2      2022-11-16 [1] CRAN (R 4.2.3)
 plotly                        4.10.2     2023-06-03 [1] CRAN (R 4.2.0)
 plyr                        * 1.8.8      2022-11-11 [1] CRAN (R 4.2.3)
 png                           0.1-8      2022-11-29 [1] CRAN (R 4.2.3)
 polyclip                      1.10-4     2022-10-20 [1] CRAN (R 4.2.0)
 prettyunits                   1.2.0      2023-09-24 [1] CRAN (R 4.2.0)
 processx                      3.8.1      2023-04-18 [1] CRAN (R 4.2.3)
 profvis                       0.3.8      2023-05-02 [1] CRAN (R 4.2.3)
 progressr                     0.11.0     2022-09-02 [1] CRAN (R 4.2.0)
 promises                      1.2.1      2023-08-10 [1] CRAN (R 4.2.0)
 ps                            1.7.5      2023-04-18 [1] CRAN (R 4.2.3)
 purrr                       * 1.0.2      2023-08-10 [1] CRAN (R 4.2.0)
 R6                            2.5.1      2021-08-19 [1] CRAN (R 4.2.3)
 RANN                          2.6.1      2019-01-08 [1] CRAN (R 4.2.0)
 RColorBrewer                * 1.1-3      2022-04-03 [1] CRAN (R 4.2.3)
 Rcpp                        * 1.0.11     2023-07-06 [1] CRAN (R 4.2.0)
 RcppAnnoy                     0.0.21     2023-07-02 [1] CRAN (R 4.2.0)
 RcppArmadillo               * 0.12.6.4.0 2023-09-10 [1] CRAN (R 4.2.0)
 RcppHNSW                      0.4.1      2022-07-18 [1] CRAN (R 4.2.0)
 RCurl                         1.98-1.9   2022-10-03 [1] CRAN (R 4.2.0)
 readr                       * 2.1.4      2023-02-10 [1] CRAN (R 4.2.3)
 remotes                       2.4.2      2021-11-30 [1] CRAN (R 4.2.3)
 reshape2                      1.4.4      2020-04-09 [1] CRAN (R 4.2.3)
 ResidualMatrix                1.6.1      2022-08-16 [1] Bioconductor
 restfulr                      0.0.15     2022-06-16 [1] CRAN (R 4.2.0)
 reticulate                    1.30       2023-06-09 [1] CRAN (R 4.2.0)
 rhdf5                       * 2.40.0     2022-04-26 [1] Bioconductor
 rhdf5filters                  1.8.0      2022-04-26 [1] Bioconductor
 Rhdf5lib                      1.18.2     2022-05-15 [1] Bioconductor
 rjson                         0.2.21     2022-01-09 [1] CRAN (R 4.2.0)
 rlang                         1.1.1      2023-04-28 [1] CRAN (R 4.2.3)
 ROCR                          1.0-11     2020-05-02 [1] CRAN (R 4.2.0)
 Rsamtools                     2.12.0     2022-04-26 [1] Bioconductor
 RSpectra                      0.16-1     2022-04-24 [1] CRAN (R 4.2.0)
 rstudioapi                    0.14       2022-08-22 [1] CRAN (R 4.2.3)
 rsvd                          1.0.5      2021-04-16 [1] CRAN (R 4.2.0)
 rtracklayer                   1.56.1     2022-06-23 [1] Bioconductor
 Rtsne                         0.16       2022-04-17 [1] CRAN (R 4.2.0)
 S4Vectors                   * 0.34.0     2022-04-26 [1] Bioconductor
 ScaledMatrix                  1.4.0      2022-04-26 [1] Bioconductor
 scales                        1.2.1      2022-08-20 [1] CRAN (R 4.2.3)
 scattermore                   0.8        2022-02-14 [1] CRAN (R 4.2.0)
 sctransform                   0.3.5      2022-09-21 [1] CRAN (R 4.2.0)
 scuttle                       1.6.3      2022-08-23 [1] Bioconductor
 sessioninfo                   1.2.2      2021-12-06 [1] CRAN (R 4.2.3)
 Seurat                      * 4.9.9.9049 2023-06-28 [1] Github (satijalab/seurat@3a826c5)
 SeuratObject                * 4.9.9.9086 2023-06-28 [1] Github (mojaveazure/seurat-object@4be3e8d)
 shape                         1.4.6      2021-05-19 [1] CRAN (R 4.2.0)
 shiny                         1.7.4      2022-12-15 [1] CRAN (R 4.2.3)
 SingleCellExperiment        * 1.20.1     2023-03-17 [1] Bioconductor
 sp                          * 1.6-1      2023-05-31 [1] CRAN (R 4.2.3)
 spam                          2.9-1      2022-08-07 [1] CRAN (R 4.2.0)
 sparseMatrixStats           * 1.8.0      2022-04-26 [1] Bioconductor
 spatstat.data                 3.0-1      2023-03-12 [1] CRAN (R 4.2.0)
 spatstat.explore              3.2-1      2023-05-13 [1] CRAN (R 4.2.0)
 spatstat.geom                 3.2-1      2023-05-09 [1] CRAN (R 4.2.0)
 spatstat.random               3.1-5      2023-05-11 [1] CRAN (R 4.2.0)
 spatstat.sparse               3.0-2      2023-06-25 [1] CRAN (R 4.2.0)
 spatstat.utils                3.0-3      2023-05-09 [1] CRAN (R 4.2.0)
 stringi                       1.7.12     2023-01-11 [1] CRAN (R 4.2.0)
 stringr                     * 1.5.0      2022-12-02 [1] CRAN (R 4.2.3)
 SummarizedExperiment        * 1.28.0     2022-11-01 [1] Bioconductor
 survival                      3.5-5      2023-03-12 [1] CRAN (R 4.2.3)
 tensor                        1.5        2012-05-05 [1] CRAN (R 4.2.0)
 tibble                      * 3.2.1      2023-03-20 [1] CRAN (R 4.2.3)
 tidyr                       * 1.3.0      2023-01-24 [1] CRAN (R 4.2.3)
 tidyselect                    1.2.0      2022-10-10 [1] CRAN (R 4.2.3)
 tidyverse                   * 2.0.0      2023-02-22 [1] CRAN (R 4.2.0)
 timechange                    0.2.0      2023-01-11 [1] CRAN (R 4.2.3)
 tzdb                          0.4.0      2023-05-12 [1] CRAN (R 4.2.3)
 urlchecker                    1.0.1      2021-11-30 [1] CRAN (R 4.2.3)
 usethis                     * 2.2.1      2023-06-23 [1] CRAN (R 4.2.3)
 utf8                          1.2.3      2023-01-31 [1] CRAN (R 4.2.3)
 uwot                          0.1.16     2023-06-29 [1] CRAN (R 4.2.0)
 vctrs                         0.6.3      2023-06-14 [1] CRAN (R 4.2.3)
 viridisLite                   0.4.2      2023-05-02 [1] CRAN (R 4.2.3)
 withr                         2.5.1      2023-09-26 [1] CRAN (R 4.2.0)
 XML                           3.99-0.14  2023-03-19 [1] CRAN (R 4.2.3)
 xtable                        1.8-4      2019-04-21 [1] CRAN (R 4.2.3)
 XVector                       0.36.0     2022-04-26 [1] Bioconductor
 yaml                          2.3.7      2023-01-23 [1] CRAN (R 4.2.3)
 zlibbioc                      1.42.0     2022-04-26 [1] Bioconductor
 zoo                           1.8-10     2022-04-15 [1] CRAN (R 4.2.0)

 [1] /scratch/midway3/zepengmu/miniconda3/envs/R42/lib/R/library

Thanks in advance!

Zepeng-Mu commented 1 year ago

Although I realized that this might an issue with SeuratObject. I actually figured out the problem is with the formatting of column names in the matrix. Switching the colnames seems to avoid the error message. This is strange because I did not run in to the same error in previous analysis with the same data.

It seems that GT-1337 does not work although both GT1337 and 09359-20 works fine.

Zepeng-Mu commented 1 year ago

Turned out in my case the column names of a matrix is an array rather than character. https://github.com/GreenleafLab/ArchR/issues/1999#issuecomment-1761987935

chloeacolson commented 11 months ago

I recently ran into a similar problem, with the same error message for a supplied 5 x 5 matrix, but this actually happened while following the ArchR tutorial. I don't fully understand your solution above @Zepeng-Mu and had opened an issue here. How would the code in ArchR Tutorial Section 8.1 have to be amended to avoid this bug?