Skip to content

ProjectModules not flexible to user-defined modules #406

@zvittorio

Description

@zvittorio

Hello!

First of all, congrats on the amazing package, really!
I was trying to project WGCNA modules that were laying around in the lab from past experiments onto a recent scRNA-seq dataset.
The modules were saved as a text file with each row containing the gene name and the module assignment. We wanted to use hdWGCNA::ProjectModules to score their activities on scRNA-seq data and I used the following code:

library(Seurat)
library(hdWGCNA)

seurObj <- readRDS("Seurat.rds")

mods <- read.table('bulk_modules.txt', 
                      header = F, 
                      sep = "\t")

colnames(mods) <- c("gene_name", "module")
mods$color <- "grey" # just to fill the column

seurObj <- ProjectModules(
  seurat_obj = seurObj,
  modules = mods,
  seurat_ref = NULL,
  wgcna_name = "hdWGCNA",
  wgcna_name_proj = 'Modules_consensus')

Now, based on the documentation, ProjectModules can also work with a user-defined table of modules bypassing the argument seurat_ref. However, I was getting the following error:

Error in seurat_obj@misc : 
  no applicable method for `@` applied to an object of class "NULL"

Which seems to be coming from CheckWGCNAName at line 38.
For this reason I created a pull request #405 for ProjectModules where:

  • seurat_ref has a default value of NULL
  • seurat_ref is checked with CheckWGCNAName only when different than NULL
  • function stops if both seurat_ref and modules are NULL

It works on my end, and the classical behavior (with both seurat_obj and seurat_ref being provided) should not changed.
Let me know if I misunderstood anything!

Vittorio

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