Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-18T07:14:32.030Z
Answers.Text: Thank you so much! I will give it a try now, thank you!
Answers.UserDisplayName: holly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-20T09:24:03.147Z
Answers.Text: It works! Thank you so much, as always for your time and help!
Answers.UserDisplayName: holly
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-17T22:40:34.813Z
Answers.LastActivityDate: 2019-06-17T22:40:34.813Z
Answers.UserDisplayName: Peter Langfelder
Body: <p>I am comparing single block module detection with 2 block module detection in WGCNA.</p>
  
  <p>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</p>
  
  <p>I get the error code: </p>
  
  <pre><code>Error in plotOrderedColors(dendro$order, colors = colors, rowLabels = rowLabels,  : 
    ERROR: length of colors vector not compatible with number of objects in 'order'.
  </code></pre>
  
  <p>Using the following code:</p>
  
  <pre class="lang-r prettyprint-override"><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<span class="math-container">$dendrograms[[1]], mergedColors[net$</span>blockGenes[[1]]],
                      "Module colors",
                      dendroLabels = FALSE, hang = 0.03,
                      addGuide = TRUE, guideHang = 0.05)
  moduleLabels = net<span class="math-container">$colors
  moduleColors = labels2colors(net$</span>colors)
  MEs = net<span class="math-container">$MEs
  geneTree = net$</span>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",
                          verbose=3)
  bwLabels = matchLabels(bwet$colors,moduleLabels)
  
  bwModuleColors = labels2colors(bwLabels)
  
  
  plotDendroAndColors(geneTree,
                      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) 
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-15T22:32:02.103Z
Comments.Text: 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?
Comments.UserDisplayName: Peter Langfelder
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-16T07:23:59.173Z
Comments.Text: 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
Comments.UserDisplayName: holly
Tags: <r><wgcna>
Title: Error Code in WGCNA: Dealing with large data sets: block-wise network construction andmodule detection
ThreadText: # Error Code in WGCNA: Dealing with large data sets: block-wise network construction andmodule detection
  
  (Asked by: username_0 on 2019-06-15)
  
  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:
  
  ```r
  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",
                          verbose=3)
  bwLabels = matchLabels(bwet$colors,moduleLabels)
  
  bwModuleColors = labels2colors(bwLabels)
  
  plotDendroAndColors(geneTree,
                      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) 
  
  ```
  
  **Tags:** r, wgcna
  
  > **Comments:**
  > **username_1**: 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?  
  > **username_0**: 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  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-06-17. Score: 2 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: Thank you so much! I will give it a try now, thank you!  
  > **username_0**: It works! Thank you so much, as always for your time and help!  
  
  ---
  
  