Closed shanshancode closed 5 months ago
Hi, can you please send the hdWGCNA code that you ran prior to these functions? Also I am wondering if you are able to reproduce this error on the tutorial dataset or if this is a problem specific to your dataset?
Hello, sorry for the late reply. regarding to: > Hi, can you please send the hdWGCNA code that you ran prior to these functions? here is the code: DefaultAssay(sc.obj)<-'RNA'
sc.obj <- SetupForWGCNA(
sc.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 = i # the name of the hdWGCNA experiment
)
# construct metacells in each group
sc.obj <- MetacellsByGroups(
seurat_obj = sc.obj,
group.by = c("celltype0", "ttg"), # specify the columns in seurat_obj@meta.data to group by
reduction = 'harmony', # select the dimensionality reduction to perform KNN on
k = 25, # nearest-neighbors parameter
max_shared = 10, # maximum number of shared cells between two metacells
ident.group = 'celltype0' # set the Idents of the metacell seurat object
)
# normalize metacell expression matrix:
sc.obj <- NormalizeMetacells(sc.obj)
sc.obj <- SCTransform(object = sc.obj)
sc.obj <- ScaleMetacells(sc.obj, features=VariableFeatures(sc.obj))
sc.obj <- RunPCAMetacells(sc.obj, features=VariableFeatures(sc.obj))
sc.obj <- RunHarmonyMetacells(sc.obj, group.by.vars='orig.ident')
sc.obj <- RunUMAPMetacells(sc.obj, reduction='harmony', dims=1:15)
sc.obj <- SetDatExpr(
sc.obj,
group_name = "Mesophyll_11", # the name of the group of interest in the group.by column
group.by='celltype0', # the metadata column containing the cell type info. This same column should have also been used in MetacellsByGroups
assay = 'RNA',
slot = 'data' # using normalized data
)
# Test different soft powers:
sc.obj <- TestSoftPowers(
sc.obj,
networkType = 'signed' # you can also use "unsigned" or "signed hybrid"
)
# construct co-expression network:
sc.obj <- ConstructNetwork(
sc.obj,
setDatExpr=FALSE,
overwrite_tom = TRUE,
tom_name = 'Mesophyll_11' # name of the topoligical overlap matrix written to disk
)
#TOM <- GetTOM(sc.A2_5hpi_Col0)
# need to run ScaleData first or else harmony throws an error:
sc.obj <- ScaleData(sc.obj, features=VariableFeatures(sc.obj))
# harmonized module eigengenes:
hMEs <- GetMEs(sc.obj)
# module eigengenes:
MEs <- GetMEs(sc.obj, harmonized=FALSE)
# compute eigengene-based connectivity (kME):
sc.obj <- ModuleConnectivity(
sc.obj,
group.by = 'celltype0', group_name = 'Mesophyll_11'
)
# rename the modules
sc.obj <- ResetModuleNames(
sc.obj,
new_name = "Mesophyll_11-M"
)
# get the module assignment table:
modules <- GetModules(sc.obj)
# show the first 6 columns:
hub_df <- GetHubGenes(sc.obj, n_hubs = 10)
# compute gene scoring for the top 25 hub genes by kME for each module
# with Seurat method
sc.obj <- ModuleExprScore(
sc.obj,
n_genes = 25,
method='Seurat'
)
# compute gene scoring for the top 25 hub genes by kME for each module
# with UCell method
sc.obj <- ModuleExprScore(
sc.obj,
n_genes = 25,
method='UCell'
)
# get hMEs from seurat object
MEs <- GetMEs(sc.obj, harmonized=TRUE)
mods <- colnames(MEs); mods <- mods[mods != 'grey']
# add hMEs to Seurat meta-data:
sc.obj@meta.data <- cbind(sc.obj@meta.data, MEs)
Also I am wondering if you are able to reproduce this error on the tutorial dataset or if this is a problem specific to your dataset? I have not but will try the code with the tutorial dataset.
many thanks, shanshan
It looks like in your code you did not run the ModuleEigengenes
function, which is required before making the network plots.
Hi, thanks for the great package!
here is my issue, when i use
the same error showed up for HubGeneNetworkPlot , RunModuleUMAP...
Steps to reproduce