<p>If you can run pathway analysis programmatically on all modules, yes, do it on all modules. Otherwise, select the modules with strongest associations with each subtype, both positive and negative. I would keep the modules separate because they may have very different biological functions.</p>

CC BY-SA 4.0
2020-06-09T17:19:48.637Z
Thanks for the answer. One small question. Lets say from the above image, for `Subtype A` I have selected modules salmon, grey60, tan (negative), and midnightblue (positive) for pathway analysis. I see that salmon module is also significantly positive with Subtype C. So, then the pathways I get from salmon module are related to which subtype?
stack_learner
CC BY-SA 4.0
2020-06-10T18:54:35.560Z
Well, I don't see the figure anymore so I can only go by your description, but if salmon module is negatively correlated with A, it means (most of) the genes in the module are downregulated in subtype A and upregulated in (positively associated with) subtype C.
Peter Langfelder
CC BY-SA 4.0
2020-06-12T12:56:58.480Z
thanq. sorry for the heatmap with correlation values modules and trait information. Have some doubt whether here `MEs0 = moduleEigengenes(datExpr, ?)$eigengenes` I have to use `dynamicColors` which is before merging or `moduleColors` which is after merging. In the above image I used dynamicColors. 2) there are few modules like turquoise and blue with more than 8000 and 5000 genes. The number is huge. How do I reduce the number?
stack_learner
CC BY-SA 4.0
2020-06-13T22:58:50.940Z
You can use either merged or un-merged colors; I would suggest using the merged ones.
Peter Langfelder
CC BY-SA 4.0
2020-06-13T22:59:01.493Z
Some modules are often very large which just reflects a factor (driving expression or co-expression) that strongly affects a lot of genes. This could be biological or technical, and could be important to you or a nuisance confounder. You could try to identify the factor e.g. from sample clustering (could be a batch effect) or by relating the MEs of largest modules to known sample characteristics (age, sex, race etc). If you identify a match, adjust the data for it, or simply adjust the data for the ME and run WGCNA again.
Peter Langfelder
CC BY-SA 4.0
2020-06-13T23:47:56.230Z
thanq very much. one more question. To visualize all the modules as network plot....Is it only cytoscape an option? Is there any other software or code to create network plot....
stack_learner
CC BY-SA 4.0
2020-06-09T17:08:55.100Z
2020-06-09T17:08:55.100Z
Peter Langfelder
<p>I have a total of 35 tumor samples classified into 4 subtypes. Subtype A, B, C, and D. I have RNAseq data. I'm interested in identifying modules related to each subtype with co-expression network analysis. I have read the WGCNA tutorial and create a <code>trait.csv</code> file like below:</p>

<p>Showing here some rows of the <code>trait.csv</code> file.</p>

<p><img src="https://i.sstatic.net/pP3NU.png" alt="enter image description here"></p>

<pre><code>SamInfo &lt;- read.csv("trait.csv")

Samples = rownames(datExpr);
traitRows = match(Samples, SamInfo$Samples);
datTraits = SamInfo[traitRows, -1];
rownames(datTraits) = SamInfo[traitRows, 1];

nGenes = ncol(datExpr);
#15648L

nSamples = nrow(datExpr);
#35L

#calculate eigengenes (1st principal component) of modules
MEs0 = moduleEigengenes(datExpr, dynamicColors)$eigengenes
MEs = orderMEs(MEs0)
moduleTraitCor = cor(MEs, datTraits, use = "p");
moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples);

#Will display correlations and their p-values
textMatrix = paste(signif(moduleTraitCor, 2), "\n(", signif(moduleTraitPvalue, 1), ")", 
                   sep = "");
dim(textMatrix) = dim(moduleTraitCor)
par(mar = c(6, 8.5, 3, 3));

#Display the correlation values within a heatmap plot
labeledHeatmap(Matrix = moduleTraitCor, xLabels = names(datTraits), 
               yLabels = names(MEs), ySymbols = names(MEs), colorLabels = FALSE, 
               colors = blueWhiteRed(50), textMatrix = textMatrix, setStdMargins = FALSE, 
               cex.text = 0.5, zlim = c(-1,1), main = paste("Module-trait relationships"))
</code></pre>

<p>The Correlation between Subtypes and Modules Heatmap looks like below:</p>

<p><a href="https://i.sstatic.net/F161r.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/F161r.jpg" alt="enter image description here"></a></p>

<p>For functions identification (Pathway Analysis), from the above output for each subtype, should I select only the modules that were significantly positively correlated with subtypes, or Can I also use the significantly negatively correlated modules?</p>

<p>Is it good to use the modules that were not significant for pathway analysis?</p>

