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
12 changes: 1 addition & 11 deletions PathLinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,7 @@ def applyEdgePenalty(net, weight):
"""
Applies a user-specified edge penalty to each edge. This weight
penalizes the score of every path by a factor equal to
(the number of edges in the path)^(this factor).

This was previously done in the logTransformEdgeWeights method
with a parameter weight=(sum of all edge weights). In the
"standard" PathLinker case, this was necessary to account for the
probability that is lost when edges are removed in
modifyGraphForKSP_removeEdges(), along with the probability lost
to zero degree nodes in the edge flux calculation.
(the number of edges in the path)^(weight).

:param net: NetworkX graph
:param weight: user-specified edge penalty
Expand All @@ -133,9 +126,6 @@ def logTransformEdgeWeights(net):
converting multiplicative values (where higher is better) to
additive costs (where lower is better).

Before the transformation, weights are normalized to sum to one,
supporting an interpretation as probabilities.

If the weights in the input graph correspond to probabilities,
shortest paths in the output graph are maximum-probability paths
in the input graph.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ method.

### What's included
* **run.py** An end-to-end implementation of the PathLinker
algorithm. Given a network, a set or receptors, a set of
transcription factors, and a value of *k*, PathLinker outputs a ranked list of edges composing the *k* highest scoring paths connecting any receptor to any transcription factor.
algorithm. Given a network, a set or receptors, and a set of
transcription factors, run outputs a ranked list of edges encountered in the *k* highest scoring paths connecting any receptor to any transcription factor.
* **PageRank.py** An implementation of the PageRank algorithm. This algorithm can be used as
a component of PathLinker, but it can also be run as a standalone tool.
Given a weighted, directed network, PageRank uses the power method to compute the
Expand All @@ -58,6 +58,10 @@ method.
computes the *k* shortest simple paths betwen a source and target
node. Here a path is *simple* if there are no repeated nodes in the
path.
* **PathLinker.py** Given a network, a set of receptors, a set of transcription
factors, and a value of *k*, PathLinker modifies the structure of the graph to
calculate and output the *k* high-scoring paths from any receptor protein to any
transcriptional regulator.

Run any of the programs with the --help option for full documentation.
The /example directory contains a sample usage of these programs.
Expand Down
14 changes: 6 additions & 8 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def main(args):
usage = '''
PathLinker.py [options] NETWORK NODE_TYPES
run.py [options] NETWORK NODE_TYPES
REQUIRED arguments:
NETWORK - A tab-delimited file with one directed interaction per
line. Each line should have at least 2 columns: tail, head. Edges
Expand Down Expand Up @@ -43,7 +43,7 @@ def main(args):
help='Run PathLinker on only the largest weakly connected component of the graph. May provide performance speedup.')

parser.add_option('', '--edge-penalty', type='float', default=1.0,\
help='Factor by which to divide every edge weight. The effect of this option is to penalize the score of every path by a factor equal to (the number of edges in the path)^(this factor). (default=1.0)')
help='Factor by which to divide every edge weight. The effect of this option is to penalize the score of every path by a factor equal to (the number of edges in the path)^(weight). (default=1.0)')

# Random Walk Group
group = OptionGroup(parser, 'Random Walk Options')
Expand Down Expand Up @@ -184,12 +184,10 @@ def main(args):

## Prepare the network to run KSP

# Remove improper edges from the sources and targets. This portion
# must be performed before the log transformation, so that the
# renormalization within accounts for the probability lost to the
# removed edges. These transformations are executed by default;
# to prevent them, use the opts.allow_mult_sources or opts.allow_mult_targets
# arguments.
# Remove improper edges from the sources and targets. If the user runs PageRank
# first, then this step will cause the total edge flux in the graph to be less than one.
# These transformations are executed by default to prevent them, use the
# opts.allow_mult_sources or opts.allow_mult_target arguments.
if not opts.allow_mult_sources:
pl.modifyGraphForKSP_removeEdgesToSources(net, sources)
if not opts.allow_mult_targets:
Expand Down