drieslab / Giotto

Spatial omics analysis toolbox
https://drieslab.github.io/Giotto_website/
Other
240 stars 94 forks source link

Error in stats::kmeans(x, centers = 2, nstart = nstart, iter.max = iter.max) #940

Open rocketeer1998 opened 2 months ago

rocketeer1998 commented 2 months ago

Hi @gcyuan @bernard2012 @wwang-chcn @RubD @pacificma , thanks for your contribution to Giotto! I'm stuck in reproducing MERFISH pipeline to find spatially variable genes (SVG). I want to try it though there is no SVG section in MERFISH documentation. https://drieslab.github.io/Giotto_website/articles/merfish_mouse_hypothalamic.html. After running:

ranktest = binSpect(merFISH_gobject, 
                    bin_method = 'kmeans',
                    expression_values = 'normalized',
                    calc_hub = T, 
                    hub_min_int = 5,
                    spatial_network_name = 'spatial_network')

An error occurred:

This is the single parameter version of binSpect
Error in stats::kmeans(x, centers = 2, nstart = nstart, iter.max = iter.max) : 
  群集中心的数目要比数据点数目多。

Seems like a bug in kmeans part. Below is my working environment:

> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8  LC_CTYPE=Chinese (Simplified)_China.utf8   
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C                               
[5] LC_TIME=Chinese (Simplified)_China.utf8    

time zone: Asia/Shanghai
tzcode source: internal

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

other attached packages:
 [1] Giotto_4.0.5                GiottoClass_0.2.3           SpatialExperiment_1.12.0    SingleCellExperiment_1.24.0
 [5] SummarizedExperiment_1.32.0 Biobase_2.62.0              GenomicRanges_1.54.1        GenomeInfoDb_1.38.8        
 [9] IRanges_2.36.0              S4Vectors_0.40.2            BiocGenerics_0.48.1         MatrixGenerics_1.14.0      
[13] matrixStats_1.2.0           ggplot2_3.5.0               DESpace_1.2.1              

loaded via a namespace (and not attached):
 [1] colorRamp2_0.1.0        bitops_1.0-7            rlang_1.1.3             magrittr_2.0.3         
 [5] GiottoUtils_0.1.6       compiler_4.3.0          systemfonts_1.0.6       png_0.1-8              
 [9] callr_3.7.6             vctrs_0.6.5             pkgconfig_2.0.3         crayon_1.5.2           
[13] backports_1.4.1         magick_2.8.3            XVector_0.42.0          labeling_0.4.3         
[17] utf8_1.2.4              ps_1.7.6                ragg_1.3.0              purrr_1.0.2            
[21] zlibbioc_1.48.2         jsonlite_1.8.8          pak_0.7.2               DelayedArray_0.28.0    
[25] BiocParallel_1.36.0     tweenr_2.0.3            terra_1.7-71            broom_1.0.5            
[29] parallel_4.3.0          R6_2.5.1                limma_3.58.1            reticulate_1.35.0      
[33] car_3.1-2               pkgload_1.3.4           Rcpp_1.0.12             assertthat_0.2.1       
[37] igraph_2.0.3            Matrix_1.6-5            splines_4.3.0           tidyselect_1.2.1       
[41] rstudioapi_0.16.0       abind_1.4-5             codetools_0.2-20        processx_3.8.4         
[45] lattice_0.22-6          tibble_3.2.1            withr_3.0.0             polyclip_1.10-6        
[49] pillar_1.9.0            BiocManager_1.30.22     ggpubr_0.6.0            carData_3.0-5          
[53] checkmate_2.3.1         dbscan_1.1-12           generics_0.1.3          RCurl_1.98-1.14        
[57] munsell_0.5.1           scales_1.3.0            gtools_3.9.5            glue_1.7.0             
[61] tools_4.3.0             GiottoVisuals_0.1.6     ggnewscale_0.4.10       data.table_1.15.4      
[65] locfit_1.5-9.9          ggsignif_0.6.4          cowplot_1.1.3           grid_4.3.0             
[69] tidyr_1.3.1             edgeR_4.0.16            colorspace_2.1-0        GenomeInfoDbData_1.2.11
[73] patchwork_1.2.0         ggforce_0.4.2           cli_3.6.2               rappdirs_0.3.3         
[77] textshaping_0.3.7       fansi_1.0.6             S4Arrays_1.2.1          dplyr_1.1.4            
[81] gtable_0.3.4            rstatix_0.7.2           SparseArray_1.2.4       rjson_0.2.21           
[85] farver_2.1.1            lifecycle_1.0.4         statmod_1.5.0           MASS_7.3-60.0.1