<p>In case if I can use positive and negative correlated modules, Can I combine those modules and use those genes for Pathway analysis?</p>

CC BY-SA 4.0
2023-09-15T16:17:39.593Z
It's a great question. Please consider the answer with a view to upvoting - or even accepting - the answer. It's good all round.
M__
<r><rna-seq><pathway><wgcna><coexpression>
Which module to select for Pathway analysis based on Module trait correlation and pvalue?
# Which module to select for Pathway analysis based on Module trait correlation and pvalue?

(Asked by: username_0 on 2020-06-09)

I have a total of 35 tumor samples classified into 4 subtypes. Subtype A, B, C, and D. I have RNAseq data. I'm interested in identifying modules related to each subtype with co-expression network analysis. I have read the WGCNA tutorial and create a trait.csv file like below:
Showing here some rows of the trait.csv file.

SamInfo <- read.csv("trait.csv")

Samples = rownames(datExpr);
traitRows = match(Samples, SamInfo$Samples);
datTraits = SamInfo[traitRows, -1];
rownames(datTraits) = SamInfo[traitRows, 1];

nGenes = ncol(datExpr);
#15648L

nSamples = nrow(datExpr);
#35L

#calculate eigengenes (1st principal component) of modules
MEs0 = moduleEigengenes(datExpr, dynamicColors)$eigengenes
MEs = orderMEs(MEs0)
moduleTraitCor = cor(MEs, datTraits, use = "p");
moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples);

#Will display correlations and their p-values
textMatrix = paste(signif(moduleTraitCor, 2), "\n(", signif(moduleTraitPvalue, 1), ")", 
                   sep = "");
dim(textMatrix) = dim(moduleTraitCor)
par(mar = c(6, 8.5, 3, 3));

#Display the correlation values within a heatmap plot
labeledHeatmap(Matrix = moduleTraitCor, xLabels = names(datTraits), 
               yLabels = names(MEs), ySymbols = names(MEs), colorLabels = FALSE, 
               colors = blueWhiteRed(50), textMatrix = textMatrix, setStdMargins = FALSE, 
               cex.text = 0.5, zlim = c(-1,1), main = paste("Module-trait relationships"))

The Correlation between Subtypes and Modules Heatmap looks like below:

For functions identification (Pathway Analysis), from the above output for each subtype, should I select only the modules that were significantly positively correlated with subtypes, or Can I also use the significantly negatively correlated modules?
Is it good to use the modules that were not significant for pathway analysis?
In case if I can use positive and negative correlated modules, Can I combine those modules and use those genes for Pathway analysis?

**Tags:** r, rna-seq, pathway, wgcna, coexpression
> **Comments:**
> **username_1**: It's a great question. Please consider the answer with a view to upvoting - or even accepting - the answer. It's good all round.  

---

## 1 answers

### Answer by username_2 on 2020-06-09. Score: 1

If you can run pathway analysis programmatically on all modules, yes, do it on all modules. Otherwise, select the modules with strongest associations with each subtype, both positive and negative. I would keep the modules separate because they may have very different biological functions.

> **Comments:**
> **username_0**: Thanks for the answer. One small question. Lets say from the above image, for `Subtype A` I have selected modules salmon, grey60, tan (negative), and midnightblue (positive) for pathway analysis. I see that salmon module is also significantly positive with Subtype C. So, then the pathways I get from salmon module are related to which subtype?  
> **username_2**: Well, I don't see the figure anymore so I can only go by your description, but if salmon module is negatively correlated with A, it means (most of) the genes in the module are downregulated in subtype A and upregulated in (positively associated with) subtype C.  
> **username_0**: thanq. sorry for the heatmap with correlation values modules and trait information. Have some doubt whether here `MEs0 = moduleEigengenes(datExpr, ?)$eigengenes` I have to use `dynamicColors` which is before merging or `moduleColors` which is after merging. In the above image I used dynamicColors. 2) there are few modules like turquoise and blue with more than 8000 and 5000 genes. The number is huge. How do I reduce the number?  
> **username_2**: You can use either merged or un-merged colors; I would suggest using the merged ones.  
> **username_2**: Some modules are often very large which just reflects a factor (driving expression or co-expression) that strongly affects a lot of genes. This could be biological or technical, and could be important to you or a nuisance confounder. You could try to identify the factor e.g. from sample clustering (could be a batch effect) or by relating the MEs of largest modules to known sample characteristics (age, sex, race etc). If you identify a match, adjust the data for it, or simply adjust the data for the ME and run WGCNA again.  
> **username_0**: thanq very much. one more question. To visualize all the modules as network plot....Is it only cytoscape an option? Is there any other software or code to create network plot....  

---

