smorabit / hdWGCNA

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

error in ModuleEigengenes function #39

Closed nfancy closed 1 year ago

nfancy commented 1 year ago

Hi,

Thank you for this great package, I could successfully build the network but is getting an error at this stage.

seurat_obj <- ModuleEigengenes(
  seurat_obj,
  group.by.vars="manifest"
  #modules = seurat_obj@misc$enriched_micro$wgcna_modules,
  #vars.to.regress = c("nCount_RNA", "pc_mito", "sex", "PMI", "age"),
  #assay = "RNA"
 )
[1] "grey"
Centering and scaling data matrix
 |===========================================================================================| 100%
Error in data.use[features, ] : subscript out of bounds

I checked the code and tried to execute the individual commands an it seems all the genes are present, not sure, why it's giving the subscript out of bounds error. Any help is appreciated.

Best wishes Nurun

smorabit commented 1 year ago

Can you update to the most recent version of hdWGCNA and try again?

devtools::install_github('smorabit/hdWGCNA', ref='dev')
nfancy commented 1 year ago

thanks, I'll try.

nfancy commented 1 year ago

Hi, sorry to reopen, the issue still persists.

nfancy commented 1 year ago

Hi, I believe, I've debugged the issue. You will need as.character at line 520 in this https://github.com/smorabit/hdWGCNA/blob/dev/R/WGCNA_functions.R function. As when the gene names as factor this creates the issue.

 cur_genes <- modules %>% subset(module == cur_mod) %>% .$gene_name
 cur_genes <- as.character(modules %>% subset(module == cur_mod) %>% .$gene_name)
smorabit commented 1 year ago

I added as.character as you suggested in the latest version.