thanks for the reply Kevin. Small question about module trait relationship.
# Set the minimum module size
minModuleSize = 50;
# Module identification using dynamic tree cut
dynamicMods = cutreeDynamic(dendro = geneTree, method="tree", minClusterSize = minModuleSize);
#the following command gives the module labels and the size of each module. Lable 0 is reserved for unassigned genes
table(dynamicMods)
# dynamicMods
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# 3714 7155 6200 1315 1001 999 855 829 641 417 366 362 325 295 245 209 206 175 76
#Plot the module assignment under the dendrogram; note: The grey color is reserved for unassigned genes
dynamicColors = labels2colors(dynamicMods)
table(dynamicColors)
# dynamicColors
# black blue brown cyan green greenyellow grey grey60
# 829 6200 1315 245 999 362 3714 175
# lightcyan lightgreen magenta midnightblue pink purple red salmon
# 206 76 417 209 641 366 855 295
# tan turquoise yellow
# 325 7155 1001
And then merged the modules like below:
MEList = moduleEigengenes(datExpr, colors = dynamicColors)
MEs = MEList$eigengenes
# Calculate dissimilarity of module eigengenes
MEDiss = 1-cor(MEs);
library(flashClust)
# Cluster module eigengenes
METree = flashClust(as.dist(MEDiss), method = "average");
# Plot the result
sizeGrWindow(7, 6)
plot(METree, main = "Clustering of module eigengenes", xlab = "", sub = "")
MEDissThres = 0.2
# Plot the cut line into the dendrogram
abline(h=MEDissThres, col = "red")
dev.off()
# Call an automatic merging function
merge = mergeCloseModules(datExpr,
dynamicColors, cutHeight = MEDissThres, verbose = 3)
# The merged module colors
mergedColors = merge$colors;
# Eigengenes of the new merged modules:
mergedMEs = merge$newMEs;
# Numeric module labels
moduleLabels = merge$colors
# Convert labels to colors
moduleColors = labels2colors(moduleLabels)
#Relating modules to external clinical traits
#Compute 1st principal componet of each module as its eigengenes.
#Correlate eigengene external traits and look for the most significant associations.
#Define numbers of genes and samples
nGenes = ncol(datExpr);
nSamples = nrow(datExpr);
#calculate eigengenes (1st principal component) of modules
MEs0 = moduleEigengenes(datExpr, ?)$eigengenes
1) Now I wanted to create a heatmap with correlation values modules and trait information. Have some doubt whether here MEs0 = moduleEigengenes(datExpr, ?)$eigengenes I have to use dynamicColors which is before merging or moduleColors after merging.
2) there are few modules like turquoise and blue with more than 7000 and 6000 genes. The number is huge. How do I reduce the number?

