Skip to content

ConstructNetwork() sets $wgcna_modules from active_wgcna instead of using the wgcna_name parameter #397

@fcylee

Description

@fcylee

Hello!
I ran into trouble when having multiple wgcna experiments in one object where the modules (from GetModules()) are all the same across different ConstructNetwork() runs, leading to errors in PlotDendrogram() as the colors do not match. I believe this is the bug and fix.

Describe the bug
ConstructNetwork() saves $wgcna_modules from the wgcna experiment that is named in active_wgcna rather than the one specified by the wgcna_name parameter in the function.

Existing code

  # set the modules df in the Seurat object
  mods <- GetNetworkData(seurat_obj)$colors
  seurat_obj <- SetModules(
    seurat_obj, modules = data.frame(
      "gene_name" = names(mods),
      "module" = factor(mods, levels=unique(mods)),
      "color" = mods
    ), wgcna_name
  )

Suggested fix

  # set the modules df in the Seurat object
  mods <- GetNetworkData(seurat_obj, wgcna_name)$colors     #added wgcna_name
  seurat_obj <- SetModules(    
    seurat_obj, modules = data.frame(
      "gene_name" = names(mods),
      "module" = factor(mods, levels=unique(mods)),
      "color" = mods
    ), wgcna_name
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions