zhanghao-njmu / SCP

An end-to-end Single-Cell Pipeline designed to facilitate comprehensive analysis and exploration of single-cell data.
https://zhanghao-njmu.github.io/SCP/
GNU General Public License v3.0
386 stars 84 forks source link

RunKNNPredict #177

Closed chenhy-lab closed 11 months ago

chenhy-lab commented 1 year ago

pancreas_sub <- RunKNNPredict( srt_query = pancreas_sub, srt_ref = panc8_rename, query_group = "SubCellType", ref_group = "celltype", return_full_distance_matrix = TRUE ) Use the HVF to calculate distance metric. Use 631 features to calculate distance. Detected query data type: log_normalized_counts Detected reference data type: log_normalized_counts Calculate similarity... Use 'raw' method to find neighbors. Predict cell type... 错误: No cell overlap between new meta data and Seurat object

zhanghao-njmu commented 1 year ago

Can you provide a complete and reproducible code?

chenhy-lab commented 1 year ago

This is the code in the part Cell annotation using single-cell datasets of README.

zhanghao-njmu commented 1 year ago

This error is likely caused by Seurat v5. SCP will undergo compatibility modifications after the official release of Seurat v5.

chenhy-lab commented 1 year ago

Thank you very much, I will test it later with Seurat v4.2 or higher.

ziyuan-ma commented 1 year ago

Hey, thanks for this beautiful package! I have the same issue as described by @chenhy-lab, but I'm using Seurat v4.4.0, not v5. Could you provide a potential solution for this error message? Thanks!

zhanghao-njmu commented 1 year ago

The error is specifically caused by an issue with the SeuratObject package. Currently, it is one version ahead of Seurat on CRAN, with Seurat at version 4.4.0 and SeuratObject at version 5.0.0.

You can install the corresponding version 4 of SeuratObject by remotes::install_version("SeuratObject", version = "4.1.4")

chenhy-lab commented 1 year ago

When I encountered this bug, the software version was: Seurat at version 4.1.1 and SeuratObject at version 4.1.0

zhanghao-njmu commented 1 year ago

I found that the message "No cell overlap between new meta data and Seurat object" was first added in version 4.9.9.9027 of SeuratObject. https://github.com/mojaveazure/seurat-object/blame/78f71fee5b0cbe69f669f9a698cb60877eeb8da8/R/seurat.R#L5129 https://github.com/mojaveazure/seurat-object/blob/4a58f01aa30620961e9cb344964699dbc892b317/DESCRIPTION

ziyuan-ma commented 1 year ago

The error is specifically caused by an issue with the SeuratObject package. Currently, it is one version ahead of Seurat on CRAN, with Seurat at version 4.4.0 and SeuratObject at version 5.0.0.

You can install the corresponding version 4 of SeuratObject by remotes::install_version("SeuratObject", version = "4.1.3")

Thank you, I downgraded my SeuratObject to v4.1.4 and the error was gone!

ayyildizd commented 11 months ago

Sorry for re-opening this issue but I am stuck here. If I install SeuratObject 4.1.3 or 4.1.4 I get the error:

library(SCP)
Error: package or namespace load failed for ‘SCP’:
object ‘LayerData<-’ is not exported by 'namespace:SeuratObject'

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.6.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Amsterdam
tzcode source: internal

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

other attached packages:
 [1] readxl_1.4.3                yardstick_1.2.0             workflowsets_1.0.1          workflows_1.1.3            
 [5] tune_1.1.2                  rsample_1.2.0               recipes_1.0.8               parsnip_1.1.1              
 [9] modeldata_1.2.0             infer_1.0.5                 dials_1.2.0                 scales_1.3.0               
