<p>Pathways are generally directed graphs, which can be implemented in python using the <code>networkx</code> package. Note that there will be cycles in graphs.</p>

<p>Please note that there are large numbers of pathways analysis packages that already exist (both python and R packages but also just webservers), so I strongly recommend searching to see if something already exists before wasting time and implementing it yourself.</p>

CC BY-SA 4.0
2020-01-29T12:18:42.943Z
Pathways aren’t exactly directed graphs. There are different relationships (inhibition, enhancement,...) how to build a netwrokx’s graph out of it isn’t clear. And that is my main issue, how to build a graph given a KEGG pathway.
0x90
CC BY-SA 4.0
2020-01-29T15:16:05.507Z
Basically my original question is how to transfer a KEGG pathway to a networkx object?
0x90
CC BY-SA 4.0
2020-01-29T19:17:45.490Z
Inhibition and enhancement would be weights with different signs. For more complicated interactions standard graph representations simply wouldn't suffice.
Devon Ryan
CC BY-SA 4.0
2020-01-29T07:21:52.870Z
2020-01-29T07:21:52.870Z
Devon Ryan
<p>I would like to construct a mathematical graph: <span class="math-container">$G = (E,V, w(E))$</span> a graph with vertices, edges with weight on them <a href="https://www.biostars.org/p/85763/" rel="nofollow noreferrer">based on a KEGG pathway</a>.  </p>

<p>Is there a way to do that with existing tools? If not I will start to implement a Python module for that. My main question is what is the mathematical graph representation of pathways? Assuming the possible node types and the different connections? </p>

<p>I would like to transform a pathway to a graph because then one can run min-cut-max-flow algorithms and stuff like that as part of my <a href="https://en.wikipedia.org/wiki/Pathway_analysis" rel="nofollow noreferrer">pathway analysis</a>. </p>

<python><pathway><kegg>
How to represent pathways as mathematical graphs?
# How to represent pathways as mathematical graphs?

(Asked by: username_0 on 2020-01-28)

I would like to construct a mathematical graph: $G = (E,V, w(E))$ a graph with vertices, edges with weight on them [based on a KEGG pathway](https://www.biostars.org/p/85763/).

Is there a way to do that with existing tools? If not I will start to implement a Python module for that. My main question is what is the mathematical graph representation of pathways? Assuming the possible node types and the different connections?

I would like to transform a pathway to a graph because then one can run min-cut-max-flow algorithms and stuff like that as part of my [pathway analysis](https://en.wikipedia.org/wiki/Pathway_analysis).

**Tags:** python, pathway, kegg

---

## 1 answers

### Answer by username_1 on 2020-01-29. Score: 1

Pathways are generally directed graphs, which can be implemented in python using the `networkx` package. Note that there will be cycles in graphs.

Please note that there are large numbers of pathways analysis packages that already exist (both python and R packages but also just webservers), so I strongly recommend searching to see if something already exists before wasting time and implementing it yourself.

> **Comments:**
> **username_0**: Pathways aren’t exactly directed graphs. There are different relationships (inhibition, enhancement,...) how to build a netwrokx’s graph out of it isn’t clear. And that is my main issue, how to build a graph given a KEGG pathway.  
> **username_0**: Basically my original question is how to transfer a KEGG pathway to a networkx object?  
> **username_1**: Inhibition and enhancement would be weights with different signs. For more complicated interactions standard graph representations simply wouldn't suffice.  

---

