WGCNA package in R: dendogram plot error
2
4
Entering edit mode
7.9 years ago
zyr123 ▴ 40

Hi, I am new to WGCNA and I am trying to plot a dendogram using WGCNA package in R.

plotDendroAndColors(sampleTree2, traitColors,
>                     groupLabels = names(datTraits),
>                     main = "Sample dendrogram and trait heatmap")

This is the error I get:

Error in plotOrderedColors(dendro$order, colors = colors, rowLabels = rowLabels, : ERROR: length of colors vector not compatible with number of objects in 'order'.

Any ideas on how to resolve this? Many thanks!

wgcna R • 12k views
ADD COMMENT
0
Entering edit mode

Zyr123, Were you able to fix the problem, I'm having the same problem. Thanks!

ADD REPLY
0
Entering edit mode

Also running into the same issue. Anyone able to get is working? Thanks!

mine was running this part though:

> plotDendroAndColors(geneTree,
>                     cbind(moduleColors, bwModuleColors),
>                     c("Single block", "2 blocks"),
>                     main = "Single block gene dendrogram and module colors",
>                     dendroLabels = FALSE, hang = 0.03,
>                     addGuide = TRUE, guideHang = 0.05)

Error in plotOrderedColors(dendro$order, colors = colors, rowLabels = rowLabels, : ERROR: length of colors vector not compatible with number of objects in 'order'.

This is my net

net = blockwiseModules(datExpr, power = 6,
                       TOMType = "unsigned", minModuleSize = 30,
                       reassignThreshold = 0, mergeCutHeight = 0.25,
                       numericLabels = TRUE, pamRespectsDendro = FALSE,
                       saveTOMs = TRUE,
                       saveTOMFileBase = "All_sample_TOM", 
                       verbose = 3)

And this is my bwnet

bwnet = blockwiseModules(datExpr, maxBlockSize = 2000,
                         power = 6, TOMType = "unsigned", minModuleSize = 30,
                         reassignThreshold = 0, mergeCutHeight = 0.25,
                         numericLabels = TRUE,
                         saveTOMs = TRUE,
                         saveTOMFileBase = "All_sample_TOM-blockwise",
                         verbose = 3)

I have 6720 genes (RNA-Seq data)

ADD REPLY
2
Entering edit mode
7.4 years ago
pakajpol ▴ 20

Hi,

blockwiseModules function have a default max block size of 5000. Thus your data is split in 2 blocks ...2 dendrograms are produced each for cca. half of your genes...the module membership objects (moduleColors, bwModuleColors) however are both of the total length. So when you call a dendrogram it's "order" object is shorter than objects (moduleColors, bwModuleColors) and you get an error.

fix: 1) set maxBlochSize=7000 and you will get a single dendro for all genes 2) or subset the genes in (moduleColors, bwModuleColors) to contain only the ones in block 1 and then match dendro1 with sub setted moduleColors

and read this : https://labs.genetics.ucla.edu/horvath/htdocs/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/FemaleLiver-02-networkConstr-blockwise.pdf

ADD COMMENT
0
Entering edit mode

How can I extract gene lists from blocks and dendros?

ADD REPLY
0
Entering edit mode
24 months ago
rodd ▴ 250

When I got this error in the past, it was because I had removed a few outliers from the expression data object (datExpr0), and this was no longer matching the samples described in datTraits object. Be sure that the number of samples match between the metadata object and the expression object.

ADD COMMENT

Login before adding your answer.

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