WGCNA network creation error
1
0
Entering edit mode
@akridgerunner-7719
Last seen 5.9 years ago
United States

Hello, I'm using the following to attempt network creation

# Load the WGCNA package
library(WGCNA)
options(stringsAsFactors = FALSE);
net = blockwiseModules(datExpr, power = 6, networkType = "signed", checkMissingData = TRUE, corType="bicor",
TOMType = "signed", minModuleSize = 30,
reassignThreshold = 0, mergeCutHeight = 0.05,
numericLabels = TRUE,
pamStage = TRUE, pamRespectsDendro = FALSE,
saveTOMs = TRUE,
saveTOMFileBase = "2-GSE50772_PBMC_TOM",
verbose = 5,
maxBlockSize = 15000)

save(net, file="2-net_output-original.RData")

##########################

Yet after the 3/3 TOM is created I see the following:

Error in fastcluster::hclust(as.dist(dissTom), method=“average” : NaN dissimilarity value.

Any thoughts on this? I have the three TOMs, but recutBlockwiseTrees() requires more than those to generate new modules. I'm guessing complete method instead of average would be better? What new arguments can I pass to overcome this? At this point I'm a bit desperate. Would it help to turn off PAM stage and go back to dynamic from hybrid?

Thanks,

Robert

WGCNA • 3.6k views
0
Entering edit mode

As an update I filtered out a number of probes based on an arbitrarily selected mean low intensity threshold. This removed the "offending probes" and allowed for successful network creation. I'm still curious what Dr. Langfelder might have to say about this, or if we should modify the plugin to handle for these breaks?

0
Entering edit mode
@peter-langfelder-4469
Last seen 3 months ago
United States

I will have to add some more checks into the TOM calculation code. It seems that some probes were giving an NA or NaN in the correlation calculation, which then propagated into the TOM. Such probes are usually automatically flagged and filtered out by blockwiseModules, but the filtering will fail to catch some "pathological" special cases.

Do you have any missing values (NAs) in your data?

0
Entering edit mode

Dear Dr Peter Langfelder I got the same error with akridgerunner, but I can confirm that there is no NAs in my date, I still got the error, can you help me? the following is my codes and error:

> library(WGCNA)
> dim(datExpr)
[1]     7 70523
> datExpr[ is.na(datExpr) ] <- NA
> unique (unlist (lapply (esetnea, function (x) which is.na (x)))))
integer(0)
> par(cex=1.25,cex.axis=1.25,cex.main=1.75,cex.lab=1.25,mfrow=c(2,1),
+ mar=c(2,2,2,1))
> par(mfrow=c(2,1))
> h1=hclust(dist(datExpr),method="average")
Error in hclust(dist(datExpr), method = "average") :
NaN dissimilarity value.
In dist(datExpr) : NAs introduced by coercion
>

0
Entering edit mode

You probably have non-numeric data. Run

datExpr.mat = as.matrix(datExpr)

mode(datExpr)

If you get anything other than "numeric", you don't have numeric data. You will have to investigate what makes your data non-numeric - you may have a character column, or some entries of what you think are numeric columns may not be numeric, forcing the entire column (and the matrix version of datExpr) to be of class 'character'.

HTH,

Peter

0
Entering edit mode

I ran into the same issue as akridgerunner, I have filtered out NA, low expressing genes and genes of low variance for the expression matrix but still got the error of: Error in fastcluster::hclust(as.dist(dissTom), method=“average” : NaN dissimilarity value. The same code works on several other expression matrices generated the same way. Is there any update on what the "pathological" special cases are and how they might be removed?

0
Entering edit mode

Try running adj = adjacency(datExpr) (replace datExpr with whatever object holds your expression data). See if you have any missing or non-finite entries, then investigate the corresponding columns of datExpr.