smorabit / hdWGCNA

High dimensional weighted gene co-expression network analysis
https://smorabit.github.io/hdWGCNA/
Other
316 stars 31 forks source link

Error in blockwiseIndividualTOMs #111

Closed yt723 closed 1 year ago

yt723 commented 1 year ago

Hello,

I can't solve the error below. Can you suggest what I should try to troubleshoot? Thank you so much.

Error in blockwiseIndividualTOMs(multiExpr = multiExpr, checkMissingData = checkMissingData, : Standard deviation of some genes is zero.

smorabit commented 1 year ago

Hi,

Could you please provide a bit more information in order for me to help you? Can you send all of the hdWGCNA code that you used? More information about your dataset could also help.

yt723 commented 1 year ago

Hello,

I'm running the ConstructNetwork function below and facing the problem. My samples are PBMC and data was obtained by scRNAseq+CITEseq (BD Rhapsody). I integrated data from different libraries using Seurat's CCA method. After obtaining major cell types (such as B cells, CD8T cells, NK cells etc.), I did targeted clustering. Then I'm running WGNCA for those major cell types with seurat_clusters. The codes I'm using are working for most of the cell types, but I can't analyze one of the cell types because of the error message.

My codes: CD4Tm <- ConstructNetwork( CD4Tm, soft_power = 3, setDatExpr = FALSE, deepSplit = 2, overwrite_tom = TRUE, TOMType = 'unsigned', minModuleSize = 10, mergeCutHeight = 0.1, tom_name = 'CAV' )

Response: Calculating consensus modules and module eigengenes block-wise from all genes Calculating topological overlaps block-wise from all genes Flagging genes and samples with too many missing values... ..step 1 TOM calculation: adjacency.. ..will not use multithreading. Fraction of slow calculations: 0.804846 TOM: exit because 'adjacency' reported an error. Error in blockwiseIndividualTOMs(multiExpr = multiExpr, checkMissingData = checkMissingData, : Standard deviation of some genes is zero.


Default assay is set for integrated RNA. I chose genes by 'variable' for SetupForWGCNA. There are 477 genes selected. When I encountered the same issue, I changed 'max_shared' value in the MetacellsByGroups function and that sometimes solved the problem. But for the cell type above, it didn't work. I also tried to change SetupForWGCNA parameter from 'variable' to 'fraction', but this didn't work because of the error message (below).

CD4Tm <- SetupForWGCNA(CD4Tm, gene_select = "fraction", fraction=0.05, wgcna_name = 'wgcna_CAV') Error in cut.default(1:nrow(expr_mat), n_chunks) : invalid number of intervals

What else should I try? Thank you so much for your help.

Yuko

smorabit commented 1 year ago

Can you also show the code that you ran before ConstructNetwork?

Default assay is set for integrated RNA. I chose genes by 'variable' for SetupForWGCNA. There are 477 genes selected.

This seems like a very low number of genes, not sure if this is causing this particular issue but usually there are a few thousand genes included for network analysis. I actually have not tried running hdWGCNA with this few genes.

yt723 commented 1 year ago

Hello,

We did targeted RNA sequencing and the number of genes included was less than 500. I have other seurat objects from the same experiment (same genes) and WGCNA worked for them. Only a few seurat objects are causing errors. The codes I ran before ConstructNetwork are below.

DefaultAssay(CD4Tm) <- 'integrated' CD4Tm <- SetupForWGCNA(CD4Tm, gene_select = 'variable', wgcna_name = 'wgcna_CAV') CD4Tm <- MetacellsByGroups( seurat_obj = CD4Tm, group.by = c("seurat_clusters", "SampleType"), k=25, max_shared = 10, assay = 'integrated', slot = 'data', ident.group = 'SampleType') CD4Tm <- NormalizeMetacells(CD4Tm) CD4Tm <- SetDatExpr(CD4Tm, group_name = "CAV", group.by = 'SampleType', assay = 'integrated', slot = 'data')

Thank you so much.

Yuko

smorabit commented 1 year ago

How many cells are there in the group that is giving you this error message?

Looking at your error message:

Error in blockwiseIndividualTOMs(multiExpr = multiExpr, checkMissingData = checkMissingData, : Standard deviation of some genes is zero.

I think that there's something wrong with the some of genes that you're using as input. However I am somewhat confused because SetDatExpr is supposed to look for genes with zero variance and remove them from the analysis. Maybe try selecting genes a different way. Unfortunately it is very difficult for me to figure out what's causing the error without a reproducible example on a dataset that I have access to.

yt723 commented 1 year ago

There are 12091 cells.

Standard deviation of none of the genes was zero (minimum was 2.9e-6). I set up the genes manually, and it worked. I tested multiple std thresholds for selecting genes and eventually I selected genes with std >1e-2 (400/477 genes were selected).
I'm ok with the results. Thank you so much for your advice.

Yuko