<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>

CC BY-SA 4.0
2021-08-27T16:20:02.927Z
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
user1567654
CC BY-SA 4.0
2021-08-28T17:21:26.897Z
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.
Peter Langfelder
CC BY-SA 4.0
2021-08-25T17:37:35.290Z
2021-08-25T17:37:35.290Z
Peter Langfelder
<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>

CC BY-SA 4.0
2021-08-24T21:57:49.610Z
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
Ram RS
CC BY-SA 4.0
2023-01-17T21:18:17.830Z
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
Mazbi
<wgcna>
WGCNA hub genes error
# 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.  

---

