Documentation

使用图理论函数

此示例显示了如何使用BioinFormatics Toolbox™与图形一起使用和远程化图形。

从图理论意义上讲,图是表示对象之间的连接或关系的一种数学方式。生物信息学中有许多应用程序,其中理解对象之间的关系非常重要。这些应用包括系统发育分析,蛋白质 - 蛋白质相互作用,途径分析等等。生物信息学工具箱提供了一组通用功能,用于使用和可视化图。

Creating a Graph from a SimBiology® Model

该图理论在生物信息学工具箱中起作用,可在稀疏矩阵上起作用。唯一的限制是矩阵是正方形。在此示例中,由抑制剂[1]振荡网络的Simbiology®模型创建了图。在该模型中,蛋白A抑制蛋白B,蛋白B抑制蛋白C,从而抑制蛋白A。

loadoscillatorgraph

There are two variables:g, a sparse matrix, and名称, a list of the names of the nodes of the graph.

whosg名称
名称大小字节类属性G 65x65 2544双稀疏名称65x1 8340单元格

If you have SimBiology you can create the graph using the following commands:

%sbioloadproject振荡器% class(m1)%现在获取邻接矩阵%[g,names] = getAdjacencyMatrix(M1);

可视化图

There are many functions in MATLAB® for working with sparse matrices. The间谍function displays as * wherever there is a non-zero element of the matrix.

间谍(g)

This gives some indication of the number of edges of the graph and also shows that the graph is not symmetric and, hence, is a directed graph. However, it is difficult to visualize what is going on. Thebiograph对象代表一个图表的另一种方式在Bioinformatics Toolbox.

gObj = biograph(g,names)
Biograph object with 65 nodes and 123 edges.

Theview方法列出图形并将其显示在图中。

gObj = view(gObj);

You can interact with the graph using the mouse. You can also programmatically modify the way that the graph is displayed.

% find the nodes pA, pB, and pCpANode = find(strcmp('pA', names)); pBNode = find(strcmp('pB',names)); pCNode = find(strcmp('个人电脑', names));这些红色,绿色和蓝色颜色为%gobj.nodes(panode).color = [1 0 0];gobj.nodes(panode).size = [40 30];gobj.nodes(pbnode).color = [0 1 0];gobj.nodes(pbnode).size = [40 30];gobj.nodes(pcNode).color = [0 0 1];gobj.nodes(pcNode).size = [40 30];dolayout(gobj);

使用图理论函数

生物信息学工具箱中有几个功能用于使用图形。这些包括GraphShortestPath,找到两个节点之间的最短路径,Graphisspantree, which checks if a graph is a spanning tree, andgraphisdag, which checks if a graph is a directed acyclic graph.

graphisdag(g)
ans = 0

There are also corresponding methods of the biograph object. These have names similar to the functions for working with sparse matrices but without the prefix 'graph'.

isdag(gObj)
ans = 0

找到节点PA和PC之间的最短路径

关于图形的一个常见问题是两个节点之间的最短路径是什么。请注意,在此示例中,所有边缘都有长度1。

[dist,path,pred] =短路路径(gobj,panode,pcnode);

为最短路径的节点和边缘着色

set(gObj.Nodes(path),'颜色',[1 0.4 0.4]) edges = getedgesbynodeid(gObj,get(gObj.Nodes(path),'ID')); set(edges,'linecolor',[1 0 0])设置(边缘,'LineWidth',1.5)

您可以使用allshortestpathsto calculate the shortest paths from each node to all other nodes.

allshortest = allshortestpath(gobj);

A heatmap of these distances shows some interesting patterns.

imagesc(allShortest) colormap(pink); colorbar title('All Shortest Paths for Oscillator Model');

Traversing the Graph

Another common problem with graphs is finding an efficient way to traverse a graph by moving between adjacent nodes. The遍历方法默认使用深度优先搜索,但您也可以选择使用广度优先搜索。

顺序= traverse(Gobj,Panode);

返回值order显示了从PA开始穿过节点的顺序。您可以使用它来找到从PA到PC的替代路径。

替代路径=订单(1:find(order == pcNode));set(gobj.nodes(备用路径),'颜色',[0.4 0.4 1]) edges = getedgesbynodeid(gObj,get(gObj.Nodes(alternatePath),'ID')); set(edges,'linecolor',[0 0 1])设置(边缘,'LineWidth',1.5)

在图中查找连接的组件

The oscillator model is cyclic with pA, pB, and pC all connected. The methodConncompfinds connected components. A strongly connected component of a graph is a maximal group of nodes that are mutually reachable without violating the edge directions. You can use theConncomp确定哪些节点不是主要周期的一部分的方法。

[s,c] = conncomp(gobj);% Mark the nodes for each component with different colorcolors = flipud(jet(S));fori = 1:numel(gobj.nodes)gobj.nodes(i).color =颜色(c(i),:);end

您会注意到“垃圾”节点是一个接收器。几个节点连接到该节点,但是从“垃圾”到任何其他节点没有路径。

Simulating Knocking Out a Reaction

In biological pathways it is common to find that while some reactions are essential to the survival of the behavior of the pathway, others are not. You can use the sparse graph representation of the pathway to investigate whether Reaction1 and Reaction2 in the model are essential to the survival of the oscillatory properties.

Find the nodes in which you are interested.

r1Node = find(strcmp('Reaction1', names)); r2Node = find(strcmp('Reaction2', names));

创建稀疏矩阵的副本,然后删除与反应相关的所有边缘。

gNoR1 = g; gNoR1(r1Node,:) = 0; gNoR1(:,r1Node) = 0; gNoR2 = g; gNoR2(r2Node,:) = 0; gNoR2(:,r2Node) = 0;

如果我们删除了反应2,则仍然存在从PA到PC和背部的路径,并且结构并没有太大变化。

distNoR2CA = graphshortestpath(gNoR2,pCNode,pANode) distNoR2AC = graphshortestpath(gNoR2,pANode,pCNode)% Display the graph from which Reaction2 was removed.gNoR2Obj = view(biograph(gNoR2,names)); [S,C] = conncomp(gNoR2Obj);% Mark the nodes for each component with different colorcolors = flipud(jet(S));fori = 1:numel(gNoR2Obj.nodes) gNoR2Obj.Nodes(i).Color = colors(C(i),:);end
distnor2ca = 10 distnor2ac = 14

However, in the case where we remove Reaction1, there is no longer a path from pC back to pA.

DistNor1ac = GraphShortestPath(GNOR1,PANODE,PCNODE)DISTNOR1CA = GraphShortestPath(GNOR1,PCNODE,PANODE)
distNoR1AC = 14 distNoR1CA = Inf

When you visualize the graph from which Reaction1 was removed you will see a significant change in the structure of the graph.

%显示去除反应1的图。gNoR1Obj = view(biograph(gNoR1,names)); [S,C] = conncomp(gNoR1Obj);% Mark the nodes for each component with different colorcolors = flipud(jet(S));fori = 1:numel(gNoR1Obj.nodes) gNoR1Obj.Nodes(i).Color = colors(C(i),:);end

参考

[1] Elowitz,M.B和Leibler,S。,“转录调节器的合成振荡网络”,《自然》,403(6767):335-8,2000。

这个话题有帮助吗?