Skip to content

Commit 6b66e0c

Browse files
committed
updated ST_RWR documentation
1 parent a096b54 commit 6b66e0c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

docker-wrappers/ST_RWR/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Notes
2+
The random walk with restarts algorithm requires a directed input network. However, the algorithm in its current form will accept an undirected input network and interpret it as a directed network. The resulting output from an undirected network does not accuratly represent directionality.
3+
4+
5+
## Testing
6+
Test code is located in `test/ST_RWR`.
7+
The `input` subdirectory contains test files `strwr-network.txt`, `strwr-sources.txt`, and `strwr-targets.txt`
8+
The Docker wrapper can be tested with `pytest`.

docker-wrappers/ST_RWR/ST_RWR.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,41 @@ def RWR(network_file: Path, source_nodes_file: Path,target_nodes_file: Path, alp
3434
# Create the parent directories for the output file if needed
3535
output_file.parent.mkdir(parents=True, exist_ok=True)
3636

37+
# Read in network file
3738
edgelist = []
3839
with open(network_file) as file:
3940
for line in file:
4041
edge = line.split('|')
4142
edge[1] = edge[1].strip('\n')
4243
edgelist.append(edge)
43-
44+
45+
# Read in sources file
4446
sources = []
4547
with open(source_nodes_file) as source_nodes:
4648
for line in source_nodes:
4749
source = line.split('\t')
4850
sources.append(source[0].strip('\n'))
4951

52+
# Read in targets file
5053
targets = []
5154
with open(target_nodes_file) as target_nodes:
5255
for line in target_nodes:
5356
target = line.split('\t')
5457
targets.append(target[0].strip('\n'))
5558

59+
# Create directed graph from input network
5660
source_graph = nx.DiGraph(edgelist)
61+
62+
# Create reversed graph to run pagerank on targets
5763
target_graph = source_graph.reverse(copy= True)
5864

65+
# Run pagegrank algorithm on source and target graph seperatly
5966
source_scores = nx.pagerank(source_graph,personalization={n:1 for n in sources},alpha=alpha)
6067
target_scores = nx.pagerank(target_graph,personalization={n:1 for n in targets},alpha=alpha)
6168

62-
#While merge_scores currently returns the average of the two scores, alternate methods such as taking
63-
#the minimum of the two scores may be used
69+
# Merge scores from source and target pagerank runs
70+
# While merge_scores currently returns the average of the two scores, alternate methods such as taking
71+
# the minimum of the two scores may be used
6472
total_scores = merge_scores(source_scores,target_scores)
6573

6674
with output_file.open('w') as output_f:

0 commit comments

Comments
 (0)