[13] broom_1.0.5                 tidymodels_1.1.1            gridExtra_2.3               Nebulosa_1.12.0            
[17] tradeSeq_1.16.0             slingshot_2.10.0            TrajectoryUtils_1.10.0      princurve_2.1.6            
[21] viridis_0.6.4               viridisLite_0.4.2           monocle3_1.3.4              UCell_2.6.2                
[25] stringr_1.5.1               DropletUtils_1.22.0         BiocParallel_1.36.0         scDblFinder_1.16.0         
[29] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0 GenomicRanges_1.54.1        GenomeInfoDb_1.38.1        
[33] MatrixGenerics_1.14.0       matrixStats_1.1.0           harmony_1.1.0               Rcpp_1.0.11                
[37] easyGgplot2_1.0.0.9000      purrr_1.0.2                 tibble_3.2.1                patchwork_1.1.3            
[41] biomaRt_2.58.0              enrichplot_1.22.0           org.Hs.eg.db_3.18.0         AnnotationDbi_1.64.1       
[45] IRanges_2.36.0              S4Vectors_0.40.2            Biobase_2.62.0              BiocGenerics_0.48.1        
[49] clusterProfiler_4.10.0      magrittr_2.0.3              data.table_1.14.8           scCustomize_1.1.3          
[53] SeuratObject_4.1.4          Seurat_4.4.0                dplyr_1.1.4                 cli_3.6.1                  
[57] tidyr_1.3.0                 ggplot2_3.4.4              

loaded via a namespace (and not attached):
  [1] igraph_1.5.1              ica_1.0-3                 plotly_4.10.3             scater_1.30.0            
  [5] rematch2_2.1.2            zlibbioc_1.48.0           tidyselect_1.2.0          bit_4.0.5                
  [9] GPfit_1.0-8               doParallel_1.0.17         clue_0.3-65               lattice_0.22-5           
 [13] rjson_0.2.21              blob_1.2.4                S4Arrays_1.2.0            parallel_4.3.1           
 [17] png_0.1-8                 ggplotify_0.1.2           goftest_1.2-3             BiocIO_1.12.0            
 [21] bluster_1.12.0            BiocNeighbors_1.20.0      lhs_1.1.6                 uwot_0.1.16              
 [25] shadowtext_0.1.2          curl_5.1.0                mime_0.12                 tidytree_0.4.5           
 [29] leiden_0.4.3.1            ComplexHeatmap_2.18.0     stringi_1.8.2             backports_1.4.1          
 [33] XML_3.99-0.16             lubridate_1.9.3           httpuv_1.6.12             paletteer_1.5.0          
 [37] rappdirs_0.3.3            splines_4.3.1             RcppRoll_0.3.0            mclust_6.0.1             
 [41] prodlim_2023.08.28        ggraph_2.1.0              sctransform_0.4.1         ggbeeswarm_0.7.2         
 [45] DBI_1.1.3                 terra_1.7-55              HDF5Array_1.30.0          withr_2.5.2              
 [49] class_7.3-22              xgboost_1.7.6.1           lmtest_0.9-40             tidygraph_1.2.3          
 [53] rtracklayer_1.62.0        htmlwidgets_1.6.4         fs_1.6.3                  ggrepel_0.9.4            
 [57] SparseArray_1.2.2         cellranger_1.1.0          reticulate_1.34.0         zoo_1.8-12               
 [61] XVector_0.42.0            timechange_0.2.0          foreach_1.5.2             fansi_1.0.5              
 [65] grid_4.3.1                timeDate_4022.108         ggtree_3.10.0             rhdf5_2.46.1             
 [69] R.oo_1.25.0               irlba_2.3.5.1             ggrastr_1.0.2             gridGraphics_0.5-1       
 [73] ellipsis_0.3.2            lazyeval_0.2.2            yaml_2.3.7                survival_3.5-7           
 [77] scattermore_1.2           crayon_1.5.2              RcppAnnoy_0.0.21          RColorBrewer_1.1-3       
 [81] progressr_0.14.0          tweenr_2.0.2              later_1.3.1               ggridges_0.5.4           
 [85] codetools_0.2-19          GlobalOptions_0.1.2       KEGGREST_1.42.0           Rtsne_0.16               
 [89] shape_1.4.6               limma_3.58.1              Rsamtools_2.18.0          filelock_1.0.2           
 [93] DiceDesign_1.9            pkgconfig_2.0.3           xml2_1.3.6                GenomicAlignments_1.38.0 
 [97] aplot_0.2.2               spatstat.sparse_3.0-3     ape_5.7-1                 xtable_1.8-4             
