I have what I imagine is a very simple error regarding the use of WGCNA in R. I am trying to create a weighted correlation network by setting a hard threshold using the function pickHardThreshold
. However, when I pass in my expression set I get a strange error:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'x'
I imagine there is something wrong with my understanding of how to use the function but there seems to be no tutorials or examples where a hard threshold is set (there are many based on soft thresholds, such as here).
I am passing in an expression set matrix with the samples as the rows and the genes as the columns as described in the documentation for the function
expression data in a matrix or data frame. Rows correspond to samples and columns to genes.
Also, there are no NA's in my dataset which was my first check based on the error. Just to give a reproducible example of the error see below:
exp_matrix<-matrix(data=runif(100),ncol=10,
dimnames=list(paste0("sample_",1:10),
paste0("gene_",1:10)))
pickHardThreshold(exp_matrix)
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in 'x'
Any help would be greatly appreciated!
Thanks.
How odd, I have 500 genes and 100 samples so it would be a 100x500 matrix. I've checked on that size and I hit the same issue
Sorry just to add to this, when you increase your example to 100 samples rather than 10 it gives the same error. So it seems its not just down to the number for genes.
If I modify
cutVector
I am able to run the function without errors. So i guess the error happen whenpickHardThreshold
attempt to calculate the scale free topology fit fromscaleFreeFitIndex(k = khelp, nBreaks = nBreaks, removeFirst = removeFirst)
using a vectork
of connectivities which, in your case, seems to beZero
. Funny enough, this does not happen if you use the functionpickSoftThreshold
.I would post the same question on
bioconductor
. WGCNA devs are more active therePerfect, I will do. Thank you very much for all the help!