Skip to content

IlyaLab/BNMPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BNMPy: Boolean network modeling and optimization

A Python library for Boolean Network (BN) and Probabilistic Boolean Network (PBN) modeling, simulation, optimization, and analysis with applications in systems biology.

See https://ilyalab.github.io/BNMPy/ for detailed documentation.

Installation

To install, run pip install -e . in this directory.

Core functionalities

1. Boolean network

Basic operations

  • Network loading: Load networks from text files, SBML files, or string representations
  • Network construction: Build networks from connectivity matrices and Boolean functions
  • Network manipulation: Knockout/knockdown specific nodes, rename nodes, merge networks
  • Network visualization: Interactive network visualizations with igraph and matplotlib

Simulation

  • Deterministic update: Synchronous and asynchronous update schemes
  • Stochastic update: Add noise to represent biological uncertainty
  • Attractor analysis: Find steady states and limit cycles

2. Probabilistic Boolean network

Basic operations are similar to BNs.

  • Stochastic Simulation: Run Monte Carlo simulations over steps
  • Attractor analysis: Find steady states (state distributions) via Monte Carlo or Two-state Markov Chain (TSMC) methods

3. Knowledge Graph (KG) augmentation

BNMPy can build and extend models using the SIGNOR knowledge graph.

  • Build KG-derived BN: Build a Boolean Network (BN) directly from a Knowledge Graph (KG)
  • Merge models: Merge an original BN with a KG-derived model into either a BN or a PBN
  • Targeted extension to PBN: Extend an existing BN by adding nodes and rules informed by KG
  • Phenotype scoring from KG paths: Compute phenotype scores using gene-phenotype relations from KG

4. PBN Optimization

Parameter optimization

  • Objective function: MSE-based optimization for experimental data fitting
  • Optimization algorithms: Differential evolution, particle swarm optimization
  • Discrete optimization: Support for discrete parameter spaces
  • Result Evaluation: Compare predictions with experimental observations
  • Model compression: Simplify models while preserving behavior

Examples

Tutorials:

Applications:

Other utilities:

Quick Start

sys.path.append('./src')
import BNMPy

# Load a network (auto-detects BN vs PBN, file vs string)
network_string = """
A = A
B = C
C = !E
D = A | B
E = C & D
F = !A & B
"""
# initial state (array or dictionary)
x0 = [0, 0, 0, 0, 0, 0]  # array: order matches gene order in string
# or
x0 = {'A': 0, 'B': 1, 'C': 0, 'D': 0, 'E': 0, 'F': 0}  # dict: keys are gene names
network = BNMPy.load_network(network_string, initial_state=x0)

# Visualize the network
BNMPy.vis_network(network, output_html="SimpleBN.html", interactive=True)

# Simulate with noise = 0.05 for 10 steps
network.update_noise(p=0.05, iterations=10)

# Calculate steady states
calc = BNMPy.SteadyStateCalculator(network)
steady_state = calc.compute_steady_state(n_runs=20,n_steps=10000)

Note that when assigning initial states or obtaining steady states, gene order matches their order in the network string/file, and can be obtained by calling network.nodeDict. Currently it support both array input and dictionary input (genes not specified default to 0.)

Documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5