Closed jijjigae closed 1 week ago
Hi, I am not able to recreate your error with the latest version of hdWGCNA, but I am looking at the behavior of the function CheckWGCNAName
. I am able to get the same error message if I run this:
CheckWGCNAName(seurat_obj, wgcna_name=NULL)
However, in the code for RunEnrichr
, wgcna_name
should not be assigned to NULL
. This is the code from RunEnrichr
:
if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}
CheckWGCNAName(seurat_obj, wgcna_name)
I can't duplicate this behavior when running RunEnrichr
, and I can't see where in the code it would be going wrong.
I wonder if somehow your active_wgcna
has been set to NULL
? Try print(seurat_obj@misc$active_wgcna)
. If this is NULL
, you need to re-name it.
Hi there, thanks so much for your help. Yep, that indeed is the output of the function print(seurat_obj@misc$active_wgcna)
, I get NULL
.
This is probably a very basic question, but how exactly do I rename it?
I previously didn't realize it had been set to NULL
because running CheckWGCNAName()
returns this error:
Error in CheckWGCNAName() :
argument "wgcna_name" is missing, with no default
As shown in the tutorial, at the very beginning of the hdWGCNA pipeline you run SetupForWGCNA
, and in this function you specify the wgcna_name
.
I am not sure what you used for wgcna_name
, but for example in the tutorial we used wgcna_name = "tutorial"
. In this example, you could do this:
seurat_obj <- SetActiveWGCNA(seurat_obj, "tutorial")
# this should now say "tutorial"
print(seurat_obj@misc$active_wgcna)
I hope that this helps you fix your problem. But I am confused how or why this was set to NULL
in the first place...
Thanks for your help. It did let me set the name to something else, but afterwards I tried to run Enrichr according to the code in the tutorial and I was met with this error:
> seurat_obj <- RunEnrichr(
+ seurat_obj,
+ dbs=dbs, # character vector of enrichr databases to test
+ max_genes = 100 # number of genes per module to test. use max_genes = Inf to choose all genes!
+ )
Error in RunEnrichr(seurat_obj, dbs = dbs, max_genes = 100) :
object 'module' not found
Adding more arguments, including the wgcna_name
, returned this error:
> RunEnrichr(seurat_obj, dbs=dbs, max_genes = 100, wait = TRUE, wait_time=5, wgcna_name = Trem2AD.combined)
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
I checked and the Seurat object doesn't appear to have any issues, as mentioned previously running other hdWGCNA commands other than EnrichR work fine.
Oh, and as for dbs
potentially requiring vector arguments, I had already set dbs
to my preferred databases, and verified that it works:
> dbs
[1] "GO_Molecular_Function_2023"
[2] "GO_Molecular_Component_2023"
[3] "Kinase_Perturbations_from_GEO_up"
[4] "Rummagene_kinases"
Other than the dbs
argument I can't manage to figure out what else would require vector arguments which isn't already specified...
Are you sure that you are using the correct wgcna_name
which you used previously?
Yes, and I tried it several times as well. Even when reloading the seurat_object
and renaming it from the beginning it brings up the Error in RunEnrichr(seurat_obj, dbs = dbs, max_genes = 100) : object 'module' not found
I am not sure how this happened but it seems like this wgcna_name
does not have any modules, which means that you have probably not run ConstructNetwork
.
GetModules(seurat_obj, wgcna_name)
Does this show you NULL
?
Please ensure that you have run the main steps of hdWGCNA as outlined in the tutorial.
I re-loaded all libraries according to the tutorial and ran SetupForWGCNA
, renaming the WGCNA name as we discussed previously, however I got this error once more:
> GetModules(seurat_obj, Trem2AD.combined)
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
The exact code that I ran, with outputs, is below:
library(hdWGCNA)
> # single-cell analysis package
> library(Seurat)
>
> # plotting and data science packages
> library(tidyverse)
> library(cowplot)
> library(patchwork)
>
> # co-expression network analysis packages:
> library(WGCNA)
> library(hdWGCNA)
>
> # using the cowplot theme for ggplot
> theme_set(theme_cowplot())
>
> # set random seed for reproducibility
> set.seed(12345)
>
> # optionally enable multithreading
> enableWGCNAThreads(nThreads = 8)
Warning in allowWGCNAThreads: Requested number of threads is higher than number of available processors (or cores). Using too many threads may degrade code performance. It is recommended that the number of threads is no more than number
of available processors.
Allowing parallel execution with up to 8 working processes.
>
> # load the dataset
> seurat_obj <- readRDS("/Users/cinnamonsoup/Trem2AD.combined.rds")
> seurat_obj <- SetupForWGCNA(seurat_obj, 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 = "Trem2AD.combined" # the name of the hdWGCNA experiment
)
> GetModules(seurat_obj, Trem2AD.combined)
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
Reading your comment, I realized that I had no idea I had to go through the entire hdWGCNA tutorial before running EnrichR analysis, as you can see from the code above I figured for some reason that just running SetupforWGCNA
was sufficient.
I figured it was an obvious error.. turns out it was, lol.
I went back and ran the entire hdWGCNA tutorial from the beginning before running EnrichR and it worked; I was able to get outputs of GO analysis for all modules.
Thanks so much for taking the time to reply!
Recurring unsolvable issue
This is an issue that I've tried for over three days to resolve unsuccessfully so I'm hoping someone with more experience with this can help me out!
Basically, when running EnrichR with hdWGCNA (following the basic code in the tutorial here), when trying function
RunEnrichr
I always get the same output:Error in if (!check) { : argument is of length zero
. Using thetraceback()
function reveals that the error occurs inCheckWGCNAName(seurat_obj, wgcna_name)
, which I know has supposedly been fixed as of a short time ago.Knowing this, I have performed the below steps with no success:
I'm copying the most recent attempt with this code below:
The original code from the tutorial is as below:
Up until here, there is no issue. Then, replacing my own .rds file with the data in the final input, I continue with this input and receive the error:
The next part of the code I tried to run anyways with no success, either. I receive the same message.
I am also aware that a similar issue has recently been solved in the newest release but no matter how many times I attempt a reinstall the issue is not solvable with the extent of my knowledge! As a side note, I was able to analyze the same Seurat object with just hdWGCNA, without running EnrichR.
Thanks in advance for any help you can offer, much appreciated!