I am comparing single block module detection with 2 block module detection in WGCNA.

Does anyone know what this relates to? I have rechecked and rechecked my codes for both the single and 2 module detection and cannot see an error. Thank you

I get the error code:

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

Using the following code:

net= blockwiseModules(Th1_h5, power=6,
                      TOMType = "signed", minModuleSize=30,
                      reassignThreshold =0, mergeCutHeight = 0.25,
                      numericLabels = TRUE, pamRespectsDendro = FALSE,
                      saveTOMs = TRUE,
                      saveTOMFileBase = "PBCreponseTOMB",
                      verbose= 3 
mergedColors = labels2colors(net$colors)

plotDendroAndColors(net$dendrograms[[1]], mergedColors[net$blockGenes[[1]]],
                    "Module colors",
                    dendroLabels = FALSE, hang = 0.03,
                    addGuide = TRUE, guideHang = 0.05)
moduleLabels = net$colors
moduleColors = labels2colors(net$colors)
MEs = net$MEs
geneTree = net$dendrograms[[1]]

bwet = blockwiseModules(Th1_h5, maxBlockSize = 8000,
                        power=6, TOMType = "signed", minModuleSize = 30,
                        reassignThreshold = 0, mergeCutHeight = 0.25,
                        numericLabels = TRUE,
                        saveTOMs = TRUE, 
                        saveTOMFileBase = "Th1_NR_R_TOM-blockwise",
bwLabels = matchLabels(bwet$colors,moduleLabels)

bwModuleColors = labels2colors(bwLabels)

                    cbind(moduleColors, bwModuleColors),
                    c("Single block", "2 blocks"),
                    main = "Single block gene dendrogram and module colours",
                    dendroLabels = FALSE, hang = 0.03,
                    addGuide = TRUE, guideHang =  0.05) 
  • $\begingroup$ You will need to provide more detail. How big was the data from which you calculated the network (how many genes) and how did you determine geneTree? $\endgroup$ – Peter Langfelder Jun 15 '19 at 22:32
  • $\begingroup$ I have 12711 genes after filtering and have added the additional code above. It has worked with the simple Automatic, one-step network construction and module detection and Step-by-step network construction and module detection but not when trying with 2 blocks. Thank you kindly $\endgroup$ – holly Jun 16 '19 at 7:23

The problem is that blockwiseModules split your data into (probably 3) blocks, because the default maxBlockSize is 5000 and smaller than the number of genes in your data. If you have enough RAM (16GB is recommended for 12k genes, but 8GB just might be enough), rerun blockswiseModules again with maxBlockSize raised to above the number of your genes. Since you were able to run the function with maxBlockSize=8000, hoepfully you'll be able to do the single block calculation.

| improve this answer | |
  • $\begingroup$ Thank you so much! I will give it a try now, thank you! $\endgroup$ – holly Jun 18 '19 at 7:14
  • $\begingroup$ It works! Thank you so much, as always for your time and help! $\endgroup$ – holly Jun 20 '19 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.