vertesy / Seurat.utils

Various utility functions for Seurat single-cell analysis
https://vertesy.github.io/Seurat.utils
GNU General Public License v3.0
35 stars 6 forks source link

Error in RenameGenesSeurat #65

Open jenellewallace opened 9 months ago

jenellewallace commented 9 months ago

Hello, thanks for writing these functions! I am getting the following error when trying to rename genes:

RenameGenesSeurat(s16,newnames = df16$Approved_symbol,assay = "RNA")

This is the output:

Warning in RenameGenesSeurat(s16, newnames = df16$Approved_symbol, assay = "RNA") :
  Run this before integration and downstream processing. It only attempts to change
          @counts, @data, @scale.data and @meta.features in obj@assays$YOUR_ASSAY.
[1] "Present: counts" "Present: data"  
data
Error in rownames(assayobj@features@.Data) : 
  no slot of name "features" for this object of class "Assay"

This is what my Seurat object looks like:

 s16
An object of class Seurat 
40500 features across 66318 samples within 1 assay 
Active assay: RNA (40500 features, 0 variable features)
 2 layers present: counts, data
 2 dimensional reductions calculated: X_PCA, X_UMAP

Thanks for any advice!

vertesy commented 9 months ago

Hey, thx for reportingit! I will take a look tomorrow! Are you using Seurat v5.0.1? Can you check the version?

jenellewallace commented 9 months ago

Thanks for responding! Here's the first part of sessionInfo() showing the version for Seurat 5.0.0:

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

time zone: America/Los_Angeles
tzcode source: system (glibc)

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

other attached packages:
 [1] scater_1.28.0               scuttle_1.11.3              patchwork_1.1.3            
 [4] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0 Biobase_2.62.0             
 [7] GenomicRanges_1.54.1        GenomeInfoDb_1.38.5         IRanges_2.36.0             
[10] S4Vectors_0.40.2            BiocGenerics_0.48.1         MatrixGenerics_1.14.0      
[13] matrixStats_1.2.0           rlang_1.1.3                 stringr_1.5.1              
[16] Seurat_5.0.0                SeuratObject_5.0.0          sp_2.1-1                   
[19] ggplot2_3.4.4  
vertesy commented 9 months ago

I did not have time yet, but, on a side note, you should really upgrade to Seurat v5.0.1. The version naming is weird, but it has important bug fixes.

Also, what version of Seurat.utils are you using? Could you please use the latest?

vertesy commented 9 months ago

Hey, do you still have the problem? Or newer version solved it?

jenellewallace commented 9 months ago

Thanks for looking into this. I am still getting the same error after updating

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

time zone: America/Los_Angeles
tzcode source: system (glibc)

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

other attached packages:
 [1] Seurat.utils_2.6.0          magrittr_2.0.3              ggExpress_0.9.0            
 [4] MarkdownHelpers_1.0.4       ggpubr_0.6.0                ggplot2_3.4.4              
 [7] CodeAndRoll2_2.5.6          Stringendo_0.6.0            Seurat_5.0.1               
[10] SeuratObject_5.0.1          sp_2.1-3                    dplyr_1.1.4                
[13] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0 Biobase_2.62.0             
[16] GenomicRanges_1.54.1        GenomeInfoDb_1.38.5         IRanges_2.36.0             
[19] S4Vectors_0.40.2            BiocGenerics_0.48.1         MatrixGenerics_1.14.0      
[22] matrixStats_1.2.0          

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22         splines_4.3.1            later_1.3.2              bitops_1.0-7            
  [5] R.oo_1.26.0              tibble_3.2.1             polyclip_1.10-6          fastDummies_1.7.3       
  [9] DatabaseLinke.R_1.7.0    lifecycle_1.0.4          rstatix_0.7.2            vroom_1.6.5             
 [13] globals_0.16.2           lattice_0.21-9           MASS_7.3-60              nVennR_0.2.3            
 [17] backports_1.4.1          openxlsx_4.2.5.2         plotly_4.10.4            sm_2.2-5.7.1            
 [21] httpuv_1.6.14            sctransform_0.4.1        spam_2.10-0              zip_2.3.1               
 [25] sessioninfo_1.2.2        spatstat.sparse_3.0-3    HGNChelper_0.8.1         EnhancedVolcano_1.18.0  
 [29] reticulate_1.35.0        cowplot_1.1.3            pbapply_1.7-2            RColorBrewer_1.1-3      
 [33] abind_1.4-5              zlibbioc_1.48.0          Rtsne_0.17               R.utils_2.12.3          
 [37] purrr_1.0.2              RCurl_1.98-1.14          job_0.3.0                GenomeInfoDbData_1.2.11 
 [41] ggrepel_0.9.5            irlba_2.3.5.1            listenv_0.9.1            spatstat.utils_3.0-4    
 [45] pheatmap_1.0.12          goftest_1.2-3            RSpectra_0.16-1          spatstat.random_3.2-2   
 [49] fitdistrplus_1.1-11      parallelly_1.36.0        leiden_0.4.3.1           codetools_0.2-19        
 [53] DelayedArray_0.28.0      RApiSerialize_0.1.2      tidyselect_1.2.0         futile.logger_1.4.3     
 [57] SoupX_1.6.2              spatstat.explore_3.2-6   ReadWriter_1.5.3         jsonlite_1.8.8          
 [61] vioplot_0.4.0            ellipsis_0.3.2           progressr_0.14.0         iterators_1.0.14        
 [65] ggridges_0.5.6           survival_3.5-7           tictoc_1.2               foreach_1.5.2           
 [69] tools_4.3.1              ica_1.0-3                Rcpp_1.0.12              ggVennDiagram_1.5.0     
 [73] glue_1.7.0               gridExtra_2.3            SparseArray_1.2.3        withr_3.0.0             
 [77] formatR_1.14             fastmap_1.1.1            fansi_1.0.6              caTools_1.18.2          
 [81] digest_0.6.34            MarkdownReports_4.7.0    R6_2.5.1                 mime_0.12               
 [85] colorspace_2.1-0         scattermore_1.2          gtools_3.9.5             tensor_1.5              
 [89] spatstat.data_3.0-4      R.methodsS3_1.8.2        UpSetR_1.4.0             utf8_1.2.4              
 [93] tidyr_1.3.1              generics_0.1.3           data.table_1.15.0        httr_1.4.7              
 [97] htmlwidgets_1.6.4        S4Arrays_1.2.0           uwot_0.1.16              pkgconfig_2.0.3         
