satijalab / seurat-object

https://satijalab.github.io/seurat-object/
Other
23 stars 26 forks source link

Velocyto- Seurat - invalid class “LogMap” object: Duplicate rownames not allowed #179

Open Ruba-Mahmoud opened 9 months ago

Ruba-Mahmoud commented 9 months ago

Hello, first thank you for developing such great tools I am Ruba PhD student in Germany and I am doing scRNAseq analysis for my data, I wanted to check the velocity and so I generated the loom files by velacyto, I wanted to continue with Seurat with .r but unfortunately am facing some errors, I looked many published errors, tried to downgrade the Matrix Package (where Seurat didn't work anymore) I had to upgrade it again, the error am facing is | | 0%Error in validObject(.Object) : invalid class “LogMap” object: Duplicate rownames not allowed taking into account there's no duplicated rownames could somebody kindly look into it and give an advice if something could be done so I can go through the velocity analysis in the end.

thank you in advance

Kind regards!


library(Seurat)
library(SeuratWrappers)
library(velocyto.R)
library(Matrix)

ldat <- ReadVelocity(file = "E11.5.possorted_genome_bam_BX5BE.loom")
Seurat::bm <- as.Seurat(x= ldat)

output

  |                                                                                                                                          |   0%Error in validObject(.Object) : 
  invalid class “LogMap” object: Duplicate rownames not allowed 

any(duplicated(rownames(ldat)))
[1] FALSE

> class(ldat)
[1] "list"

> str(ldat)
List of 3
 $ spliced  :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. ..@ i       : int [1:12963443] 100 110 111 177 263 376 461 467 472 500 ...
  .. ..@ p       : int [1:14699] 0 679 1555 2345 3484 3870 5098 6066 7591 8934 ...
  .. ..@ Dim     : int [1:2] 32285 14698
  .. ..@ Dimnames:List of 2
  .. .. ..$ : chr [1:32285] "AC125149.3" "AC125149.5" "AC125149.2" "AC125149.1" ...
  .. .. ..$ : chr [1:14698] "possorted_genome_bam_BX5BE:AAAGCAACAGGTCGTCx" "possorted_genome_bam_BX5BE:AAAGCAATCTGCGTAAx" "possorted_genome_bam_BX5BE:AAACGGGCAGATGAGCx" "possorted_genome_bam_BX5BE:AAAGCAAGTACAGTTCx" ...
  .. ..@ x       : num [1:12963443] 1 2 1 1 1 1 1 1 2 1 ...
  .. ..@ factors : list()
 $ unspliced:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. ..@ i       : int [1:7903683] 195 411 501 526 548 586 615 723 851 985 ...
  .. ..@ p       : int [1:14699] 0 309 579 864 1999 2017 2490 2712 4181 4807 ...
  .. ..@ Dim     : int [1:2] 32285 14698
  .. ..@ Dimnames:List of 2
  .. .. ..$ : chr [1:32285] "AC125149.3" "AC125149.5" "AC125149.2" "AC125149.1" ...
  .. .. ..$ : chr [1:14698] "possorted_genome_bam_BX5BE:AAAGCAACAGGTCGTCx" "possorted_genome_bam_BX5BE:AAAGCAATCTGCGTAAx" "possorted_genome_bam_BX5BE:AAACGGGCAGATGAGCx" "possorted_genome_bam_BX5BE:AAAGCAAGTACAGTTCx" ...
  .. ..@ x       : num [1:7903683] 2 3 2 1 1 1 3 1 1 1 ...
  .. ..@ factors : list()
 $ ambiguous:Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. ..@ i       : int [1:1881126] 214 274 615 738 783 867 1469 2097 2828 2954 ...
  .. ..@ p       : int [1:14699] 0 85 160 245 453 481 617 714 1038 1231 ...
  .. ..@ Dim     : int [1:2] 32285 14698
  .. ..@ Dimnames:List of 2
  .. .. ..$ : chr [1:32285] "AC125149.3" "AC125149.5" "AC125149.2" "AC125149.1" ...
  .. .. ..$ : chr [1:14698] "possorted_genome_bam_BX5BE:AAAGCAACAGGTCGTCx" "possorted_genome_bam_BX5BE:AAAGCAATCTGCGTAAx" "possorted_genome_bam_BX5BE:AAACGGGCAGATGAGCx" "possorted_genome_bam_BX5BE:AAAGCAAGTACAGTTCx" ...
  .. ..@ x       : num [1:1881126] 1 1 1 1 1 2 1 1 1 1 ...
  .. ..@ factors : list()

> sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)

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    

time zone: Europe/Berlin
tzcode source: internal

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

