How can I extract gene lists from blocks and dendros?
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!
3 answers
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
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.
In case some other people run into this problem, if increasing your block size does not solve the problem, the "blockwiseModules" removes genes that have "too many missing samples or zero variance". However, "bwnet$colors" and "bwnet$unmergedColors" contain all the genes, but the dendrogram contains only the GOOD genes. I solved the problem by removing the BAD genes as follows:
bwnet$colors <- bwnet$colors[bwnet$goodGenes]
bwnet$unmergedColors <- bwnet$unmergedColors[bwnet$goodGenes]
Log in to answer this question.
Hello zyr123!
It appears that your post has been cross-posted to another site: http://stackoverflow.com/questions/41865463
This is typically not recommended as it runs the risk of annoying people in both communities.
Thanks for pointing that out! Sorry I am quite new to all this, I have removed the same post on the other site. Thanks!
Zyr123, Were you able to fix the problem, I'm having the same problem. Thanks!
Also running into the same issue. Anyone able to get is working? Thanks!
mine was running this part though:
This is my net
And this is my bwnet
I have 6720 genes (RNA-Seq data)
You might had delete the outliers from the expression table but then the traits data.frame doesn't match with expression table dimensions.