[101] plyr_1.8.9                httr_1.4.7                tools_4.3.1               globals_0.16.2           
[105] hardhat_1.3.0             beeswarm_0.4.0            nlme_3.1-164              HDO.db_0.99.1            
[109] dbplyr_2.4.0              lme4_1.1-35.1             digest_0.6.33             Matrix_1.6-4             
[113] furrr_0.3.1               farver_2.1.1              reshape2_1.4.4            ks_1.14.1                
[117] yulab.utils_0.1.0         rpart_4.1.23              glue_1.6.2                cachem_1.0.8             
[121] BiocFileCache_2.10.1      polyclip_1.10-6           generics_0.1.3            Biostrings_2.70.1        
[125] mvtnorm_1.2-4             parallelly_1.36.0         statmod_1.5.0             R.cache_0.16.0           
[129] ScaledMatrix_1.10.0       minqa_1.2.6               pbapply_1.7-2             spam_2.10-0              
[133] gson_0.1.0                dqrng_0.3.2               utf8_1.2.4                gower_1.0.1              
[137] graphlayouts_1.0.2        shiny_1.8.0               lava_1.7.3                GenomeInfoDbData_1.2.11  
[141] R.utils_2.12.3            rhdf5filters_1.14.1       RCurl_1.98-1.13           memoise_2.0.1            
[145] pheatmap_1.0.12           R.methodsS3_1.8.2         future_1.33.0             RANN_2.6.1               
[149] spatstat.data_3.0-3       rstudioapi_0.15.0         cluster_2.1.6             janitor_2.2.0            
[153] spatstat.utils_3.0-4      hms_1.1.3                 fitdistrplus_1.1-11       munsell_0.5.0            
[157] cowplot_1.1.1             colorspace_2.1-0          rlang_1.1.2               DelayedMatrixStats_1.24.0
[161] sparseMatrixStats_1.14.0  ipred_0.9-14              dotCall64_1.1-1           ggforce_0.4.1            
[165] circlize_0.4.15           scuttle_1.12.0            mgcv_1.9-0                iterators_1.0.14         
[169] abind_1.4-5               GOSemSim_2.28.0           treeio_1.26.0             Rhdf5lib_1.24.0          
[173] bitops_1.0-7              promises_1.2.1            scatterpie_0.2.1          RSQLite_2.3.3            
[177] qvalue_2.34.0             fgsea_1.28.0              DelayedArray_0.28.0       GO.db_3.18.0             
[181] compiler_4.3.1            forcats_1.0.0             prettyunits_1.2.0         boot_1.3-28.1            
[185] beachmat_2.18.0           listenv_0.9.0             edgeR_4.0.2               BiocSingular_1.18.0      
[189] tensor_1.5                MASS_7.3-60               progress_1.2.2            spatstat.random_3.2-2    
[193] R6_2.5.1                  fastmap_1.1.1             fastmatch_1.1-4           vipor_0.4.5              
[197] ROCR_1.0-11               rsvd_1.0.5                nnet_7.3-19               gtable_0.3.4             
[201] KernSmooth_2.23-22        miniUI_0.1.1.1            deldir_2.0-2              htmltools_0.5.7          
[205] bit64_4.0.5               spatstat.explore_3.2-5    lifecycle_1.0.4           ggprism_1.0.4            
[209] nloptr_2.0.3              restfulr_0.0.15           vctrs_0.6.5               spatstat.geom_3.2-7      
[213] snakecase_0.11.1          DOSE_3.28.1               scran_1.30.0              ggfun_0.1.3              
[217] sp_2.1-2                  future.apply_1.11.0       pracma_2.4.4              pillar_1.9.0             
[221] prismatic_1.1.1           metapod_1.10.0            locfit_1.5-9.8            jsonlite_1.8.8           
[225] GetoptLong_1.0.5   

If I update SeuratObject to > version 5.0.0 which is where LayerData function is introduced, I get the same error as above when I run CellColorHeatmap()

No cell overlap between new meta data and Seurat object

And solution seem to be SeuratObject 4.1.4 or 4.1.3 but they don't work as I stated above.

vd4mmind commented 8 months ago

Is this error handed? It still persists with the available data in the package. Can you suggest what is the best way to tackle this? The downgrade is not helping.

ayyildizd commented 8 months ago

Unfortunately I had to go to the source code of many functions it wraps and change the problematic part myself to run it. The authors still need to look at this.

vd4mmind commented 8 months ago

Thanks for responding. Can you share your solution if it is possible? The downgrade does not work and compatibility exists. Also there is no recommendation which version of SCP should be used if Seuratand SeuratObjectis downgraded.

redtorrentCN commented 8 months ago

Unfortunately I had to go to the source code of many functions it wraps and change the problematic part myself to run it. The authors still need to look at this.

sorry to bother, could you please share ur solution about package compatibility? thank you very much! @ayyildizd