lnames=load(file="ES-networkConstruction-stepByStep.RData") KMEColors=moduleColors TMEList = moduleEigengenes(datExprT, colors = KMEColors) TMEs = TMEList$eigengenes NMEList = moduleEigengenes(datExprN, colors = KMEColors) NMEs = NMEList$eigengenes nGenes = ncol(datExprT) nSamples = nrow(datExprT) TNames = substring(names(TMEs), 3) TModuleMembership = as.data.frame(cor(datExprT, TMEs, use = "p")) TPvalue = as.data.frame(corPvalueStudent(as.matrix(TModuleMembership), nSamples)) names(TModuleMembership) = paste("T", TNames, sep="") names(TPvalue) = paste("T.MM", TNames, sep="") mGenes = ncol(datExprN) mSamples = nrow(datExprN) NNames = substring(names(NMEs), 3) NModuleMembership = as.data.frame(cor(datExprN, NMEs, use = "p")) NPvalue = as.data.frame(corPvalueStudent(as.matrix(NModuleMembership), mSamples)) names(NModuleMembership) = paste("N", NNames, sep="") names(NPvalue) = paste("N.MM", NNames, sep="") ##########example:royalblue and CK Tmodule="lightyellow" Tcolumn = match(Tmodule, TNames) TmoduleGenes = KMEColors==Tmodule Nmodule="lightyellow" Ncolumn = match(Nmodule, NNames) NmoduleGenes = KMEColors==Nmodule modulecolor="yellow" sizeGrWindow(8, 8) par(mfrow = c(1,1)) verboseScatterplot(abs(TModuleMembership[TmoduleGenes, Tcolumn]), abs(NModuleMembership[NmoduleGenes, Ncolumn]), xlab = paste("kME in", "ES"), ylab = paste("kME in", "RS"), main = paste("lightyellow"), cex.main = 1.7, cex.lab = 1.6, cex.axis = 1.6, col = modulecolor) # Select each module moduleColors=KMEColors for (mod in 1:nrow(table(moduleColors))) { modules = names(table(moduleColors))[mod] # Select module probes probes = names(datExprT) inModule = (moduleColors == modules) modProbes = probes[inModule] modGenes = modProbes # Select the corresponding Topological Overlap modTOM = TOM[inModule, inModule] dimnames(modTOM) = list(modProbes, modProbes) # Export the network into edge and node list files Cytoscape can read cyt = exportNetworkToCytoscape(modTOM, edgeFile = paste("ES_CytoscapeInput-edges-", modules , ".txt", sep=""), nodeFile = paste("ES_CytoscapeInput-nodes-", modules, ".txt", sep=""), weighted = TRUE, threshold = 0.5, nodeNames = modProbes, altNodeNames = modGenes, nodeAttr = moduleColors[inModule]) }