[101] gtable_0.3.4             lmtest_0.9-40            XVector_0.42.0           htmltools_0.5.7         
[105] carData_3.0-5            dotCall64_1.1-1          tidyverse_2.0.0          scales_1.3.0            
[109] png_0.1-8                colorRamps_2.3.1         lambda.r_1.2.4           rstudioapi_0.15.0       
[113] tzdb_0.4.0               reshape2_1.4.4           nlme_3.1-163             ggcorrplot_0.1.4.1      
[117] zoo_1.8-12               stringr_1.5.1            KernSmooth_2.23-22       parallel_4.3.1          
[121] miniUI_0.1.1.1           pillar_1.9.0             grid_4.3.1               vctrs_0.6.5             
[125] RANN_2.6.1               gplots_3.1.3.1           promises_1.2.1           stringfish_0.16.0       
[129] car_3.1-2                princurve_2.1.6          xtable_1.8-4             cluster_2.1.4           
[133] VennDiagram_1.7.3        readr_2.1.5              futile.options_1.0.1     cli_3.6.2               
[137] compiler_4.3.1           rlang_1.1.3              crayon_1.5.2             future.apply_1.11.1     
[141] ggsignif_0.6.4           fs_1.6.3                 plyr_1.8.9               stringi_1.8.3           
[145] viridisLite_0.4.2        deldir_2.0-2             munsell_0.5.0            lazyeval_0.2.2          
[149] spatstat.geom_3.2-8      Matrix_1.6-5             RcppHNSW_0.5.0           hms_1.1.3               
[153] patchwork_1.2.0          bit64_4.0.5              sparseMatrixStats_1.14.0 future_1.33.1           
[157] shiny_1.8.0              qs_0.25.7                ROCR_1.0-11              clipr_0.8.0             
[161] igraph_2.0.1.9002        broom_1.0.5              RcppParallel_5.1.7       bit_4.0.5      
vertesy commented 9 months ago

hey, thanks for getting back with the details. I will look into it today.

vertesy commented 9 months ago

A quick fix could be that you specify: slots = c("data", "counts") as in

RenameGenesSeurat2(obj = obj, newnames = NewGeneNames, slots = c("data", "counts")).

I am looking into the deeper cause.

vertesy commented 9 months ago

So the function runs fine on my end, I can't reproduce your error.

Also, could you please obj@version?

Expected is:

>  obj@version
[1] ‘5.0.1’

If not, try to update the object to latest.

vertesy commented 8 months ago

Assume solved, let me know if otherwise

JH-42 commented 5 months ago

Hi, thank you for the wonderful function! I met the same problem as jenellewallace. Do you have any updates on this?

> HGNC.updated <- HGNChelper::checkGeneSymbols(rownames(Tcells), unmapped.as.na = FALSE, map = NULL, species = "human")

>  Tcells@version
[1] ‘5.0.1’
> Tcells<-Seurat.utils::RenameGenesSeurat(obj = Tcells,newnames = HGNC.updated$Suggested.Symbol,assay = "RNA",slots=c("data","counts"))
RenameGenesSeurat, assay: RNA
Warning in Seurat.utils::RenameGenesSeurat(obj = Tcells, newnames = HGNC.updated$Suggested.Symbol,  :
  Run this before integration and downstream processing. It only attempts to change
          @counts, @data, and @meta.features in obj@assays$YOUR_ASSAY.
[1] "Present:  counts data scale.data"
[1] "Replaced:  counts data"
[1] "counts"
counts
Error in rownames(assayobj@features@.Data) :
  no slot of name "features" for this object of class "Assay"