rw — random walk
Random-walk simulation over the network.
- bobaT.rw.random_walks(attractor_dict, rules, regulators_dict, nodes, save_dir, radius=2, perturbations=False, iters=1000, max_steps=500, stability=False, reach_or_leave='leave', random_start=0, on_nodes=[], off_nodes=[], basin=0, overwrite_walks=True, overwrite_perturbations=True, verbose=2)[source]
Wrapper function to perform random walks.
- Parameters:
attractor_dict (dictionary) – Dictionary of attractors used to get to steady states
rules (dictionary) – Dictionary of probabilistic rules for the regulators
regulators_dict (dictionary) – Dictionary of relevant regulators
nodes (list) – List of nodes in the transcription factor network
save_dir (string or path-like object) – Path/directory to save output
radius (int or list) – Single or multiple radii values for random walks
perturbations (bool) – Whether to perform random walks with perturbations or not
iters (int) – Number of iterations of random walks
max_steps (int) – Max number of steps to take in random walks
stability (bool) – Whether to perform stability testing with multiple radii or not
reach_or_leave (string) – Define what type of random walk to perform
random_start (int) – Whether to perform walks with a random list of start states. If >0, run that many random starts
on_nodes (list) – Define ON nodes of a perturbation
off_nodes (list) – Define OFF nodes of a perturbation
basin (int) – Define a basin for random_walk_until_reach_basin
overwrite_walks (bool, default True) – If False and walks/{start_idx} already exists, do not overwrite the results. Instead move on to the next start_idx. Note that if this is set to False and walks/{start_idx} already exists, the code skips all random walks for this start_idx (including any perturbations and stability testing)
overwrite_perturbations (bool, default = True) – If False and perturbations/{start_idx} already exists, do not overwrite the results. Instead move on to the next start_idx.
- Return type:
None
- bobaT.rw.random_walks_parallel(attractor_dict, rules, regulators_dict, nodes, save_dir, radius=2, perturbations=False, iters=1000, max_steps=500, stability=False, reach_or_leave='leave', random_start=0, on_nodes=[], off_nodes=[], basin=0, overwrite_walks=True, overwrite_perturbations=True, cpu_usage=0.5, cpus=None, verbose=1)[source]
Wrapper function to perform random walks.
- Parameters:
attractor_dict (dictionary) – Dictionary of attractors used to get to steady states
rules (dictionary) – Dictionary of probabilistic rules for the regulators
regulators_dict (dictionary) – Dictionary of relevant regulators
nodes (list) – List of nodes in the transcription factor network
save_dir (string or path-like object) – Path/directory to save output
radius (int or list) – Single or multiple radii values for random walks
perturbations (bool) – Whether to perform random walks with perturbations or not
iters (int) – Number of iterations of random walks
max_steps (int) – Max number of steps to take in random walks
stability (bool) – Whether to perform stability testing with multiple radii or not
reach_or_leave (string) – Define what type of random walk to perform
random_start (int) – Whether to perform walks with a random list of start states. If >0, run that many random starts
on_nodes (list) – Define ON nodes of a perturbation
off_nodes (list) – Define OFF nodes of a perturbation
basin (int) – Define a basin for random_walk_until_reach_basin
overwrite_walks (bool, default True) – If False and walks/{start_idx} already exists, do not overwrite the results. Instead move on to the next start_idx. Note that if this is set to False and walks/{start_idx} already exists, the code skips all random walks for this start_idx (including any perturbations and stability testing)
overwrite_perturbations (bool, default = True) – If False and perturbations/{start_idx} already exists, do not overwrite the results. Instead move on to the next start_idx.
- Return type:
None
- bobaT.rw.simple_random_walk(stg, edge_weights, start_idx, steps)[source]
Perform random walk on a state transition graph with known edge weights.
Paramters
- stggraph tools Graph() object
State transition graph
- start_idxint
Index of the vertext to start the walk
- stepsint
Walk length
- returns:
verts – Path of vertices taken during random walk
- rtype:
list
- bobaT.rw.random_walk_until_leave_basin(start_state, rules, regulators_dict, nodes, radius=2, max_steps=10000, on_nodes=[], off_nodes=[])[source]
- Parameters:
start_state (int) – Index of attractor to start walk from
rules (dictionary) – Dictionary of probabilistic rules for the regulators
regulators_dict (dictionary) – Dictionary of relevant regulators
nodes (list) – List of nodes in the transcription factor network
radius (int) – Radius to stay within during walk
max_steps (int) – Max number of steps to take in random walks
on_nodes (list) – Define ON nodes of a perturbation
off_nodes (list) – Define OFF nodes of a perturbation
- Returns:
walk (list) – Path of vertices taken during random walk
Counter(walk) – Histogram of walk
flipped_nodes (list) – Transcription factors that flipped during walk
distances (list) – Starting state to next step in walk
- bobaT.rw.random_walk_until_reach_basin(start_state, rules, regulators_dict, nodes, radius=2, max_steps=10000, on_nodes=[], off_nodes=[], basin=1)[source]
- Parameters:
start_state –
.
rules (dictionary) – Dictionary of probabilistic rules for the regulators
regulators_dict (dictionary) – Dictionary of relevant regulators
nodes (list) – List of nodes in the transcription factor network
radius (int) – Radius to stay within during walk
max_steps (int) – Max number of steps to take in random walks
on_nodes (list) – Define ON nodes of a perturbation
off_nodes (list) – Define OFF nodes of a perturbation
basin (int or list) – List of attractors to reach (or a single attractor) by state index (integer)
- Returns:
walk (list) – Path of vertices taken during random walk
Counter(walk)
flipped_nodes (list)
distances (list) – All distances to basin
- bobaT.rw.long_random_walks(starting_attractors, attractor_dict, rules, regulators_dict, nodes, save_dir, on_nodes=[], off_nodes=[], max_steps=2000, iters=100, overwrite_walks=False)[source]
Alternative way to do random walks (until reach basin). Instead of looking for a specific basin, keep walking some length of steps. Can be used for visualizing effects of perturbations using bb.plot.plot_random_walks.
- Parameters:
starting_attractors (list) – name of the attractors to start the walk from (key in attractor_dict)
attractor_dict (dict()) – Dictionary of attractors
rules (dict()) – Rules from BooleaBayes rule fitting
regulators_dict (dict()) – Dictionary of regulators from rule fitting
nodes – list of nodes in the network
save_dir (str) – Directory to save output
on_nodes (list, optional) – activating perturbations to run simulations for, defaults to []
off_nodes (list, optional) – knockdown perturbations to run simulations for, defaults to []
max_steps (int, optional) – Length of random walks, defaults to 2000
iters (int, optional) – Number of iterations to run, defaults to 100
overwrite_walks (bool, optional) – If false, don’t rewrite walks if the folder already exists, defaults to False