mydata = read.csv("data.csv", sep = "\t");
datExpr0 = as.data.frame(t(mydata[, -c(1)]));
rownames(datExpr0) = names(mydata)[-c(1)];
sampleTree = hclust(dist(datExpr0), method = "average");
table(clust)
traitData = read.csv("trait2.csv");
allTraits = traitData[,];
femaleSamples = rownames(datExpr);
traitRows = match(femaleSamples, allTraits$CaseID);
datTraits = allTraits[traitRows,-1];
rownames(datTraits) = allTraits[traitRows,1];
# Re-cluster samples
sampleTree2 = hclust(dist(datExpr), method = "average")
# Convert traits to a color representation: white means low, red means high, grey means missing entry
traitColors = numbers2colors(datTraits, signed = FALSE);
# Choose a set of soft-thresholding powers
powers = c(c(1:10), seq(from = 12, to=20, by=2))
sft = pickSoftThreshold(datExpr, powerVector = powers, verbose = 5)
# Plot the results:
sizeGrWindow(9, 5)
par(mfrow = c(1,2));
cex1 = 0.9;
# Scale-free topology fit index as a function of the soft-thresholding power
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")
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")
softPower = 10;
adjacency = adjacency(datExpr, power = softPower);
TOM = TOMsimilarity(adjacency);
dissTOM = 1-TOM
geneTree = hclust(as.dist(dissTOM), method = "average");
minModuleSize = 30;
dynamicMods = cutreeDynamic(dendro = geneTree, distM = dissTOM,
deepSplit = 2, pamRespectsDendro = FALSE,
minClusterSize = minModuleSize);
table(dynamicMods)
dynamicColors = labels2colors(dynamicMods)
table(dynamicColors)
# Calculate eigengenes
MEList = moduleEigengenes(datExpr, colors = dynamicColors)
MEs = MEList$eigengenes
MEDiss = 1-cor(MEs);
METree = hclust(as.dist(MEDiss), method = "average");
MEDissThres = 0.25
# Plot the cut line into the dendrogram
abline(h=MEDissThres, col = "red")
# 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;
moduleColors = mergedColors
colorOrder = c("grey", standardColors(50));
moduleLabels = match(moduleColors, colorOrder)-1;
MEList$eigengenes$MEblack
[1] 0.0241169910 -0.0120321545 0.0151839828 -0.0096772173 -0.0406240823 -0.0340541878 -0.0212249015 -0.0236107441
I just want to print name of eigengene in each module, I have tried using MEList, MEs, MEList$eigengenes but could not get the name of gene, when I tried using MEList$eigengenes$MEsblack, it printed result as above. But I want to have name of that eigengene in each module.
I want to extract eigengenes in each module and not modules, I have given all codes I followed and the one I tried for eigengenes extraction, but could not do. Please look into it.
Please don't post another question as an answer. We will get around to it when we have time. We are volunteers here, each with our own full-time job (or jobs) and struggles that we face.
But, I want the name of eigen-gene in each module calculated by WGCNA to merge modules.
Means I want to print the name of ME (module eigen-gene) in each of the module created by WGCNA. I assume that if there are 20 modules, there must be 20 eigen-genes, each from one module. I just want to have them.
I think this is very old, but I think the commenters are misinterpreting your (miswritten) question. Based on the back-and-forth, you aren't asking about the eigengene "name," (because there isn't one), you are wanting to know the "hub gene" for each module, i.e. the gene whose expression across samples correlates most with the module's eigengene.
This can be easily retrieved using chooseTopHubInEachModule, with the same settings you used to generate the WGCNA network.
Paste what you have tried; otherwise, nobody will respond.
Agree with Kevin's point.
you can try with this code to extract modules..
Extract modules
I just want to print name of eigengene in each module, I have tried using MEList, MEs, MEList$eigengenes but could not get the name of gene, when I tried using MEList$eigengenes$MEsblack, it printed result as above. But I want to have name of that eigengene in each module.
Hi Mike
I want to extract eigengenes in each module and not modules, I have given all codes I followed and the one I tried for eigengenes extraction, but could not do. Please look into it.
Thanks in advance
This script will give you name of genes in each module
Ya MiKe you are right But I want to also know the name of eigengene in each module.
Regards
Hello
Can anyone tell how to print out the ME (module eigengenes) while using WGCNA?
Regards Shivangi
Please don't post another question as an answer. We will get around to it when we have time. We are volunteers here, each with our own full-time job (or jobs) and struggles that we face.
Ok,I am sorry Kevin. But, it is not the other question, it is the same question.
With regards
Please use
ADD REPLY/ADD COMMENT
when responding to existing posts to keep threads logically organized. Do not useSUBMIT ANSWER
to add comments.OK genomax, thanks for the information. Actually, I am new to it.. Anyway, thanks
With regards