<p>I took a quick look and don't see anything wrong with the module merging. You could lower the merging threshold a bit - 0.95 is very high, I would use 0.9 or 0.85. Other than that though, really nothing seems out of the ordinary.</p>

CC BY-SA 4.0
2022-09-30T08:16:28.000Z
Hi Peter, Sorry for the late reply but thank you again for your feedback. :)
siddhartha das
CC BY-SA 4.0
2022-09-27T14:07:31.997Z
2022-09-27T14:07:31.997Z
Peter Langfelder
<p>This is my first time working on using WGCNA on a microarray dataset. One of the major problems I am facing is merging close modules which is not really working well. I have quantile normalised the data before working on it. I have put my code below and link to some of the plots generated during this process. I was wondering can somebody advice on what could be improved upon in this analysis?
Link to plots: ![plots] <a href="https://i.sstatic.net/dF6NA.jpg" rel="nofollow noreferrer">https://i.sstatic.net/dF6NA.jpg</a>
I have a total of 767 samples and 13466 probes.</p>
<pre><code>powers = c(c(1:10))
## Scale free topology since it can find hubs
sft = pickSoftThreshold(bryois_norm_keep_use, powerVector = powers, verbose = 5)
par(mfrow = c(1,2));
cex1 = 0.9;
plot(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],
xlab=&quot;Soft Threshold (power)&quot;,ylab=&quot;Scale Free Topology Model Fit,signed R^2&quot;,type=&quot;n&quot;,
main = paste(&quot;Scale independence&quot;));
text(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],
labels=powers,cex=cex1,col=&quot;red&quot;);
abline(h=0.90,col=&quot;red&quot;)
# Mean connectivity as a function of the soft-thresholding power
plot(sft$fitIndices[,1], sft$fitIndices[,5],
xlab=&quot;Soft Threshold (power)&quot;,ylab=&quot;Mean Connectivity&quot;, type=&quot;n&quot;,
main = paste(&quot;Mean connectivity&quot;))
text(sft$fitIndices[,1], sft$fitIndices[,5], labels=powers, cex=cex1,col=&quot;red&quot;)
# Turn data expression into topological overlap matrix
power=sft$powerEstimate
# Even though estimate suggests 3, trying ahigh number
# Turn adjacency into topological overlap matrix (TOM)
adjacency &lt;- adjacency(bryois_norm_keep_use, power = 6)
TOMadj &lt;- TOMsimilarity(adjacency,verbose = 5)
dissTOMadj &lt;- 1- TOMadj
# Clustering using TOM
# Call the hierarchical clustering function
hclustGeneTree &lt;- hclust(as.dist(dissTOMadj), method = &quot;average&quot;)
# Plot the resulting clustering tree (dendogram)
sizeGrWindow(12, 9)
plot(hclustGeneTree, xlab = &quot;&quot;, sub = &quot;&quot;,
main = &quot;Gene Clustering on TOM-based disssimilarity&quot;,
labels = FALSE, hang = 0.04)
# Make the modules larger, so set the minimum higher
minModuleSize &lt;- 30
# Module ID using dynamic tree cut
dynamicMods &lt;- cutreeDynamic(dendro = hclustGeneTree,
distM = dissTOMadj,
deepSplit = 2, pamRespectsDendro = FALSE,
minClusterSize = minModuleSize,verbose = 5)
table(dynamicMods)
# Convert numeric lables into colors
dynamicColors &lt;- labels2colors(dynamicMods)
table(dynamicColors)
# Plot the dendrogram and colors underneath
sizeGrWindow(8,6)
plotDendroAndColors(hclustGeneTree, dynamicColors, &quot;Dynamic Tree Cut&quot;,
dendroLabels = FALSE, hang = 0.03,
addGuide = TRUE, guideHang = 0.05,
main = &quot;Gene dendrogram and module colors&quot;)
# Calculate eigengenes
dynamic_MEList &lt;- moduleEigengenes(bryois_norm_keep_use, colors = dynamicColors)
dynamic_MEs &lt;- dynamic_MEList$eigengenes
library(dynamicTreeCut)
# Calculate dissimilarity of module eigengenes
dynamic_MEDiss &lt;- 1-cor(dynamic_MEs)
dynamic_METree &lt;- hclust(as.dist(dynamic_MEDiss))
# Plot the hclust
sizeGrWindow(7,6)
plot(dynamic_METree, main = &quot;Dynamic Clustering of module eigengenes&quot;,
xlab = &quot;&quot;, sub = &quot;&quot;)
######################## MERGE SIMILAR MODULES
dynamic_MEDissThres &lt;- 0.95
# Plot the cut line
#abline(h = dynamic_MEDissThres, col = &quot;red&quot;)
# Call an automatic merging function
merge_dynamic_MEDs &lt;- mergeCloseModules(bryois_norm_keep_use, dynamicColors, cutHeight = dynamic_MEDissThres, verbose = 5)
# The Merged Colors
dynamic_mergedColors &lt;- merge_dynamic_MEDs$colors
# Eigen genes of the new merged modules
mergedMEs &lt;- merge_dynamic_MEDs$newMEs
mergedMEs
table(dynamic_mergedColors)
sizeGrWindow(12,9)
plotDendroAndColors(hclustGeneTree, cbind(dynamicColors, dynamic_mergedColors),
c(&quot;Dynamic Tree Cut&quot;, &quot;Merged dynamic&quot;),
dendroLabels = FALSE, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)
</code></pre>

