smorabit / hdWGCNA

High dimensional weighted gene co-expression network analysis
https://smorabit.github.io/hdWGCNA/
Other
327 stars 33 forks source link

Error when running "ModuleEigengenes()" with a seurat.v5 object #271

Open Zweig-Wong opened 1 month ago

Zweig-Wong commented 1 month ago

When running ModuleEigengenes() with a seurat.v5 object I got an error:

Error in `LayerData<-`:
! 'layer' must be a single non-empty string

It can be traced back to SetAssayData() in ComputeModuleEigengene

Backtrace:
    ▆
 1. └─hdWGCNA::ModuleEigengenes(...)
 2.   └─hdWGCNA:::ComputeModuleEigengene(...)
 3.     ├─SeuratObject::SetAssayData(...) at <tmp>:27:9
 4.     └─SeuratObject:::SetAssayData.Seurat(...)
 5.       ├─SeuratObject::SetAssayData(...)
 6.       └─SeuratObject:::SetAssayData.StdAssay(...)
 7.         ├─SeuratObject::`LayerData<-`(object = `*tmp*`, layer = slot, value = new.data)
 8.         └─SeuratObject:::`LayerData<-.Assay5`(object = `*tmp*`, layer = slot, value = new.data)
 9.           └─rlang::abort(message = "'layer' must be a single non-empty string")

Steps to reproduce

NPC <- ModuleEigengenes(NPC, group.by.vars = "orig.ident")

R session info

> sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

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

time zone: Asia/Shanghai
tzcode source: system (glibc)

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

other attached packages:
 [1] hdWGCNA_0.3.02        igraph_1.5.1          WGCNA_1.71           
 [4] fastcluster_1.2.3     dynamicTreeCut_1.63-1 ggrepel_0.9.4        
 [7] harmony_1.2.0         Rcpp_1.0.11           future_1.33.0        
[10] ggalluvial_0.12.5     ggpubr_0.6.0          clustree_0.5.1       
[13] ggraph_2.1.0          patchwork_1.2.0       Seurat_5.0.3         
[16] SeuratObject_5.0.0    sp_2.1-2              this.path_2.3.0      
[19] vroom_1.6.4           data.table_1.14.8     lubridate_1.9.3      
[22] forcats_1.0.0         stringr_1.5.1         dplyr_1.1.3          
[25] purrr_1.0.2           readr_2.1.4           tidyr_1.3.0          
[28] tibble_3.2.1          ggplot2_3.4.4         tidyverse_2.0.0      

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.21        splines_4.3.2           later_1.3.2            
  [4] bitops_1.0-7            polyclip_1.10-6         preprocessCore_1.64.0  
  [7] rpart_4.1.23            fastDummies_1.7.3       lifecycle_1.0.4        
 [10] rstatix_0.7.2           doParallel_1.0.17       globals_0.16.2         
 [13] lattice_0.22-5          MASS_7.3-60             backports_1.4.1        
 [16] magrittr_2.0.3          rmarkdown_2.25          Hmisc_5.1-1            
 [19] plotly_4.10.4           httpuv_1.6.13           sctransform_0.4.1      
 [22] spam_2.10-0             spatstat.sparse_3.0-3   reticulate_1.34.0      
 [25] cowplot_1.1.1           pbapply_1.7-2           DBI_1.1.3              
 [28] RColorBrewer_1.1-3      zlibbioc_1.48.0         abind_1.4-5            
 [31] Rtsne_0.17              RCurl_1.98-1.12         BiocGenerics_0.48.1    
 [34] nnet_7.3-19             tweenr_2.0.3            GenomeInfoDbData_1.2.11
 [37] IRanges_2.36.0          S4Vectors_0.40.2        irlba_2.3.5.1          
 [40] listenv_0.9.0           spatstat.utils_3.0-4    goftest_1.2-3          
 [43] RSpectra_0.16-1         spatstat.random_3.2-3   fitdistrplus_1.1-11    
 [46] parallelly_1.36.0       leiden_0.4.3.1          codetools_0.2-19       
 [49] ggforce_0.4.2           tidyselect_1.2.0        farver_2.1.1           
 [52] tester_0.2.0            viridis_0.6.5           base64enc_0.1-3        
 [55] matrixStats_1.0.0       stats4_4.3.2            spatstat.explore_3.2-6 
 [58] jsonlite_1.8.8          Formula_1.2-5           ellipsis_0.3.2         
 [61] tidygraph_1.3.0         progressr_0.14.0        ggridges_0.5.6         
 [64] survival_3.5-7          iterators_1.0.14        foreach_1.5.2          
 [67] ica_1.0-3               glue_1.6.2              gridExtra_2.3          
 [70] xfun_0.41               GenomeInfoDb_1.38.1     withr_2.5.2            
 [73] fastmap_1.1.1           fansi_1.0.6             digest_0.6.33          
 [76] timechange_0.2.0        R6_2.5.1                mime_0.12              
 [79] colorspace_2.1-0        scattermore_1.2         GO.db_3.18.0           
 [82] tensor_1.5              spatstat.data_3.0-4     RSQLite_2.3.1          
 [85] utf8_1.2.4              generics_0.1.3          FNN_1.1.3.2            
 [88] graphlayouts_1.1.0      httr_1.4.7              htmlwidgets_1.6.4      
 [91] uwot_0.1.16             pkgconfig_2.0.3         gtable_0.3.4           
 [94] blob_1.2.4              impute_1.76.0           lmtest_0.9-40          
 [97] XVector_0.42.0          htmltools_0.5.7         carData_3.0-5          
