<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; BioNet</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/bionet/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>用BioNet这个bioconductor包来找 maximal-scoring subgraph</title>
		<link>http://www.bio-info-trainee.com/2071.html</link>
		<comments>http://www.bio-info-trainee.com/2071.html#comments</comments>
		<pubDate>Fri, 25 Nov 2016 14:54:20 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[基础软件]]></category>
		<category><![CDATA[bioconductor]]></category>
		<category><![CDATA[BioNet]]></category>
		<category><![CDATA[网络分析]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=2071</guid>
		<description><![CDATA[## 此包是为了解决一个难题： maximal-scoring subgraph &#8230; <a href="http://www.bio-info-trainee.com/2071.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>## 此包是为了解决一个难题： maximal-scoring subgraph (MSS) problem ，在一个巨大的复杂网络里面找到significantly differentially expressed subnetworks，就是说，得到了几百个差异基因，去PPI数据库做网络图的时候，发现还是巨大无比，所以需要用这个包来精简我们的网络图。</div>
<div>heuristically的中文意思：启发性地</div>
<div>## 而这个R包可以整合多种数据结果来给一个网络打分，</div>
<div>包的主页是：<a href="https://www.bioconductor.org/packages/release/bioc/html/BioNet.html">https://www.bioconductor.org/packages/release/bioc/html/BioNet.html</a></div>
<div>paper：<a href="http://bioinformatics.oxfordjournals.org/content/early/2010/02/25/bioinformatics.btq089">BioNet: an R-Package for the Functional Analysis of ... - Bioinformatics</a></div>
<div>它整合了PPI网络分析和寻找功能模块的需求。</div>
<div>脚本：<a href="https://www.bioconductor.org/packages/release/bioc/vignettes/BioNet/inst/doc/Tutorial.R">https://www.bioconductor.org/packages/release/bioc/vignettes/BioNet/inst/doc/Tutorial.R</a></div>
<div>教程：<a href="https://www.bioconductor.org/packages/release/bioc/vignettes/BioNet/inst/doc/Tutorial.pdf">https://www.bioconductor.org/packages/release/bioc/vignettes/BioNet/inst/doc/Tutorial.pdf</a></div>
<div>重点就是根据一个"igraph" or "graphNEL"对象和打分来找最大的MSS</div>
<div>subnet &lt;- subNetwork(dataLym$label, interactome)</div>
<div>module &lt;- runFastHeinz(subnet, scores)</div>
<div>plotModule(module, scores=scores, diff.expr=logFC) #这个就是精简后的我们的网络图。</div>
<div>其实另外一个函数也有类似的功能，dNetFind <a href="https://rdrr.io/cran/dnet/man/dNetFind.html">https://rdrr.io/cran/dnet/man/dNetFind.html</a></div>
<div></div>
<p><span id="more-2071"></span></p>
<div>## 里面用到的网络，都是基于igraph的包： A graph object, either in graphNEL or igraph format.</div>
<div>## 首先加载一系列的包和内置数据</div>
<div></div>
<div>library(BioNet)</div>
<div>library(DLBCL)</div>
<div>data(dataLym)</div>
<div>data(interactome)</div>
<div>## dataLym 里面是3个样本,t,s,o 分别对应着的每个基因的p值</div>
<div>## interactome是一个内置的PPI网络对象，可以根据指定的基因list来提取里面的信息</div>
<div></div>
<div>pvals &lt;- cbind(t=dataLym$t.pval, s=dataLym$s.pval)</div>
<div>rownames(pvals) &lt;- dataLym$label</div>
<div>pval &lt;- aggrPvals(pvals, order=2, plot=FALSE)</div>
<div></div>
<div>## 提取t,s样本的p值，然后用aggrPvals整合成一个p值</div>
<div></div>
<div>subnet &lt;- subNetwork(dataLym$label, interactome)</div>
<div>subnet &lt;- rmSelfLoops(subnet)</div>
<div>subnet</div>
<div>## 根据指定的dataLym$label基因信息来提取网络，但是这个基因信息有点奇怪,比如TP53(7157) ， 看起来是symbol跟entrez ID的合体。</div>
<div>## 函数rmSelfLoops是标配，只要是网络，都需要处理一下，去除自循环信息</div>
<div>## 因为指定的dataLym$label基因是有限的，一般不会太多，提取的网络一般也就上千个nodes，万把个edges的</div>
<div></div>
<div>fb &lt;- fitBumModel(pval, plot=FALSE)</div>
<div>## 对我们整合好的基因对应的P值进行Beta-Uniform-Mixture (BUM) model模型处理。</div>
<div>scores &lt;- scoreNodes(subnet, fb, fdr=0.001)</div>
<div></div>
<div>module &lt;- runFastHeinz(subnet, scores)</div>
<div>## Here we use a fast heuristic approach to calculate an approximation to the optimal scoring subnetwork.</div>
<div>logFC &lt;- dataLym$diff</div>
<div>names(logFC) &lt;- dataLym$label</div>
<div></div>
<div>plotModule(module, scores=scores, diff.expr=logFC)</div>
<div>## diff.expr是用来给nodes调色的</div>
<div>## scores是用来给nodes赋予性状的</div>
<div>## 这个函数本身是基于graphNEL or igraph format的定制版，其实可以直接用igraph包来绘图。</div>
<div>## 也可以把这个network导出成Cytoscape format，这样可以用cytoscape来绘图</div>
<div>## 一般来说，红色是上调基因，绿色是下调基因，圆形是得分为正，菱形是得分为负</div>
<div></div>
<div></div>
<div>## 下面是一个实际的例子，如何使用BioNet包来做网络分析</div>
<div>library(BioNet)</div>
<div>library(DLBCL)</div>
<div>data(exprLym)</div>
<div>data(interactome)</div>
<div>exprLym ## 内置对象，所以它的gene的laber是符合interactome的要求的</div>
<div>interactome</div>
<div>network &lt;- subNetwork(featureNames(exprLym), interactome)</div>
<div>network</div>
<div>network &lt;- largestComp(network)</div>
<div>## The function extracts the largest component of a network</div>
<div>network</div>
<div></div>
<div>library(genefilter)</div>
<div>library(impute)</div>
<div>expressions &lt;- impute.knn(exprs(exprLym))$data</div>
<div>## exprs得到的不再是纯粹的表达矩阵，需要用来 impute missing expression data</div>
<div>## 这里选择genefilter包的rowttests函数来做差异分析</div>
<div>t.test &lt;- rowttests(expressions, fac=exprLym$Subgroup)</div>
<div>t.test[1:10, ]</div>
<div>data(dataLym)</div>
<div></div>
<div>ttest.pval &lt;- t.test[, "p.value"]</div>
<div>surv.pval &lt;- dataLym$s.pval</div>
<div>names(surv.pval) &lt;- dataLym$label</div>
<div>pvals &lt;- cbind(ttest.pval, surv.pval)</div>
<div>pval &lt;- aggrPvals(pvals, order=2, plot=FALSE)</div>
<div>fb &lt;- fitBumModel(pval, plot=FALSE)</div>
<div>fb</div>
<div>## 用图来展示这个fitBumModel函数到底做了什么</div>
<div>dev.new(width=13, height=7)</div>
<div>par(mfrow=c(1,2))</div>
<div>hist(fb)</div>
<div>plot(fb)</div>
<div>dev.off()</div>
<div></div>
<div>## 下面这个图可以看到 Beta-Uniform-Mixture (BUM) 模型的两个参数是如何体现的</div>
<div>plotLLSurface(pval, fb)</div>
<div></div>
<div>scores &lt;- scoreNodes(network=network, fb=fb, fdr=0.001)</div>
<div>## 根据p值来对每个edge打分</div>
<div></div>
<div>network &lt;- rmSelfLoops(network)</div>
<div></div>
<div>## 下面是把网络数据写到txt文档，就可以导入到cytoscape啦！</div>
<div>writeHeinzEdges(network=network, file="lymphoma_edges_001", use.score=FALSE)</div>
<div>writeHeinzNodes(network=network, file="lymphoma_nodes_001", node.scores = scores)</div>
<div></div>
<div>datadir &lt;- file.path(path.package("BioNet"), "extdata")</div>
<div>dir(datadir)</div>
<div>## 本次算法变了：the heinz algorithm is used to calculate the maximum-scoring subnetwork</div>
<div>## 下面的文件需要借助heinz.py脚本生成，这里实例用的是包自带的数据</div>
<div>## 脚本代码是：heinz.py -e lymphoma_edges_001.txt -n lymphoma_nodes_001.txt -N True -E False</div>
<div></div>
<div>module &lt;- readHeinzGraph(node.file=file.path(datadir, "lymphoma_nodes_001.txt.0.hnz"), network=network)</div>
<div>diff &lt;- t.test[, "dm"]</div>
<div>names(diff) &lt;- rownames(t.test)</div>
<div></div>
<div>plotModule(module, diff.expr=diff, scores=scores)</div>
<div></div>
<div>sum(scores[nodes(module)])</div>
<div>sum(scores[nodes(module)]&gt;0)</div>
<div>sum(scores[nodes(module)]&lt;0)</div>
<div></div>
<div></div>
<div>###################################################</div>
<div>### code chunk number 27: Tutorial.Rnw:375-380</div>
<div>###################################################</div>
<div>library(BioNet)</div>
<div>library(DLBCL)</div>
<div>library(ALL)</div>
<div>data(ALL)</div>
<div>data(interactome)</div>
<div>## 这个ALL是另外一个包的数据，基因ID现在还没有，是探针ID，需要转换成BioNet识别的！</div>
<div>mapped.eset &lt;- mapByVar(ALL, network=interactome, attr="geneID")</div>
<div>mapped.eset[1:5,1:5]</div>
<div>length(intersect(rownames(mapped.eset), nodes(interactome)))</div>
<div>network &lt;- subNetwork(rownames(mapped.eset), interactome)</div>
<div>network</div>
<div>network &lt;- largestComp(network)</div>
<div>network &lt;- rmSelfLoops(network)</div>
<div>network</div>
<div></div>
<div>## 这里用limma来做差异分析</div>
<div>library(limma)</div>
<div>design &lt;- model.matrix(~ -1+ factor(c(substr(unlist(ALL$BT), 0, 1))))</div>
<div>colnames(design)&lt;- c("B", "T")</div>
<div>contrast.matrix &lt;- makeContrasts(B-T, levels=design)</div>
<div>contrast.matrix</div>
<div>fit &lt;- lmFit(mapped.eset, design)</div>
<div>fit2 &lt;- contrasts.fit(fit, contrast.matrix)</div>
<div>fit2 &lt;- eBayes(fit2)</div>
<div>pval &lt;- fit2$p.value[,1]</div>
<div>fb &lt;- fitBumModel(pval, plot=FALSE)</div>
<div>fb</div>
<div>dev.new(width=13, height=7)</div>
<div>par(mfrow=c(1,2))</div>
<div>hist(fb)</div>
<div>plot(fb)</div>
<div>scores &lt;- scoreNodes(network=network, fb=fb, fdr=1e-14)</div>
<div>## 还是把网络数据写到本地，供cytoscape导入</div>
<div>writeHeinzEdges(network=network, file="ALL_edges_001", use.score=FALSE)</div>
<div>writeHeinzNodes(network=network, file="ALL_nodes_001", node.scores = scores)</div>
<div>## 还是使用 heinz algorithm is used to calculate the maximum-scoring subnetwork</div>
<div>## A new implementation Heinz v2.0 is also available at https://software.cwi.nl/software/heinz ,</div>
<div></div>
<div>datadir &lt;- file.path(path.package("BioNet"), "extdata")</div>
<div>module &lt;- readHeinzGraph(node.file=file.path(datadir, "ALL_nodes_001.txt.0.hnz"), network=network)</div>
<div></div>
<div>nodeDataDefaults(module, attr="diff") &lt;- ""</div>
<div>nodeData(module, n=nodes(module), attr="diff") &lt;- fit2$coefficients[nodes(module),1]</div>
<div>nodeDataDefaults(module, attr="score") &lt;- ""</div>
<div>nodeData(module, n=nodes(module), attr="score") &lt;- scores[nodes(module)]</div>
<div>nodeData(module)[1]</div>
<div></div>
<div>## 保存为XGMML file，供cytoscape使用</div>
<div>saveNetwork(module, file="ALL_module", type="XGMML")</div>
<div></div>
<div><span style="color: #ff0000;">## 一般来说，红色是上调基因，绿色是下调基因，圆形是得分为正，菱形是得分为负</span></div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/2071.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
