Eigen genes using WGCNA
2
3
Entering edit mode
5.6 years ago

Hi

I am using WGCNA to calculate eigen genes using tutorial https://horvath.genetics.ucla.edu/html/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/FemaleLiver-02-networkConstr-man.pdf I just want to check or list out name of eigen gene in each module, but I could not. Can anyone suggest?

Regards

wgcna eigengenes • 5.5k views
ADD COMMENT
1
Entering edit mode

Paste what you have tried; otherwise, nobody will respond.

ADD REPLY
0
Entering edit mode

Agree with Kevin's point.

you can try with this code to extract modules..

Extract modules

module_colors= setdiff(unique(dynamicColors), "grey")
for (color in module_colors){
    module=SubGeneNames[which(dynamicColors==color)]
    write.table(module, paste("module_",color, ".txt",sep=""), sep="\t", row.names=FALSE, col.names=FALSE,quote=FALSE)

}
ADD REPLY
0
Entering edit mode
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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

This script will give you name of genes in each module

ADD REPLY
0
Entering edit mode

Ya MiKe you are right But I want to also know the name of eigengene in each module.

Regards

ADD REPLY
0
Entering edit mode

Hello

Can anyone tell how to print out the ME (module eigengenes) while using WGCNA?

Regards Shivangi

ADD REPLY
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Ok,I am sorry Kevin. But, it is not the other question, it is the same question.

With regards

ADD REPLY
0
Entering edit mode

Please use ADD REPLY/ADD COMMENT when responding to existing posts to keep threads logically organized. Do not use SUBMIT ANSWER to add comments.

ADD REPLY
0
Entering edit mode

OK genomax, thanks for the information. Actually, I am new to it.. Anyway, thanks

With regards

ADD REPLY
0
Entering edit mode
5.6 years ago

I have looked up previous WGCNA code that I used and you should be able to produce the gene-to-eigengene colour assignments via:

data.frame(colnames(datExpr), mergedColors)

Kevin

ADD COMMENT
0
Entering edit mode

Thanks Kevin for your reply. When I used the code as mentioned by you,

 data.frame(colnames(datExpr), mergedColors)

it gave me like,

 colnames.datExpr. mergedColors
1                1-Dec         grey
2                1-Mar         grey
3               12-Sep         grey
4                4-Sep         grey
5                 A1BG         grey
6                  A2M         blue
7                 AACS         grey
8                AADAC         grey
9              AADACL2         grey
10             AADACL3       purple
11             AADACL4         grey
12                AASS         grey
13            AB074188         grey
14            AB209061          red

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.

Thanks in advance.

ADD REPLY
1
Entering edit mode
ADD REPLY
0
Entering edit mode

...but, black is just MEblack, grey is MEgrey, et cetera.

An eigen-gene is an abstraction of a gene - the eigen-gene values are unit-less and are derived via PCA.

Conversely, a module is an abstraction of an eigenvector.

ADD REPLY
0
Entering edit mode

Hi Kevin, I have a small question about WGCNA, could you please give me some advice? the post are at: Different result from WGCNA tutorial I.

ADD REPLY
0
Entering edit mode
10 months ago
chaco001 ▴ 40

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1851 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6