WGCNA: how to change module color
1
2
Entering edit mode
dcxy18 ▴ 20
@dcxy18-17671
Last seen 5.5 years ago

Hi all,

I am very new in the R world. I followed the UCLA "Step-by-step network construction and module detection" WGCNA tutorial, and found 24 modules in my RNA-seq data. The issue I have right now is that my modules are all assigned with some weird colors (e.g. mistyrose, antiquewhite1,paleturquoise, etc.), not like in most publications (e.g. black, magenta, blue, red, etc.). I used the labels2color function.

My questions are:

1/ Does the module color have special meaning to genes in the module, or just a color label?

2/ Any way I can make my modules labeled with more "normal" colors? Or any way I can change the module colors manually?

Many thanks!

YS

 

Part of the code:

dynamicMods = cutreeDynamic(dendro= geneTree, distM= dissTOM, deepSplit=2, pamRespectsDendro= FALSE, minClusterSize = minModuleSize)

dynamicColors= labels2colors(dynamicMods)

MEList= moduleEigengenes(datExpr, colors= dynamicColors,softPower = 18)
MEs= MEList$eigengenes
MEDiss= 1-cor(MEs)
METree= flashClust(as.dist(MEDiss), method= "average")

MEDissThres = 0.3
merge = mergeCloseModules(datExpr, dynamicColors, cutHeight= MEDissThres, verbose =3)
mergedColors = merge$colors
mergedMEs = merge$newMEs

plotDendroAndColors(geneTree, cbind(dynamicColors, mergedColors), c("Dynamic Tree Cut", "Merged dynamic"), dendroLabels= FALSE, hang=0.03, addGuide= TRUE, guideHang=0.05)

moduleColors = mergedColors
colorOrder = c("grey", standardColors(50))
moduleLabels = match(moduleColors, colorOrder)-1
MEs = mergedMEs
wgcna • 4.5k views
ADD COMMENT
4
Entering edit mode
@peter-langfelder-4469
Last seen 27 days ago
United States

The colors are just labels. You can use any colors you want. Unfortunately, WGCNA is not set up to let you choose the standard color order. Before telling you how to change the order, I'll just mention that WGCNA does use what you call "standard" colors, the largest modules are labelled turquoise, blue, brown, yellow, green, red, black etc. The "weird" colors are used for smaller modules.

You can easily map your colors to new colors using the moduleLabels vector (which is numeric). Just define

customColorOrder = c("grey", "black", "red", whatever you want);

Make sure the first color is grey since that is conventionally the color of the unassigned genes which carry the numeric module label 0. Also make sure you have enough colors in your customColorOrder to assign a unique color to every module.

Then you can define

moduleColors.custom = customColorOrder[moduleLabels + 1].

You can verify the that the module colors were mapped correctly by running

table(moduleColors, moduleColors.custom)

 

ADD COMMENT
0
Entering edit mode

Thank you very much!

 

YS

ADD REPLY

Login before adding your answer.

Traffic: 941 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