smorabit / hdWGCNA

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

performing hdWGCNA analysis for seurat Assay5 object #246

Open wangBiojin opened 1 month ago

wangBiojin commented 1 month ago

Error Hello! Thank you for creating such an awesome package! I used seurat assay 5 to perform hdWGCNA analysis. All function worked well until ModuleEigengenes function. When I run ModuleEigengenes, I got an error "Error in ModuleEigengenes(seurat_obj, group.by.vars = "sample"): no slot of name data for this object of class "Assay5""

seurat_obj <- readRDS("../normalized_data/nodule/our.data.singlet.filter.mtpt5.200-7500-300-15000.seurat_integrated.rds")

seurat_obj <- SetupForWGCNA(
  seurat_obj,
  gene_select = "fraction", # gene selection approach
  fraction = 0.05, 
  wgcna_name = "Jixian"
)

seurat_obj <- MetacellsByGroups(
  seurat_obj = seurat_obj,
  group.by = c("Cell_type","sample"),
  reduction = "integrated.harmony",
  k=25,
  max_shared = 10,
  ident.group = 'Cell_type',
  min_cells = 200
)
seurat_obj <- NormalizeMetacells(seurat_obj)

seurat_obj@misc$Jixian$wgcna_metacell_obj <- JoinLayers(object = seurat_obj@misc$Jixian$wgcna_metacell_obj , layers = "data")
seurat_obj <- SetDatExpr(
  seurat_obj,
  use_metacells = TRUE,
  group_name = "Infected Cell",
  group.by = "Cell_type",
  assay = "RNA",
  #layer = "data"
  slot = "data"
)

seurat_obj <- TestSoftPowers(
  seurat_obj,
  networkType = 'signed'
)

seurat_obj <- ConstructNetwork(
  seurat_obj,
  tom_name="Infected_cell",
  overwrite_tom = TRUE,
  soft_power = 8
)

seurat_obj <- ScaleData(seurat_obj, features = rownames(seurat_obj))

seurat_obj <-ModuleEigengenes(
  seurat_obj,
  assay = "RNA",
  group.by.vars = "sample"
)

Could you please help me fix this? I would be very grateful!

smorabit commented 1 month ago

Hi,

Thank you for writing this issue. Unfortunately I have not come across this error and I am currently unable to reproduce it even with the Assay5 object. I am wondering if the issue stems from some issue with how you created your Seurat object? Either way I will need to be able to reproduce this error in order to help resolve your issue.