How to improve this WGCNA analysis
0
0
Entering edit mode
9 weeks ago
das2000sidd ▴ 30

Hi, 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: https://imgur.com/a/XVxYPQk 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)

microarray WGCNA • 194 views
0
Entering edit mode

the cutHeight argument in mergeCloseModules() expect a dissimilarity value:

Maximum dissimilarity (i.e., 1-correlation) that qualifies modules for merging.

dynamic_MEDissThres <- 0.95 corresponds to a correlation of 0.05, to merge. This doesn't make any sense.