Question: WGCNA: Error in plot.window(...) : need finite 'ylim' values
0
ashish270 wrote:

I am trying to learn WGCNA through this tutorial. During the network construction step I am getting this error `Error in plot.window(...) : need finite 'ylim' values` I have not modified the code, just copy pasted it. there are many other such questions on google but most of them says you need to remove NA's. when I type `ylim` it gives me this

``````NA   NA   NA  33.92194
NA   NA   NA 202.30723
``````

it is all NAs, I am also using the example data provided in the tutorial. Here is the block of code which gives the error

``````# Choose a set of soft-thresholding powers
powers = c(seq(4,10,by=1), seq(12,20, by=2));
# Initialize a list to hold the results of scale-free analysis
powerTables = vector(mode = "list", length = nSets);
# Call the network topology analysis function for each set in turn
for (set in 1:nSets)
powerTables[[set]] = list(data = pickSoftThreshold(multiExpr[[set]]\$data, powerVector=powers,
verbose = 2)[]);
collectGarbage();
# Plot the results:
colors = c("black", "red")

# Will plot these columns of the returned scale free analysis tables
plotCols = c(2,5,6,7)
colNames = c("Scale Free Topology Model Fit", "Mean connectivity", "Median connectivity",
"Max connectivity");
# Get the minima and maxima of the plotted points
ylim = matrix(NA, nrow = 2, ncol = 4);
for (set in 1:nSets)
{
for (col in 1:length(plotCols))
2
{
ylim[1, col] = min(ylim[1, col], powerTables[[set]]\$data[, plotCols[col]], na.rm = TRUE);
ylim[2, col] = max(ylim[2, col], powerTables[[set]]\$data[, plotCols[col]], na.rm = TRUE);
}
}
# Plot the quantities in the chosen columns vs. the soft thresholding power
sizeGrWindow(8, 6)
#pdf(file = "Plots/scaleFreeAnalysis.pdf", wi = 8, he = 6)
par(mfcol = c(2,2));
par(mar = c(4.2, 4.2 , 2.2, 0.5))
cex1 = 0.7;
for (col in 1:length(plotCols)) for (set in 1:nSets)
{
if (set==1)
{
plot(powerTables[[set]]\$data[,1], -sign(powerTables[[set]]\$data[,3])*powerTables[[set]]\$data[,2],
xlab="Soft Threshold (power)",ylab=colNames[col],type="n", ylim = ylim[, col],
main = colNames[col]);
}
if (col==1)
{
text(powerTables[[set]]\$data[,1], -sign(powerTables[[set]]\$data[,3])*powerTables[[set]]\$data[,2],
labels=powers,cex=cex1,col=colors[set]);
} else
text(powerTables[[set]]\$data[,1], powerTables[[set]]\$data[,plotCols[col]],
labels=powers,cex=cex1,col=colors[set]);
if (col==1)
{
legend("bottomright", legend = setLabels, col = colors, pch = 20) ;
} else
legend("topright", legend = setLabels, col = colors, pch = 20) ;
}
dev.off();
``````

I would really appreciate if someone can clarify what is wrong here. Thanks

wgcna R • 741 views
modified 7 months ago by Kevin Blighe53k • written 7 months ago by ashish270

How did you produce the `multiExpr` object?

In part one of the tutorial the authors created multiExpr object like this

``````# We work with two sets:
nSets = 2;
# For easier labeling of plots, create a vector holding descriptive names of the two sets.
setLabels = c("Female liver", "Male liver")
shortLabels = c("Female", "Male")
# Form multi-set expression data: columns starting from 9 contain actual expression data.
multiExpr = vector(mode = "list", length = nSets)
multiExpr[] = list(data = as.data.frame(t(femData[-c(1:8)])));
names(multiExpr[]\$data) = femData\$substanceBXH;
rownames(multiExpr[]\$data) = names(femData)[-c(1:8)];
multiExpr[] = list(data = as.data.frame(t(maleData[-c(1:8)])));
names(multiExpr[]\$data) = maleData\$substanceBXH;
rownames(multiExpr[]\$data) = names(maleData)[-c(1:8)];
# Check that the data has the correct format for many functions operating on multiple sets:
exprSize = checkSets(multiExpr)
``````
0
Kevin Blighe53k wrote:

Following the tutorial exactly in this order, you should not have any error messages (I just did it now): Kevin

I am following it exactly as it is, just copying and pasting all the code. I even tried it on just R instead on Rstudio. How come I am not able to do it.

Check that every command has completed successfully. Also, update your version of WGCNA. I used the following package version to complete the tutorial:

• WGCNA_1.68
• fastcluster_1.1.25
• dynamicTreeCut_1.63-1
1

Thanks for your time Kevin. I updated every package I have but still it gives me the same error. However I found the solution. The error only comes when I copy the code from the pdf but it works totally fine when I copy it from the Rscript.