<p>How can I find the relation between pairs of pathways in pathway databases like KEGG?</p>

<p>Is there any R-package to do this?</p>

I believe that the needed data is available through KGML files. For example the [hsa05130 pathway][1] has few arrows pointing on other pathways, for example [hsa04210][2]. If you'd get the 5130 as a [KGML file][3] through their REST API, you'll find that these arrows are encoded as:

```
<entry id="19" name="path:hsa04210" type="map" link="http://www.kegg.jp/dbget-bin/www_bget?hsa04210">
<graphics name="Apoptosis" fgcolor="#000000" bgcolor="#FFFFFF" type="roundrectangle" x="773" y="814" width="73" height="25"/>
</entry>
```

i.e. as *external links*. Should not be difficult to parse an XML using R. As a quick solution:

```
require(XML)
hsa05130_kgml <- xmlParse("http://rest.kegg.jp/get/hsa05130/kgml")
out_nodes = getNodeSet(data, "//entry[@type='map']", fun=xmlToList)
links_summary <- data.frame(do.call(rbind, out_nodes))
head(links_summary)
```

```
1     Regulation of actin cytoskeleton, #000000, #FFFFFF, roundrectangle, 805, 460, 119, 34
2                   Flagellar assembly, #000000, #FFFFFF, roundrectangle, 126, 253, 113, 25
3                    Adherens junction, #000000, #FFFFFF, roundrectangle, 761, 975, 120, 25
4                        Tight junction, #000000, #FFFFFF, roundrectangle, 631, 975, 98, 25
5 Toll-like receptor signaling pathway, #000000, #FFFFFF, roundrectangle, 584, 264, 132, 34
6           Bacterial secretion system, #000000, #FFFFFF, roundrectangle, 271, 361, 185, 34
                                                                 .attrs
1 1, path:hsa04810, map, http://www.kegg.jp/dbget-bin/www_bget?hsa04810
2 4, path:map02040, map, http://www.kegg.jp/dbget-bin/www_bget?map02040
3 5, path:hsa04520, map, http://www.kegg.jp/dbget-bin/www_bget?hsa04520
4 6, path:hsa04530, map, http://www.kegg.jp/dbget-bin/www_bget?hsa04530
5 7, path:hsa04620, map, http://www.kegg.jp/dbget-bin/www_bget?hsa04620
6 8, path:map03070, map, http://www.kegg.jp/dbget-bin/www_bget?map03070
```

 [1]: http://www.genome.jp/kegg-bin/show_pathway?hsa05130
 [2]: http://www.genome.jp/kegg-bin/show_pathway?hsa04210
 [3]: http://rest.kegg.jp/get/hsa05130/kgml