Answers.Body: <p>The most likely culprit here is that your expression data (the datExpr input to chooseTopHubInEachModule) has no colnames. Check that your data do have appropriate column names. Also check that the module color vector you supply has at least actual module (type table(moduleColors) and check that you have at least one module apart from &quot;grey&quot; or 0).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-27T16:20:02.927Z
Answers.Text: thanks as it worked. I have another question for extracting genes within modules of interest. I used unsigned network and interested in two modules for a trait. Earlier I made scatter plot and extracted the genes in all the modules. But now I only want to extract genes in these two modules for further analysis. I am not able to find a tutorial with more than one module. Can you please suggest something? Thank you1
Answers.UserDisplayName: user1567654
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-28T17:21:26.897Z
Answers.Text: Well, there are a few sections of the tutorial that may help. You can export the entire network analysis results (which you should do anyway) as illustrated in section 3d and then restrict the table (or just the gene identifiers) to the two modules you want. Alternatively, section 4a shows how to export gene identifiers in selected modules.
Answers.UserDisplayName: Peter Langfelder
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-25T17:37:35.290Z
Answers.LastActivityDate: 2021-08-25T17:37:35.290Z
Answers.UserDisplayName: Peter Langfelder
Body: <p>I am trying to find hub genes for modules made using WGCNA:</p>
  <pre><code>hub = chooseTopHubInEachModule(datExpr, moduleColors)
  </code></pre>
  <p>But I am getting error:</p>
  <pre><code>Error in hubs[m] &lt;- colnames(adj)[hub] : replacement has length zero
  </code></pre>
  <p>Thank you for the help1</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-24T21:57:49.610Z
Comments.Text: Cross-posted on biostars: https://www.biostars.org/p/9486378/ Please don't shotgun post on multiple fora. See this discussion: https://bioinformatics.meta.stackexchange.com/questions/265/about-posting-queries-in-stack-bioinformatics
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-01-17T21:18:17.830Z
Comments.Text: Can you please share the code, how you fixed this problem? I am facing the same problem and my data has colnames.
  Any help will be appreciated.
  Thanks
Comments.UserDisplayName: Mazbi
Tags: <wgcna>
Title: WGCNA hub genes error
ThreadText: # WGCNA hub genes error
  
  (Asked by: username_0 on 2021-08-24)
  
  I am trying to find hub genes for modules made using WGCNA:
  
  ```
  hub = chooseTopHubInEachModule(datExpr, moduleColors)
  
  ```
  
  But I am getting error:
  
  ```
  Error in hubs[m] <- colnames(adj)[hub] : replacement has length zero
  
  ```
  
  Thank you for the help1
  
  **Tags:** wgcna
  
  > **Comments:**
  > **username_1**: Cross-posted on biostars: https://www.biostars.org/p/9486378/ Please don't shotgun post on multiple fora. See this discussion: https://bioinformatics.meta.stackexchange.com/questions/265/about-posting-queries-in-stack-bioinformatics  
  > **username_2**: Can you please share the code, how you fixed this problem? I am facing the same problem and my data has colnames. Any help will be appreciated. Thanks  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-08-25. Score: 1 | Accepted answer
  
  The most likely culprit here is that your expression data (the datExpr input to chooseTopHubInEachModule) has no colnames. Check that your data do have appropriate column names. Also check that the module color vector you supply has at least actual module (type table(moduleColors) and check that you have at least one module apart from "grey" or 0).
  
  > **Comments:**
  > **username_0**: thanks as it worked. I have another question for extracting genes within modules of interest. I used unsigned network and interested in two modules for a trait. Earlier I made scatter plot and extracted the genes in all the modules. But now I only want to extract genes in these two modules for further analysis. I am not able to find a tutorial with more than one module. Can you please suggest something? Thank you1  
  > **username_3**: Well, there are a few sections of the tutorial that may help. You can export the entire network analysis results (which you should do anyway) as illustrated in section 3d and then restrict the table (or just the gene identifiers) to the two modules you want. Alternatively, section 4a shows how to export gene identifiers in selected modules.  
  
  ---
  
  