[100] dotCall64_1.1-1         scales_1.2.1            Biobase_2.62.0         
[103] png_0.1-8               rstudioapi_0.15.0       knitr_1.45             
[106] tzdb_0.4.0              reshape2_1.4.4          checkmate_2.3.0        
[109] nlme_3.1-163            proxy_0.4-27            zoo_1.8-12             
[112] cachem_1.0.8            KernSmooth_2.23-22      parallel_4.3.2         
[115] miniUI_0.1.1.1          foreign_0.8-86          AnnotationDbi_1.64.1   
[118] pillar_1.9.0            grid_4.3.2              vctrs_0.6.5            
[121] RANN_2.6.1              promises_1.2.1          car_3.1-2              
[124] xtable_1.8-4            cluster_2.1.6           htmlTable_2.4.1        
[127] evaluate_0.23           cli_3.6.1               compiler_4.3.2         
[130] rlang_1.1.2             crayon_1.5.2            future.apply_1.11.0    
[133] ggsignif_0.6.4          labeling_0.4.3          plyr_1.8.9             
[136] stringi_1.8.2           viridisLite_0.4.2       deldir_2.0-4           
[139] munsell_0.5.0           Biostrings_2.70.1       lazyeval_0.2.2         
[142] spatstat.geom_3.2-9     pacman_0.5.1            Matrix_1.6-1.1         
[145] RcppHNSW_0.6.0          hms_1.1.3               bit64_4.0.5            
[148] KEGGREST_1.42.0         shiny_1.8.0             ROCR_1.0-11            
[151] broom_1.0.5             memoise_2.0.1           bit_4.0.5 

Screenshots image

I would appreciate it if you could address this problem. Thanks.

Zweig-Wong commented 1 month ago

I thought I found the way to fix it: image Just use the old arg "slot" instead of the new one "layer".

smorabit commented 1 month ago

Hi, I am unfortunately not able to reproduce your error. Is this problem specific to your dataset, or does it happen on any dataset that you use like the tutorial dataset?

Zweig-Wong commented 1 month ago

Hi, I am unfortunately not able to reproduce your error. Is this problem specific to your dataset, or does it happen on any dataset that you use like the tutorial dataset?

Thanks for your reply! I haven't tried other datasets yet, but my data was updated from a seurat v4 object using UpdateSeuratObject(). I wonder whether there are some compatibility issues relating to the update...? But changing the layer to slot in that line did work for my data. If this problem does not happen on other data, maybe it's not a big deal? Anyway, currently it works just fine. Thanks a lot for developing this creative algorithm!

smorabit commented 1 month ago

Okay that is interesting, I have tested hdWGCNA successfully with Seurat v4 and Seurat v5 objects, but I have not tried using UpdateSeuratObject, so maybe the issue is related to how the data is re-formatted with that function. I will perform some additional testing to see if I can reproduce the issue.

CWYuan08 commented 3 days ago

Dear @smorabit @Zweig-Wong @samuel-marsh @rootze I am encountering a similar error,

seurat_obj <- SetDatExpr(

I checked layer 'data' is not empty and I am running with seurat V5. Do you have any idea on how to debug this?

Thank you very much! CW