Skip to content

Commit 304fd73

Browse files
committed
updated documentation and small usability changes
1 parent a507dbf commit 304fd73

File tree

5 files changed

+45
-60
lines changed

5 files changed

+45
-60
lines changed

README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,52 @@
22

33
Requires modules `networkx`, `numpy`, `scikit-learn`, and `argparse`.
44

5-
For a description of the Random Walk with Restart (RWR) algorithm, see the paper by Kohler et al. at [http://www.sciencedirect.com/science/article/pii/S0002929708001729](http://www.sciencedirect.com/science/article/pii/S0002929708001729).
5+
For a description of the Random Walk with Restart (RWR) algorithm, which
6+
this module implements, see the paper by Kohler et al. at
7+
[http://www.sciencedirect.com/science/article/pii/S0002929708001729](http://www.sciencedirect.com/science/article/pii/S0002929708001729).
68

7-
This module was initially created to run node removal experiments with two separate graphs, but the code in matrix\_main.py can easily be used to run the standard RWR algorithm on a single graph of any sort.
9+
## Overview
10+
11+
This module can be used to run two types of experiments:
12+
13+
- A standard random walk with restart from a set of seed nodes, as in the
14+
Kohler et al. paper referenced above.
15+
- A random walk with restart, from a set of seed nodes, on a "tissue-specific"
16+
network. The network is defined by a "low list" of nodes (i.e. genes) that
17+
are not expressed in the tissue of interest. This is described in more
18+
detail in our paper, which is currently in review.
19+
20+
Examples of both experiments are described in more detail below.
821

922
## Running a random walk
1023

11-
The matrix\_main.py script can be used to run a random walk. The syntax looks like:
24+
The run\_walker.py script can be used to run a random walk. The syntax looks like:
1225

13-
`python matrix_main.py <input_graph> <seed> [-l <low_list>] [-r <remove_nodes>]`
26+
`python run_walker.py <input_graph> <seed> [-l <low_list>] [-r <remove_nodes>]`
1427

1528
where the input graph is in edge list format, the seed is a list of nodes to
1629
start the random walk at, the optional low list is a list of nodes to down-weight
17-
for node removal experiments (as in the tissue-specific networks paper), and the
18-
optional node removal list is a list of nodes to remove completely from the graph.
30+
for node removal experiments, and the optional node removal list is a list of nodes
31+
to remove completely from the network.
32+
33+
The script will write a tab-separated list of nodes and probabilities to stdout,
34+
where the probability number represents the probability that a random walk
35+
starting at the seed nodes will terminate at the given node.
36+
37+
For more detail about the expected arguments, run `python run_walker.py -h`.
38+
39+
## Examples
40+
41+
To help you get up and running, a few simple examples are included in the `testdata`
42+
folder. To run a standard random walk experiment on a simple example network, run
43+
this command:
44+
45+
`python run_walker.py testdata/test_network.ppi testdata/test_seed.txt`
46+
47+
Or, to run a "tissue-specific" random walk experiment using the same
48+
simple example network, try:
1949

20-
More thorough documentation to come.
50+
`python run_walker.py testdata/test_network.ppi testdata/test_seed.txt -l testdata/test_low_list.txt`
2151

2252
## Using the module
2353

runSH.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

run_walker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main(argv):
7373

7474
# run the experiments, and write a rank list to stdout
7575
wk = Walker(opts.input_graph, opts.low_list, remove_list)
76-
wk.run_exp(seed_list, opts.restart_prob,
76+
wk.run_exp(seed_list, opts.restart_prob,
7777
opts.original_graph_prob, node_list)
7878

7979

testdata/test_low_list.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
0 1.5
2+
1 2.0
3+
2 NA
4+
3 1.0
5+
4 1.8

walker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _generate_rank_list(self, p_t):
9898

9999
def _calculate_next_p(self, p_t, p_0):
100100
""" Calculate the next probability vector. """
101-
if self.tsg_matrix:
101+
if self.tsg_matrix is not None:
102102
no_epsilon = np.squeeze(np.asarray(np.dot(self.tsg_matrix, p_t) *
103103
(1 - self.og_prob)))
104104
epsilon = np.squeeze(np.asarray(np.dot(self.og_matrix, p_t) *
@@ -151,7 +151,7 @@ def _build_matrices(self, original_ppi, low_list, remove_nodes):
151151
og_not_normalized, low_list)
152152
self.tsg_matrix = self._normalize_cols(tsg_not_normalized)
153153
else:
154-
self.tsg_matrix = []
154+
self.tsg_matrix = None
155155

156156

157157
def _tsg_matrix(self, original_graph, og_matrix, low_list):

0 commit comments

Comments
 (0)