Not getting any Kme (NaN) values after "ModuleConnectivity"
Describe the bug After running the MolduleConnectivity function all the Kme values are 0. I do not get any errors. I have me and hme values.
Steps to reproduce I am following along from the introduction vignette using my own dataset. I ran all of the standard seurat functions on the data (removed dead, scaled normalize, vst, pca, UMAP, DEGs, etc). Have not tried to reproduce the error on a tutorial dataset.
EM <- SetupForWGCNA(
EM,
gene_select = "fraction", # the gene selection approach
fraction = 0.05, # fraction of cells that a gene needs to be expressed in order to be included
wgcna_name = "EM_WGCNA" # the name of the hdWGCNA experiment
)
# construct metacells in each group
EM <- MetacellsByGroups(
EM,
group.by = c("sample_group"), # specify the columns in [email protected] to group by
reduction = 'harmony', # select the dimensionality reduction to perform KNN on
k = 25, # nearest-neighbors parameter
min_cells = 100,
max_shared = 10, # maximum number of shared cells between two metacells
ident.group = 'sample_group' # set the Idents of the metacell seurat object
)
# normalize metacell expression matrix:
EM <- NormalizeMetacells(EM)
EM <- SetDatExpr(
EM,
group_name = c("EM1", "EM2", "EM3"),
group.by='sample_group',
assay = 'RNA', # using RNA assay
slot = 'data' # using normalized data
)
# Test different soft powers:
EM <- TestSoftPowers(
EM,
networkType = 'signed' # you can also use "unsigned" or "signed hybrid"
)
# plot the results:
plot_list <- PlotSoftPowers(EM)
# assemble with patchwork
wrap_plots(plot_list, ncol=2)
# construct co-expression network:
EM <- ConstructNetwork(
EM,
tom_name = 'sample_group' # name of the topoligical overlap matrix written to disk
)
PlotDendrogram(EM, main='group hdWGCNA Dendrogram') (I see a dendrogram with various modules
# compute all MEs in the full single-cell dataset
EM <- ModuleEigengenes(
EM,
group.by.vars="donor"
)
# harmonized module eigengenes:
hMEs <- GetMEs(EM)
# module eigengenes:
MEs <- GetMEs(EM, harmonized=FALSE)
# compute eigengene-based connectivity (kME):
EM <- ModuleConnectivity(
EM,
group.by = 'sample_group'
)
> head(modules[,1:6])
gene_name module color kME_grey kME_EM-M1 kME_EM-M2
LINC01409 LINC01409 grey grey NaN NaN NaN
LINC01128 LINC01128 EM-M1 pink NaN NaN NaN
NOC2L NOC2L grey grey NaN NaN NaN
HES4 HES4 grey grey NaN NaN NaN
ISG15 ISG15 EM-M2 yellow NaN NaN NaN
C1orf159 C1orf159 grey grey NaN NaN NaN
I also tried plotting with the following but, of course, nothing was there
p <- PlotKMEs(EM, ncol=5)
p
R session info sessionInfo() R version 4.4.0 (2024-04-24) Platform: x86_64-apple-darwin20 Running under: macOS Monterey 12.6.3
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.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.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/New_York tzcode source: internal
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] UCell_2.8.0 hdWGCNA_0.3.03 igraph_2.0.3 ggrepel_0.9.5 WGCNA_1.72-5 fastcluster_1.2.6 dynamicTreeCut_1.63-1 cowplot_1.1.3 harmony_1.2.0
[10] Rcpp_1.0.12 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1
[19] tidyverse_2.0.0 patchwork_1.2.0 dplyr_1.1.4 Seurat_5.1.0 SeuratObject_5.0.2 sp_2.1-4
loaded via a namespace (and not attached):
[1] fs_1.6.4 matrixStats_1.3.0 spatstat.sparse_3.0-3 devtools_2.4.5 httr_1.4.7 RColorBrewer_1.1-3 doParallel_1.0.17
[8] profvis_0.3.8 tools_4.4.0 sctransform_0.4.1 backports_1.5.0 utf8_1.2.4 R6_2.5.1 lazyeval_0.2.2
[15] uwot_0.2.2 urlchecker_1.0.1 withr_3.0.0 gridExtra_2.3 preprocessCore_1.66.0 progressr_0.14.0 cli_3.6.2
[22] Biobase_2.64.0 textshaping_0.4.0 spatstat.explore_3.2-7 fastDummies_1.7.3 labeling_0.4.3 spatstat.data_3.0-4 proxy_0.4-27
[29] ggridges_0.5.6 pbapply_1.7-2 systemfonts_1.1.0 foreign_0.8-86 parallelly_1.37.1 sessioninfo_1.2.2 rstudioapi_0.16.0
[36] impute_1.78.0 RSQLite_2.3.7 FNN_1.1.4 generics_0.1.3 ica_1.0-3 spatstat.random_3.2-3 GO.db_3.19.1
[43] Matrix_1.7-0 fansi_1.0.6 S4Vectors_0.42.0 abind_1.4-5 lifecycle_1.0.4 yaml_2.3.8 SummarizedExperiment_1.34.0
[50] SparseArray_1.4.8 Rtsne_0.17 grid_4.4.0 blob_1.2.4 promises_1.3.0 crayon_1.5.2 miniUI_0.1.1.1
[57] lattice_0.22-6 KEGGREST_1.44.0 pillar_1.9.0 knitr_1.47 GenomicRanges_1.56.0 future.apply_1.11.2 codetools_0.2-20
[64] leiden_0.4.3.1 glue_1.7.0 data.table_1.15.4 remotes_2.5.0 vctrs_0.6.5 png_0.1-8 spam_2.10-0
[71] gtable_0.3.5 cachem_1.1.0 xfun_0.44 S4Arrays_1.4.1 mime_0.12 survival_3.6-4 SingleCellExperiment_1.26.0
[78] iterators_1.0.14 ellipsis_0.3.2 fitdistrplus_1.1-11 ROCR_1.0-11 nlme_3.1-164 usethis_2.2.3 bit64_4.0.5
[85] RcppAnnoy_0.0.22 GenomeInfoDb_1.40.1 irlba_2.3.5.1 KernSmooth_2.23-24 rpart_4.1.23 colorspace_2.1-0 BiocGenerics_0.50.0
[92] DBI_1.2.2 Hmisc_5.1-3 nnet_7.3-19 tidyselect_1.2.1 bit_4.0.5 compiler_4.4.0 htmlTable_2.4.2
[99] BiocNeighbors_1.22.0 DelayedArray_0.30.1 plotly_4.10.4 checkmate_2.3.1 scales_1.3.0 lmtest_0.9-40 digest_0.6.35
[106] goftest_1.2-3 spatstat.utils_3.0-4 presto_1.0.0 rmarkdown_2.27 XVector_0.44.0 RhpcBLASctl_0.23-42 htmltools_0.5.8.1
[113] pkgconfig_2.0.3 base64enc_0.1-3 MatrixGenerics_1.16.0 fastmap_1.2.0 rlang_1.1.4 htmlwidgets_1.6.4 UCSC.utils_1.0.0
[120] shiny_1.8.1.1 farver_2.1.2 zoo_1.8-12 jsonlite_1.8.8 BiocParallel_1.38.0 magrittr_2.0.3 Formula_1.2-5
[127] GenomeInfoDbData_1.2.12 dotCall64_1.1-1 munsell_0.5.1 viridis_0.6.5 reticulate_1.37.0 stringi_1.8.4 zlibbioc_1.50.0
[134] MASS_7.3-60.2 plyr_1.8.9 pkgbuild_1.4.4 parallel_4.4.0 listenv_0.9.1 deldir_2.0-4 Biostrings_2.70.3
[141] splines_4.4.0 tensor_1.5 hms_1.1.3 spatstat.geom_3.2-9 RcppHNSW_0.6.0 reshape2_1.4.4 stats4_4.4.0
[148] pkgload_1.3.4 evaluate_0.23 tester_0.2.0 BiocManager_1.30.23 tzdb_0.4.0 foreach_1.5.2 httpuv_1.6.15
[155] RANN_2.6.1 polyclip_1.10-6 future_1.33.2 scattermore_1.2 xtable_1.8-4 RSpectra_0.16-1 later_1.3.2
[162] viridisLite_0.4.2 ragg_1.3.2 memoise_2.0.1 AnnotationDbi_1.66.0 IRanges_2.38.0 cluster_2.1.6 timechange_0.3.0
[169] globals_0.16.3
Hi, thank you for taking the time to write this issue.
Have not tried to reproduce the error on a tutorial dataset.
I have never personally run into this issue in any of my testing, and I need to be able to reproduce your error in order to help resolve it. Please let me know if you get the same behavior when using the tutorial dataset.
Hi @Paoloorder66,
I have the exact error:
Were you able to fix this?
Thank you so much!
@apal6 @Paoloorder66
Are either of you able to reproduce this error with the tutorial data, or does this only appear on your own dataset?
Hi @smorabit, I wasn't able to reproduce with the tutorial data. It just works fine.
Looks like there is something with my data but not sure what as there isn't any error. However, I just looked at the warnings after running
seurat_obj <- TestSoftPowers( seurat_obj, networkType = 'signed' # you can also use "unsigned" or "signed hybrid")
Warning messages: 1: In (function (x, y = NULL, robustX = TRUE, robustY = TRUE, ... : bicor: zero MAD in variable 'x'. Pearson correlation was used for individual columns with zero (or missing) MAD. 2: In (function (x, y = NULL, robustX = TRUE, robustY = TRUE, ... :
Any suggestions?
Thank you, Aastha
If you are able to run it on the tutorial data without this issue, it seems that the issue likely is due to something about your particular dataset. Unfortunately I don't have any suggestions or any ability to diagnose the problem / provide a solution unless I can reproduce the behavior myself.
Closing due to inactivity.
I got the same issue here, is there any solutions?
Are you able to provide a reproducible example that I can run? I have not found this error myself so it is difficult for me to help at this time.
I ran into this same issue. It turns out that I was confusing the tom_name parameter in ConstructNetwork (which can be whatever you wish) and the group_name parameter in ModuleConnectivity (which should be a set drawn from the column you specify in group.by). Because these parameters are both specified as 'INH' in the tutorial, I mixed them up. I hope this is helpful to others!