WGCNA Concise Guide | 3. Network Visualization with WGCNA
WGCNA series
WGCNA Concise Guide | 1. Gene Coexpression Network Construction and Module Identification
WGCNA Concise Guide | 2. Module-Trait Association Analysis and Identification of Important Genes
The basic tutorial of WGCNA has come to an end here, and will be explained in practice with examples in published articles. Friends who need all the code and sample data of the basic tutorial can do
点赞+在看,并转发朋友圈集赞10个
it赞赏10元
.
WGCNA series
reference
data preparation
Visualizing Networks in R
Visualizing gene networks
eigengenes network visualization
Export network data to network visualization software
Export to Cytoscape
Past
reference
This article mainly refers to the official guide Tutorials for WGCNA R package (ucla.edu). For details, please refer to the official documentation.
Other information:
WGCNA - Anthology - Jianshu (jianshu.com)
WGCNA analysis, the latest simple and comprehensive tutorial - short book (jianshu.com)
WGCNA: (weighted co-expression network analysis) - bioprogrammer - CSDN blog
How does WGCNA mine key genes from modules - Programmer Sought
data preparation
WGCNA Concise Guide | 1. Gene Coexpression Network Construction and Module Identification
WGCNA Concise Guide | 2. Module-Trait Association Analysis and Identification of Important Genes
Visualizing Networks in R
Visualizing gene networks
# 模块检测时的计算,重新算一次
dissTOM = 1-TOMsimilarityFromExpr(datExpr, power = 6);
# 对dissTOM进行power转换,使中等强度的连接在热图中更加明显
plotTOM = dissTOM^7;
# 设置对角线为NA以得到更好的图
diag(plotTOM) = NA;
# 绘图
sizeGrWindow(9,9)
TOMplot(plotTOM, geneTree, moduleColors, main = "Network heatmap plot, all genes")
Partial gene visualization TOM matrix
Generating a heatmap for all genes can take a significant amount of time. The number of genes can be limited to speed up the plot. However, a gene dendrogram for a subset of genes often looks different from a gene dendrogram for all genes. In the example below, the number of genes plotted is limited to 400.
nSelect = 400
# 为了可重复,设置随机数种子
set.seed(10);
select = sample(nGenes, size = nSelect);
selectTOM = dissTOM[select, select];
# 没有简单的方法将聚类树限制在基因的一个子集,所以我们必须重新聚类
selectTree = hclust(as.dist(selectTOM), method = "average")
selectColors = moduleColors[select];
# 绘制
sizeGrWindow(9,9)
plotDiss = selectTOM^7;
diag(plotDiss) = NA;
TOMplot(plotDiss, selectTree, selectColors, main = "Network heatmap plot, selected genes")
eigengenes network visualization
# 重新计算模块 eigengenes
MEs = moduleEigengenes(datExpr, moduleColors)$eigengenes
# 提取临床特征weight
weight = as.data.frame(datTraits$weight_g);
names(weight) = "weight"
# 在eigengenes模块中加入临床特征weight
MET = orderMEs(cbind(MEs, weight))
# 绘制eigengenes和临床特征weight之间的关系图
sizeGrWindow(5,7.5);
par(cex = 0.9)
plotEigengeneNetworks(MET, "",
marDendro = c(0,4,1,2),
marHeatmap = c(3,4,1,2),
cex.lab = 0.8, xLabelsAngle= 90)
# 分别绘制
# 绘制树状图
sizeGrWindow(6,6);
par(cex = 1.0)
plotEigengeneNetworks(MET, "Eigengene dendrogram", marDendro = c(0,4,2,0),
plotHeatmaps = FALSE)
# 绘制热图
par(cex = 1.0)
plotEigengeneNetworks(MET, "Eigengene adjacency heatmap", marHeatmap = c(3,4,2,2),
plotDendrograms = FALSE, xLabelsAngle = 90)
Export network data to network visualization software
Export to Cytoscape
# Recalculate topological overlap if needed
TOM = TOMsimilarityFromExpr(datExpr, power = 6);
# Read in the annotation file
annot = read.csv(file = "GeneAnnotation.csv");
# 以红色和棕色模块为例
modules = c("brown", "red");
# Select module probes
probes = names(datExpr)
inModule = is.finite(match(moduleColors, modules));
modProbes = probes[inModule];
modGenes = annot$gene_symbol[match(modProbes, annot$substanceBXH)];
# Select the corresponding Topological Overlap
modTOM = TOM[inModule, inModule];
dimnames(modTOM) = list(modProbes, modProbes)
# Export the network into edge and node list files Cytoscape can read
cyt = exportNetworkToCytoscape(modTOM,
edgeFile = paste("CytoscapeInput-edges-", paste(modules, collapse="-"), ".txt", sep=""),
nodeFile = paste("CytoscapeInput-nodes-", paste(modules, collapse="-"), ".txt", sep=""),
weighted = TRUE,
threshold = 0.02,
nodeNames = modProbes,
altNodeNames = modGenes,
nodeAttr = moduleColors[inModule]);
cyt
There are edge
sum node
data, which can be imported cytoscape
for visualization.
Past
Mapping with Nature | Paired Dumbbell Plot + Grouped Fitting Curve + Categorical Variable Heat Map
(Free Tutorial + Code Collection)|Follow Cell to Learn Drawing Series Collection
Follow Nat Commun to learn to draw | 1. Batch boxplot + scatter + difference analysis
Follow Nat Commun to learn to map | 3. Species abundance stacking histogram
Follow Nat Commun to learn to draw | 4. Paired boxplot + difference analysis