Closed iamakhilverma closed 9 months ago
Can you please describe the deviation from expected behavior that you are observing? I just tried to do this with the tutorial dataset and it worked just fine.
Can you please describe the deviation from expected behavior that you are observing? I just tried to do this with the tutorial dataset and it worked just fine.
My code was:
seurat_obj <- ResetModuleNames(
seurat_obj.wgcna,
new_name = rename_list
)
# print out the new module names
modules <- GetModules(seurat_obj)
print(levels(modules$module))
I wanted it to not only rename the modules that we get using GetModules()
function but also rename the module names present as column names in seurat object's metadata. I had to do that part manually which we can easily add to the source code.
I am sorry but I still don't understand what you are expecting versus what you are observing. I am not sure what you mean by "WGCNA object"?
Could you please provide a reproducible example?
I am sorry but I still don't understand what you are expecting versus what you are observing. I am not sure what you mean by "WGCNA object"?
Could you please provide a reproducible example?
I meant Seurat object with hdWGCNA run information (I've modified my comment above).
For example, you identified four modules, say blue
, cyan
, red
, and black
using hdWGCNA
. Now, you want to rename them to EMT
, Cell_Cycle
, OxPhos
, and Hypoxia
. You create a rename list as follows:
rename_list <- list(
"blue" = "EMT",
"cyan" = "Cell_Cycle",
"red" = "OxPhos",
"black" = "Hypoxia"
)
seurat_obj <- ResetModuleNames(
seurat_obj.wgcna,
new_name = rename_list
)
# print out the new module names
modules <- GetModules(seurat_obj)
print(levels(modules$module))
and get output:
[1] "EMT" "grey"
[3] "Cell_Cycle" "OxPhos"
[5] "Hypoxia"
This is as expected but when you ask for colnames(seurat_obj@meta.data)
, you don't see EMT
, Cell_Cycle
, OxPhos
, and Hypoxia
but it has blue
, cyan
, red
, and black
. Also, in the wgcna_modules_r_max
column, you still see old module names which is the deviation from what we want, i.e., the new module names.
The following code fixes the issue that I mentioned:
data.table::setnames(
seurat_obj@meta.data,
old = as.character(names(rename_list)),
new = as.character(rename_list)
)
df <- seurat_obj@meta.data[as.character(rename_list)]
seurat_obj <- AddMetaData(
object = seurat_obj,
metadata = colnames(df)[max.col(df, ties.method="first")],
col.name = 'wgcna_renamedModules_r_max'
)
Based on this code that you provide it looks like you are interested in changing the Seurat object meta data, and I think if you are having an issue or error regarding this then it's ultimately a problem with Seurat rather than with hdWGCNA. To clarify, hdWGCNA itself does not use the Seurat meta data to store any information about the modules.
Based on this code that you provide it looks like you are interested in changing the Seurat object meta data, and I think if you are having an issue or error regarding this then it's ultimately a problem with Seurat rather than with hdWGCNA. To clarify, hdWGCNA itself does not use the Seurat meta data to store any information about the modules.
Correct me if I'm wrong, but doesn't it run AddModuleScore
for each identified module which in turn modifies the seurat object's metadata?
I am not sure what code that you ran, so I am not sure? Typically with GitHub issues I need to know the relevant details in order to identify and resolve your issue, which is why a reproducible example would be very helpful.
One of the commands in hdWGCNA
tutorial runs AddModuleScore
(PFA the screenshot showing that part of output), not sure which one was it because I ran it a few months ago but when I noticed the same issue when my labmate ran hdWGCNA
pipeline, I opened this issue. I understand a reproducible example is more helpful, if this doesn't help, let me know and I'll try to create one more like the one I created above.
I think that this information about module scores or module eigengenes is optionally added to the Seurat object metadata by the user for some suggested plotting in the tutorial, but to be clear the hdWGCNA functions do not directly add this information to the Seurat object metadata. For this reason, the ResetModuleNames function does not change any of the information in the Seurat metadata.
This doesn't work as described in the Module customization tutorial. Something seems to be broken with
ResetModuleNames
. I've tried it with multipleseurat objects
from differenthdWGCNA
runs.R session info