You can use graphite package

For example if you want to know how many nodes and edges are in the first reactome pathway:

```
#load package
library(graphite)
require(igraph)
#get all reactome pathways for human
reactomedata=pathways(species = 'hsapiens','reactome')
#information about the first pathway in the list
reactomedata[[1]]
# number of nodes
length(nodes(reactomedata[[1]]))
# number of edges
dim(graphite::edges(reactomedata[[1]]))[1]
```

You can also create an igraph to calculate more topological indexes:

```
# builds a graphNEL
g <- pathwayGraph(reactomedata[[1]])
# create an igraph from the graphNEL object
g2=igraph.from.graphNEL(g, name = TRUE, weight = TRUE, unlist.attrs = TRUE)
# calculate diameter
diameter(g2)
# calculate transitivity/clustering coefficient
transitivity(g2)
# calculate outdegree
degree(g2,mode = 'out')
# calculate indegree
degree(g2,mode = 'in')
```

Obviously the topological indexes will change greatly if you have a directed edges, if you want to remove self loops and so on.

•

link
modified 6 months ago
by
RamRS ♦ **27k**
•
written
4.5 years ago by
5utr • **350**
Hi vassialk,

I am interested in hoe many links and nodes a given pathway contains. This will be my measure of "length".

10Just a hint: what you measure is usually called the pathway/network size (i.e., number of vertices, number of edges). Because pathways often have many connections (depends on the pathway and the database) and may contain circles, etc. some people prefer to use other metrics like the diameter.

1.2kThank you very much for that info. Do you have any idea how I can calculate these parameters?

10Yepp, check Wikipedia: calculate all shortest path between each pair of nodes (hint: Floyd's algorithm), then get the length of each shortest path, the maximum length is the diameter...

PS: I am quite confident, that there is already some graph package available on CRAN/BioConductor that implements the algorithm and/or diameter calculation.

27k• written 4.5 years ago by Manuel Landesfeind •1.2kSo Reactome allows me to directly extract these informations (number of in-nodes, out-nodes, links, edges...) from the results they provide in R?

10I don't know! I rarely use Reactome and have never used R for graph theory.

I just wanted to make you aware of the other graph/network metrics...

1.2k