翻译 - WGCNA 6 - Export of networks to external software

6. 网络导出

在这里,我们可以将获得的共表达网络提取出来,然后使用其他第三方可视化工具来分析,比如Cytoscape、VisANT。

6.1. 导入处理的数据:

首先,导入准备好的样本表达数据datExpr、临床信息datTraits以及构建的网络和模块networkConstruction-auto.RData

# 设定工作目录
setwd("/home/cxt/data/R/")
# 导入包
library(WGCNA)
# 设置将strings不要转成factors
options(stringsAsFactors=F)

# 允许使用最大线程
allowWGCNAThreads()
# 或者直接指定线程数
# enableWGCNAThreads(nThreads=16)

# 导入表达与临床数据
lnames = load(file = "dataInput.RData");
lnames
# 导入共表达网络及模块
lnames = load(file = "networkConstruction-auto.RData");
lnames

6.2. 获得VisANT可视化数据

该包提供了一个方便的功能,用于将网络导出到VisANT[1]。我们举例说明了单个模块的全加权网络的一个简单导出。

# Recalculate topological overlap
TOM = TOMsimilarityFromExpr(datExpr, power = 6);
# Read in the annotation file
annot = read.csv(file = "GeneAnnotation.csv");
# Select module
module = "brown";
# Select module probes
probes = names(datExpr)
inModule = (moduleColors==module);
modProbes = probes[inModule];
# Select the corresponding Topological Overlap
modTOM = TOM[inModule, inModule];
dimnames(modTOM) = list(modProbes, modProbes)
# Export the network into an edge list file VisANT can read
vis = exportNetworkToVisANT(modTOM,
  file = paste("VisANTInput-", module, ".txt", sep=""),
  weighted = TRUE,
  threshold = 0,
  probeToGene = data.frame(annot$substanceBXH, annot$gene_symbol) )

由于brown模块比较大,我们可以将输出的基因限制为模块中最顶端的30个hub基因:

nTop = 30;
IMConn = softConnectivity(datExpr[, modProbes]);
top = (rank(-IMConn) <= nTop)
vis = exportNetworkToVisANT(modTOM[top, top],
  file = paste("VisANTInput-", module, "-top30.txt", sep=""),
  weighted = TRUE,
  threshold = 0,
  probeToGene = data.frame(annot$substanceBXH, annot$gene_symbol) )

6.3. 获得Cytoscape可视化数据

Cytoscape[2]允许用户输入边缘文件和节点文件,例如允许用户指定链接权重和节点颜色。在这里,我们演示了两个模块的输出:红色和棕色的模块

# Recalculate topological overlap if needed
TOM = TOMsimilarityFromExpr(datExpr, power = 6);
# Read in the annotation file
annot = read.csv(file = "GeneAnnotation.csv");
# Select modules
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]);

6.4. 小结

就我个人而言,我更习惯将共表达网络及其节点和边的属性导出,并由Cytoscape进行绘制网络。借助Cytoscape丰富的功能,我更够展示更多的信息,并获得比较惊艳的结果图。

WGCNA 
更新时间:2019-05-26 21:48:03

本文由 石九流 创作,如果您觉得本文不错,请随意赞赏
采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
原文链接:https://blog.computsystmed.com/archives/translation-wgcna-export-of-networks-to-external-software
最后更新:2019-05-26 21:48:03

评论

Your browser is out of date!

Update your browser to view this website correctly. Update my browser now

×