Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ jobs:
with:
path: docker-wrappers/ResponseNet
container: reedcompbio/responsenet
build-and-remove-rwr:
uses: "./.github/workflows/build-and-remove-template.yml"
with:
path: docker-wrappers/RWR
container: reedcompbio/rwr
build-and-remove-strwr:
uses: "./.github/workflows/build-and-remove-template.yml"
with:
path: docker-wrappers/ST_RWR
container: reedcompbio/st-rwr
build-and-remove-spras:
uses: "./.github/workflows/build-and-remove-template.yml"
with:
Expand Down
6 changes: 4 additions & 2 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,17 @@ algorithms:
params:
include: true
run1:
alpha: [0.85]
alpha: [0.85, 0.9]
threshold: [100, 200]
max_iters: 10000

- name: "rwr"
params:
include: true
run1:
alpha: [0.85]
alpha: [0.85, 0.9]
threshold: [100, 200]
max_iters: 10000

- name: "bowtiebuilder"
params:
Expand Down
2 changes: 1 addition & 1 deletion docker-wrappers/RWR/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ RUN pip install networkx==2.8.8 numpy==1.26.4 scipy==1.15.2

WORKDIR /RWR

RUN wget https://raw.githubusercontent.com/Reed-CompBio/rwr/9de14ac239df906f5ed0c19b9a42b83f5aa6f296/RWR.py
RUN wget https://raw.githubusercontent.com/Reed-CompBio/rwr/bb8d61069376afa7ff1acb47f47b34589f025d6f/RWR.py
2 changes: 1 addition & 1 deletion docker-wrappers/ST_RWR/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ RUN pip install networkx==2.8.8 numpy==1.26.4 scipy==1.15.2

WORKDIR /ST_RWR

RUN wget https://raw.githubusercontent.com/Reed-CompBio/rwr/9de14ac239df906f5ed0c19b9a42b83f5aa6f296/ST_RWR.py
RUN wget https://raw.githubusercontent.com/Reed-CompBio/rwr/bb8d61069376afa7ff1acb47f47b34589f025d6f/ST_RWR.py
2 changes: 1 addition & 1 deletion docker-wrappers/ST_RWR/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Source-Targets Random Walk with Restarts

A Docker image for [ST-RWR](https://github.com/Reed-CompBio/rwr) that is available on [DockerHub](https://hub.docker.com/repository/docker/reedcompbio/st_rwr).
A Docker image for [ST-RWR](https://github.com/Reed-CompBio/rwr) that is available on [DockerHub](https://hub.docker.com/repository/docker/reedcompbio/st-rwr).

## Notes
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 accurately represent directionality.
Expand Down
8 changes: 5 additions & 3 deletions spras/rwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_inputs(data, filename_map):
edges.to_csv(filename_map['network'],sep='|',index=False,columns=['Interactor1','Interactor2'],header=False)

@staticmethod
def run(network=None, nodes=None, alpha=None, output_file=None, container_framework="docker", threshold=None):
def run(network=None, nodes=None, alpha=None, max_iter=None, output_file=None, container_framework="docker", threshold=None):
if not nodes:
raise ValueError('Required RWR arguments are missing')

Expand Down Expand Up @@ -67,11 +67,13 @@ def run(network=None, nodes=None, alpha=None, output_file=None, container_framew
'--nodes', nodes_file,
'--output', mapped_out_prefix]

# Add alpha as an optional argument
# Add optional arguments
if alpha is not None:
command.extend(['--alpha', str(alpha)])
if max_iter is not None:
command.extend(['--max-iter', str(max_iter)])

container_suffix = 'rwr:v1'
container_suffix = 'rwr:v2'
run_container_and_log(
"RandomWalk with Restart",
container_framework,
Expand Down
8 changes: 5 additions & 3 deletions spras/strwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def generate_inputs(data, filename_map):
edges.to_csv(filename_map['network'],sep='|',index=False,columns=['Interactor1','Interactor2'],header=False)

@staticmethod
def run(network=None, sources=None, targets=None, alpha=None, output_file=None, container_framework="docker", threshold=None):
def run(network=None, sources=None, targets=None, alpha=None, max_iter=None, output_file=None, container_framework="docker", threshold=None):
if not sources or not targets or not network or not output_file:
raise ValueError('Required local_neighborhood arguments are missing')

Expand Down Expand Up @@ -72,11 +72,13 @@ def run(network=None, sources=None, targets=None, alpha=None, output_file=None,
'--targets', target_file,
'--output', mapped_out_prefix]

# Add alpha as an optional argument
# Add optional arguments
if alpha is not None:
command.extend(['--alpha', str(alpha)])
if max_iter is not None:
command.extend(['--max-iter', str(max_iter)])

container_suffix = 'st-rwr:v1'
container_suffix = 'st-rwr:v2'
run_container_and_log(
"Source-Target RandomWalk with Restart",
container_framework,
Expand Down
6 changes: 6 additions & 0 deletions test/RWR/expected_output/rwr-output-high.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Node Score
C 0.4164497171247451
E 0.1978133496120127
B 0.1978133496120127
D 0.18792358365122955
A 0.0
15 changes: 15 additions & 0 deletions test/RWR/test_RWR.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ def test_rwr(self):
expected_file = Path(TEST_DIR, 'expected_output', 'rwr-output.txt')
assert cmp(OUT_FILE, expected_file, shallow=False), 'Output file does not match expected output file'

"""
Run the RWR algorithm on the example input files and check the output matches the expected output,
specifying a higher max_iter and alpha than usual
"""
def test_rwr_optional(self):
OUT_FILE.unlink(missing_ok=True)
RWR.run(network=Path(TEST_DIR, 'input', 'rwr-network.txt'),
nodes=Path(TEST_DIR, 'input','rwr-nodes.txt'),
alpha=0.95,
max_iter=10000,
output_file=OUT_FILE)
assert OUT_FILE.exists(), 'Output file was not written'
expected_file = Path(TEST_DIR, 'expected_output', 'rwr-output-high.txt')
assert cmp(OUT_FILE, expected_file, shallow=False), 'Output file does not match expected output file'

"""
Run the RWR algorithm with a missing input file
"""
Expand Down
6 changes: 6 additions & 0 deletions test/ST_RWR/expected_output/strwr-output-high.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Node Score
A 0.321229089672757
C 0.24396106359378425
E 0.21206998743770886
B 0.1142253832416095
D 0.10851447605414039
16 changes: 16 additions & 0 deletions test/ST_RWR/test_STRWR.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ def test_strwr(self):
expected_file = Path(TEST_DIR, 'expected_output', 'strwr-output.txt')
assert cmp(OUT_FILE, expected_file, shallow=False), 'Output file does not match expected output file'

"""
Run the RWR algorithm on the example input files and check the output matches the expected output,
specifying a higher max_iter and alpha than usual
"""
def test_strwr_optional(self):
OUT_FILE.unlink(missing_ok=True)
ST_RWR.run(network=Path(TEST_DIR, 'input', 'strwr-network.txt'),
sources=Path(TEST_DIR, 'input', 'strwr-sources.txt'),
targets=Path(TEST_DIR, 'input','strwr-targets.txt'),
alpha=0.95,
max_iter=10000,
output_file=OUT_FILE)
assert OUT_FILE.exists(), 'Output file was not written'
expected_file = Path(TEST_DIR, 'expected_output', 'strwr-output-high.txt')
assert cmp(OUT_FILE, expected_file, shallow=False), 'Output file does not match expected output file'

"""
Run the ST_RWR algorithm with a missing input file
"""
Expand Down
Loading