smorabit / hdWGCNA

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

The tutorial codes cannot be run (TestSoftPowers) #130

Closed chiwwong closed 10 months ago

chiwwong commented 10 months ago

I am following the basic tutorial here and was using the example dataset. However, I cannot proceed since TestSoftPowers. It returns the following error:

Error in datk[c(startG:endG), ] = foreach(t = actualThreads, .combine = rbind) %dopar% :
number of items to replace is not a multiple of replacement length

I also encountered an error in the previous optional step for doing PCA for the metacells RunPCAMetacells, and it gave me the following error message:

Error in irlba(A = t(x = object), nv = npcs, ...) :
max(nu, nv) must be positive

Below is my session info.

R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.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-arm64/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: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] hdWGCNA_0.2.19          WGCNA_1.72-1            fastcluster_1.2.3       dynamicTreeCut_1.63-1   patchwork_1.1.2         cowplot_1.1.1          
 [7] lubridate_1.9.2         forcats_1.0.0           stringr_1.5.0           dplyr_1.1.2             purrr_1.0.1             readr_2.1.4            
[13] tidyr_1.3.0             tibble_3.2.1            ggplot2_3.4.2           tidyverse_2.0.0         SeuratObject_4.9.9.9085 Seurat_4.3.0.1         

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.20        splines_4.3.0           later_1.3.1             bitops_1.0-7            polyclip_1.10-4         preprocessCore_1.62.1  
  [7] rpart_4.1.19            lifecycle_1.0.3         doParallel_1.0.17       globals_0.16.2          lattice_0.21-8          MASS_7.3-60            
 [13] backports_1.4.1         magrittr_2.0.3          rmarkdown_2.22          Hmisc_5.1-0             plotly_4.10.2           httpuv_1.6.11          
 [19] sctransform_0.3.5       spam_2.9-1              sp_2.0-0                spatstat.sparse_3.0-2   reticulate_1.30         pbapply_1.7-2          
 [25] DBI_1.1.3               RColorBrewer_1.1-3      abind_1.4-5             zlibbioc_1.46.0         Rtsne_0.16              BiocGenerics_0.46.0    
 [31] RCurl_1.98-1.12         nnet_7.3-19             GenomeInfoDbData_1.2.10 IRanges_2.34.0          S4Vectors_0.38.1        ggrepel_0.9.3          
 [37] irlba_2.3.5.1           listenv_0.9.0           spatstat.utils_3.0-3    goftest_1.2-3           spatstat.random_3.1-5   fitdistrplus_1.1-11    
 [43] parallelly_1.36.0       leiden_0.4.3            codetools_0.2-19        tidyselect_1.2.0        farver_2.1.1            tester_0.1.7           
 [49] matrixStats_1.0.0       stats4_4.3.0            base64enc_0.1-3         spatstat.explore_3.2-1  jsonlite_1.8.5          ellipsis_0.3.2         
 [55] progressr_0.13.0        Formula_1.2-5           ggridges_0.5.4          survival_3.5-5          iterators_1.0.14        foreach_1.5.2          
 [61] tools_4.3.0             ica_1.0-3               Rcpp_1.0.10             glue_1.6.2              gridExtra_2.3           xfun_0.39              
 [67] GenomeInfoDb_1.36.0     withr_2.5.0             fastmap_1.1.1           fansi_1.0.4             digest_0.6.31           timechange_0.2.0       
 [73] R6_2.5.1                mime_0.12               colorspace_2.1-0        scattermore_1.2         GO.db_3.17.0            tensor_1.5             
 [79] spatstat.data_3.0-1     RSQLite_2.3.1           utf8_1.2.3              generics_0.1.3          data.table_1.14.8       FNN_1.1.3.2            
 [85] httr_1.4.6              htmlwidgets_1.6.2       uwot_0.1.15             pkgconfig_2.0.3         gtable_0.3.3            blob_1.2.4             
 [91] impute_1.74.1           lmtest_0.9-40           XVector_0.40.0          htmltools_0.5.5         dotCall64_1.0-2         scales_1.2.1           
 [97] Biobase_2.60.0          png_0.1-8               harmony_0.1.1           knitr_1.43              rstudioapi_0.14         tzdb_0.4.0             
[103] reshape2_1.4.4          checkmate_2.2.0         nlme_3.1-162            zoo_1.8-12              cachem_1.0.8            KernSmooth_2.23-21     
[109] parallel_4.3.0          miniUI_0.1.1.1          foreign_0.8-84          AnnotationDbi_1.62.1    pillar_1.9.0            grid_4.3.0             
[115] vctrs_0.6.3             RANN_2.6.1              promises_1.2.0.1        xtable_1.8-4            cluster_2.1.4           htmlTable_2.4.1        
[121] evaluate_0.21           cli_3.6.1               compiler_4.3.0          rlang_1.1.1             crayon_1.5.2            future.apply_1.11.0    
[127] labeling_0.4.2          plyr_1.8.8              stringi_1.7.12          viridisLite_0.4.2       deldir_1.0-9            munsell_0.5.0          
[133] Biostrings_2.68.1       lazyeval_0.2.2          spatstat.geom_3.2-1     Matrix_1.5-4.1          hms_1.1.3               bit64_4.0.5            
[139] future_1.32.0           KEGGREST_1.40.0         shiny_1.7.4             ROCR_1.0-11             igraph_1.5.0            memoise_2.0.1          
[145] bit_4.0.5          
smorabit commented 10 months ago

Unfortunately I am not able to reproduce your error. Are you able to run this on any dataset? Based on the error message it looks like it could be a multithreading issue.

chiwwong commented 10 months ago

I used a Mac (Rstudio) and I have also tried in a Linux environment with pure R and the problem was solved. However, I am not able to reproduce the plot shown in the tutorial even though I have used the same seed. The power was chosen at 8, rather than the 9 shown in the tutorial. soft-power_plot

smorabit commented 10 months ago

Glad you were able to run the code. Just for your information, I don't re-generate the tutorial figures with each update, and at this point they are a few versions out of date so I am not surprised that the images you generate are not the exact same as the figures on the tutorial.

chiwwong commented 9 months ago

Sure. Should I assume the current code is always better than the previous version (at least when I use the default parameters)?

I would also like to know if you are aware of the following warning and how to solve it: Warning: Invalid name supplied, making object name syntactically valid. New object name is INH.M1_UCellINH.M2_UCellINH.M3_UCellINH.M4_UCellINH.M5_UCellINH.M6_UCellINH.M7_UCellINH.M8_UCellINH.M9_UCellINH.M10_UCellINH.M11_UCellINH.M12_UCellINH.M13_UCellINH.M14_UCellINH.M15_UCellINH.M16_UCell; see ?make.names for more details on syntax validity

This is shown when I execute:

seurat_obj <- ModuleExprScore(
  seurat_obj,
  n_genes = 25,
  method='UCell'
)

Given the deviation of the results in early step, would you mind also upload the sample datasets: 'data/Zhou_control.rds' and 'Zhou_2020_hdWGCNA.rds'? They are required in tutorials here and here. I would like to test the pipeline and be sure I am correct in my interpretations. For example, I was seeing some extreme values in the lollipop plot. DMEsLollipop_plot

Some minor points:

  1. wgcna_name='INH' in the tutorial here, should refer back to wgcna_name='tutorial' which is the one used in the first tutorial.

  2. I suggest you to include the dependency of the packages: qlcMatrix, ggforestplot, enrichR, and corrplot.

  3. I also found that the package ggrepel is not loaded when calling function PlotDMEsVolcano.

Thanks!