other attached packages:
[1] velocyto.R_0.6       Matrix_1.6-4         SeuratWrappers_0.3.2 Seurat_5.0.1         SeuratObject_5.0.1   sp_2.1-2            

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     rstudioapi_0.15.0      jsonlite_1.8.8         magrittr_2.0.3         spatstat.utils_3.0-4   fs_1.6.3              
  [7] vctrs_0.6.4            ROCR_1.0-11            memoise_2.0.1          spatstat.explore_3.2-5 htmltools_0.5.7        usethis_2.2.2         
 [13] sctransform_0.4.1      parallelly_1.36.0      KernSmooth_2.23-22     htmlwidgets_1.6.4      ica_1.0-3              plyr_1.8.9            
 [19] plotly_4.10.3          zoo_1.8-12             cachem_1.0.8           igraph_1.6.0           mime_0.12              lifecycle_1.0.4       
 [25] pkgconfig_2.0.3        rsvd_1.0.5             R6_2.5.1               fastmap_1.1.1          fitdistrplus_1.1-11    future_1.33.1         
 [31] shiny_1.8.0            digest_0.6.33          pcaMethods_1.92.0      colorspace_2.1-0       patchwork_1.2.0        tensor_1.5            
 [37] RSpectra_0.16-1        irlba_2.3.5.1          pkgload_1.3.3          progressr_0.14.0       fansi_1.0.6            spatstat.sparse_3.0-3 
 [43] httr_1.4.7             polyclip_1.10-6        abind_1.4-5            mgcv_1.9-0             compiler_4.3.2         remotes_2.4.2.1       
 [49] bit64_4.0.5            fastDummies_1.7.3      pkgbuild_1.4.3         R.utils_2.12.3         MASS_7.3-60            sessioninfo_1.2.2     
 [55] tools_4.3.2            lmtest_0.9-40          httpuv_1.6.12          future.apply_1.11.1    goftest_1.2-3          R.oo_1.25.0           
 [61] glue_1.6.2             nlme_3.1-163           promises_1.2.1         grid_4.3.2             Rtsne_0.17             cluster_2.1.4         
 [67] reshape2_1.4.4         generics_0.1.3         hdf5r_1.3.8            gtable_0.3.4           spatstat.data_3.0-3    R.methodsS3_1.8.2     
 [73] tidyr_1.3.0            data.table_1.14.10     utf8_1.2.4             BiocGenerics_0.48.1    spatstat.geom_3.2-7    RcppAnnoy_0.0.21      
 [79] ggrepel_0.9.5          RANN_2.6.1             pillar_1.9.0           stringr_1.5.1          spam_2.10-0            RcppHNSW_0.5.0        
 [85] later_1.3.1            splines_4.3.2          dplyr_1.1.4            lattice_0.21-9         bit_4.0.5              survival_3.5-7        
 [91] deldir_2.0-2           tidyselect_1.2.0       miniUI_0.1.1.1         pbapply_1.7-2          gridExtra_2.3          scattermore_1.2       
 [97] Biobase_2.62.0         devtools_2.4.5         matrixStats_1.2.0      stringi_1.8.3          lazyeval_0.2.2         codetools_0.2-19      
[103] tibble_3.2.1           BiocManager_1.30.22    cli_3.6.1              uwot_0.1.16            xtable_1.8-4           reticulate_1.34.0     
[109] munsell_0.5.0          Rcpp_1.0.11            globals_0.16.2         spatstat.random_3.2-2  png_0.1-8              parallel_4.3.2        
[115] ellipsis_0.3.2         ggplot2_3.4.4          dotCall64_1.1-1        profvis_0.3.8          urlchecker_1.0.1       listenv_0.9.0         
[121] viridisLite_0.4.2      scales_1.3.0           ggridges_0.5.5         leiden_0.4.3.1         purrr_1.0.2            rlang_1.1.2           
[127] cowplot_1.1.2
lldelisle commented 9 months ago

Hi, I got the same error but I could figure out that indeed there was duplicated gene names (ldat is a list of 3 so it does not have row names but the 3 matrices probably have):

lapply(ldat, function(m) {anyDuplicated(rownames(m))})

I have the impression that before there was an implicite make.unique that was made when we generate seurat object:

Warning: Non-unique features (rownames) present in the input matrix, making unique

(Obtained with SeuratObject_4.1.3 Seurat_4.3.0)

lldelisle commented 9 months ago

After digging into the code, it appears that the new default assay is assay version 5 for which there is no 'make.unique'. If you want to go back to the old version 3 use: options(Seurat.object.assay.version = 'v3') and as.Seurat will work (still I am not sure it is good to use make.unique and it would be probably better to have unique gene names before...).