<wgcna>
How to improve this WGCNA analysis
# How to improve this WGCNA analysis

(Asked by: username_0 on 2022-09-27)

This is my first time working on using WGCNA on a microarray dataset. One of the major problems I am facing is merging close modules which is not really working well. I have quantile normalised the data before working on it. I have put my code below and link to some of the plots generated during this process. I was wondering can somebody advice on what could be improved upon in this analysis?
Link to plots: ![plots] https://i.sstatic.net/dF6NA.jpg
I have a total of 767 samples and 13466 probes.
powers = c(c(1:10))
## Scale free topology since it can find hubs
sft = pickSoftThreshold(bryois_norm_keep_use, powerVector = powers, verbose = 5)
par(mfrow = c(1,2));
cex1 = 0.9;
plot(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],
xlab="Soft Threshold (power)",ylab="Scale Free Topology Model Fit,signed R^2",type="n",
main = paste("Scale independence"));
text(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],
labels=powers,cex=cex1,col="red");
abline(h=0.90,col="red")
# Mean connectivity as a function of the soft-thresholding power
plot(sft$fitIndices[,1], sft$fitIndices[,5],
xlab="Soft Threshold (power)",ylab="Mean Connectivity", type="n",
main = paste("Mean connectivity"))
text(sft$fitIndices[,1], sft$fitIndices[,5], labels=powers, cex=cex1,col="red")
# Turn data expression into topological overlap matrix
power=sft$powerEstimate
# Even though estimate suggests 3, trying ahigh number
# Turn adjacency into topological overlap matrix (TOM)
adjacency <- adjacency(bryois_norm_keep_use, power = 6)
TOMadj <- TOMsimilarity(adjacency,verbose = 5)
dissTOMadj <- 1- TOMadj
# Clustering using TOM
# Call the hierarchical clustering function
hclustGeneTree <- hclust(as.dist(dissTOMadj), method = "average")
# Plot the resulting clustering tree (dendogram)
sizeGrWindow(12, 9)
plot(hclustGeneTree, xlab = "", sub = "",
main = "Gene Clustering on TOM-based disssimilarity",
labels = FALSE, hang = 0.04)
# Make the modules larger, so set the minimum higher
minModuleSize <- 30
# Module ID using dynamic tree cut
dynamicMods <- cutreeDynamic(dendro = hclustGeneTree,
distM = dissTOMadj,
deepSplit = 2, pamRespectsDendro = FALSE,
minClusterSize = minModuleSize,verbose = 5)
table(dynamicMods)
# Convert numeric lables into colors
dynamicColors <- labels2colors(dynamicMods)
table(dynamicColors)
# Plot the dendrogram and colors underneath
sizeGrWindow(8,6)
plotDendroAndColors(hclustGeneTree, dynamicColors, "Dynamic Tree Cut",
dendroLabels = FALSE, hang = 0.03,
addGuide = TRUE, guideHang = 0.05,
main = "Gene dendrogram and module colors")
# Calculate eigengenes
dynamic_MEList <- moduleEigengenes(bryois_norm_keep_use, colors = dynamicColors)
dynamic_MEs <- dynamic_MEList$eigengenes
library(dynamicTreeCut)
# Calculate dissimilarity of module eigengenes
dynamic_MEDiss <- 1-cor(dynamic_MEs)
dynamic_METree <- hclust(as.dist(dynamic_MEDiss))
# Plot the hclust
sizeGrWindow(7,6)
plot(dynamic_METree, main = "Dynamic Clustering of module eigengenes",
xlab = "", sub = "")
######################## MERGE SIMILAR MODULES
dynamic_MEDissThres <- 0.95
# Plot the cut line
#abline(h = dynamic_MEDissThres, col = "red")
# Call an automatic merging function
merge_dynamic_MEDs <- mergeCloseModules(bryois_norm_keep_use, dynamicColors, cutHeight = dynamic_MEDissThres, verbose = 5)
# The Merged Colors
dynamic_mergedColors <- merge_dynamic_MEDs$colors
# Eigen genes of the new merged modules
mergedMEs <- merge_dynamic_MEDs$newMEs
mergedMEs
table(dynamic_mergedColors)
sizeGrWindow(12,9)
plotDendroAndColors(hclustGeneTree, cbind(dynamicColors, dynamic_mergedColors),
c("Dynamic Tree Cut", "Merged dynamic"),
dendroLabels = FALSE, hang = 0.03,
addGuide = TRUE, guideHang = 0.05)

**Tags:** wgcna

---

## 1 answers

### Answer by username_1 on 2022-09-27. Score: 3

I took a quick look and don't see anything wrong with the module merging. You could lower the merging threshold a bit - 0.95 is very high, I would use 0.9 or 0.85. Other than that though, really nothing seems out of the ordinary.

> **Comments:**
> **username_0**: Hi Peter, Sorry for the late reply but thank you again for your feedback. :)  

---

