1 of 25

1

Instructor:

Welcome to BME 603/606�

Computational Methods for�Biological Modeling & Simulation

Assistant Professor of Biomedical Engineering�Affiliate, Data Science Institute�Affiliate, Biophysics Graduate Program�Affiliate, Center for Genomic Science Innovation�Affiliate, Wisconsin Institute for Translational Neuroengineering �University of Wisconsin-Madison

DHANANJAY ‘Jay’ BHASKAR

​

Course Website: https://bio-modeling-uw-madison-f26.github.io/

2 of 25

2

BME 603/606: Computational Methods for Biological Modeling & Simulation

Announcements / Reflection

  • First in-class quiz on Wed, Sept 30. It will be pen and paper, at the end of class, and you’ll have 30 mins.

​

  • Assignment 1 has been released. Due Oct 5, 11:59 pm.
    • Everyone should complete Problems 1-3.
    • Problems 4-5 for grad students only!

​

  • Colin now has a permanent location for office hours on Tue (2 - 3 pm): Wendt 410B

3 of 25

3

BME 603/606: Computational Methods for Biological Modeling & Simulation

Ordinary differential equations

Two-compartment oral absorption model:

With ka = 1.2 hr⁻¹ and ke = 0.15 hr⁻¹ over 24 hr.

• This is an Initial Value Problem (IVP)

� • General form: y'(t) = f(t, y), y(0) = y0 where y = [A, C]ᵀ

Closed forms exist for linear systems

Numerical solvers needed for nonlinear ODEs

4 of 25

4

BME 603/606: Computational Methods for Biological Modeling & Simulation

Forward Euler method

Discretize [a, b] into N steps of size h = (b-a)/N, with tᵢ = a + i·h

Taylor expansion to first order gives the update rule:

(explicit: right-hand side evaluated at the current step)

5 of 25

5

BME 603/606: Computational Methods for Biological Modeling & Simulation

Python implementation

import numpy as np

​

ka, ke = 1.2, 0.15; F_dose = 500.0

​

# ODE: y = [A, C], dy/dt = f(t, y)

def f(t, y):

A, C = y

return np.array([-ka*A, ka*A - ke*C])

​

T = 24.0; N = 2400 # h = 0.01 hr (stable: h << 2/ka ~ 1.67)

t = np.linspace(0, T, N+1)

h = t[1] - t[0]

y = np.zeros((N+1, 2)); y[0] = [F_dose, 0.0]

​

for i in range(N):

y[i+1] = y[i] + h * f(t[i], y[i]) # explicit update

6 of 25

6

BME 603/606: Computational Methods for Biological Modeling & Simulation

Backward Euler method

Evaluate the right-hand side at the NEXT time step:

(implicit: yᵢ₊₁ appears on both sides - must solve at each step)

Solving for yᵢ₊₁:

• Linear f: rearrange to solve a linear system at each step� • Nonlinear f: use Newton iteration at each step

Advantages over Forward Euler:

• Unconditionally stable: stable for any h (linear problems)� • Essential for stiff problems (Forward Euler needs tiny h)

7 of 25

7

BME 603/606: Computational Methods for Biological Modeling & Simulation

Backward Euler method

For y′ = J·y, Backward Euler becomes yᵢ₊₁ = (I − h·J)⁻¹ yᵢ

​

ka, ke = 1.2, 0.15; F_dose = 500.0

​

J = np.array([[-ka, 0.0],

[ ka, -ke ]]) # Jacobian of y' = J*y

​

# (I - h*J) y_{i+1} = y_i

T = 24.0; N = 240 # h = 0.1 hr

t = np.linspace(0, T, N+1)

h = t[1] - t[0]

M = np.eye(2) - h * J # factor once (J is constant)

y = np.zeros((N+1, 2)); y[0] = [F_dose, 0.0]

​

for i in range(N):

y[i+1] = np.linalg.solve(M, y[i])

8 of 25

8

BME 603/606: Computational Methods for Biological Modeling & Simulation

Runge-Kutta Methods

Classical RK4 (4th-order):

k_1 = h * f(t_i, y_i)

k_2 = h * f(t_i + h/2, y_i + k_1/2)

k_3 = h * f(t_i + h/2, y_i + k_2/2)

k_4 = h * f(t_i + h, y_i + k_3)

y_{i+1} = y_i + (1/6)(k_1 + 2k_2 + 2k_3 + k_4)

• Global error: O(h⁴) - much more accurate than Euler for same h� • Explicit and single-step

• Cost: 4 function evaluations per step

9 of 25

9

BME 603/606: Computational Methods for Biological Modeling & Simulation

Python: scipy.integrate.solve_ivp

from scipy.integrate import solve_ivp

import numpy as np

​

ka, ke = 1.2, 0.15; F_dose = 500.0

​

def f(t, y):

A, C = y

return [-ka*A, ka*A - ke*C]

​

sol = solve_ivp(f,

t_span = (0, 24), # integration interval

y0 = [F_dose, 0.0], # initial condition

method = 'RK45', # 4(5)-th order adaptive RK

t_eval = np.linspace(0, 24, 500), # output time points

rtol = 1e-6, atol = 1e-8, # tolerances

)

10 of 25

10

BME 603/606: Computational Methods for Biological Modeling & Simulation

Direct graph representation

Directed graph G = (V, E)

  • V = set of nodes (proteins, web pages, …)
  • E ⊆ V × V = set of directed edges ( j → i )

Adjacency matrix A (n × n, n = |V|)

​

11 of 25

11

BME 603/606: Computational Methods for Biological Modeling & Simulation

Example

1

2

3

4

j (source node)

A

1

2

3

4

1

0

0

0

1

2

1

0

0

0

3

1

0

0

0

4

0

1

1

0

i (dest.)

12 of 25

12

BME 603/606: Computational Methods for Biological Modeling & Simulation

Degree

�

  • Out-degree of node j: number of edges leaving j

​

​

​

  • In-degree of node i: number of edges entering i

​

​

13 of 25

13

BME 603/606: Computational Methods for Biological Modeling & Simulation

Node importance

Not all nodes in a network are equally important.

Examples:

  • Web search: which pages best answer a query?
  • Social networks: who are the most influential users?
  • Citation networks: which papers are most impactful?
  • Biological networks: which proteins are functionally essential?

​

14 of 25

14

BME 603/606: Computational Methods for Biological Modeling & Simulation

Node importance

Why not just use degree?

​

  • Degree counts connections but ignores neighbor quality
  • A low-degree node connected to highly-connected nodes may outrank a high-degree node in a peripheral cluster

PageRank provides a recursive, globally-informed importance score.

15 of 25

15

BME 603/606: Computational Methods for Biological Modeling & Simulation

The Random Surfer Model

Original motivation: ranking web pages (Page & Brin, 1998).

Model definition

  • A random surfer starts on an arbitrary node
  • At each step: with probability α, follows a uniformly random outgoing edge
  • With probability (1 − α): teleports to a uniformly random node in V
  • Repeats indefinitely

PageRank = stationary distribution

  • ri = long-run fraction of time the surfer visits node i

16 of 25

16

BME 603/606: Computational Methods for Biological Modeling & Simulation

PageRank: Mathematical formulation

The PageRank of node i is the sum of contributions from all nodes j that link to i:

​

​

​

Matrix form

Define the column-stochastic transition matrix M:

Then the PageRank vector r satisfies the fixed-point eqn:

17 of 25

17

BME 603/606: Computational Methods for Biological Modeling & Simulation

PageRank: Mathematical formulation

r is the principal eigenvector of M with eigenvalue λ = 1.

​

Each column of M sums to 1 → therefore, M is a (column-)stochastic matrix.

Markov chain interpretation

  • Entry Mij = probability of moving from node j to node i
  • Stationary distribution π satisfies π = Mπ
  • PageRank is this stationary distribution

18 of 25

18

BME 603/606: Computational Methods for Biological Modeling & Simulation

Building the transition matrix

  • Start from the adjacency matrix A
  • Normalize each column by the out-degree:�
  • Each column sums to 1 → M is column-stochastic

Problem: dangling nodes

  • Node j with djout = 0 has no outgoing edges
  • Column j of M is all zeros - not a valid probability distribution
  • Random walker gets permanently stuck at dangling nodes

​

We must handle dangling nodes before computing PageRank.

19 of 25

19

BME 603/606: Computational Methods for Biological Modeling & Simulation

Handling dangling nodes

Dangling nodes violate column-stochasticity.

​

Fix: redistribute dangling-node rank uniformly

For each dangling node j, replace its zero column with 1/n:

�

The fix assigns them a small, uniform baseline PageRank contribution

Let d ∈ {0,1}n be the dangling-node indicator. Then:

�

20 of 25

20

BME 603/606: Computational Methods for Biological Modeling & Simulation

Google matrix

Remaining problems with pure random walk

  • Disconnected graphs: no unique stationary distribution
  • Periodic or absorbing components: random walk may fail to converge

Solution: teleportation with damping factor α

​

Construct the Google matrix:

​

​

The full PageRank equation becomes:

The original paper used: α = 0.85 (still used today)

21 of 25

21

BME 603/606: Computational Methods for Biological Modeling & Simulation

PageRank as an eigenvalue problem

The PageRank vector r is the solution to:

​

r is the dominant eigenvector of the Google matrix G (eigenvalue λ₁ = 1)

​

Perron–Frobenius theorem

  • G is a positive, column-stochastic matrix (all entries > 0 when α < 1)
  • Guarantees: unique positive dominant eigenvector
  • All other eigenvalues satisfy |λk| < 1 for k ≥ 2

​

22 of 25

22

BME 603/606: Computational Methods for Biological Modeling & Simulation

Power iteration algorithm

1. Initialize:�

  1. Iterate until convergence:

​

  • Stop when ‖r(k+1) − r(k)‖₁ < ε (e.g., ε = 10⁻⁶)

​

4. Return r(k+1) as the PageRank vector

​

23 of 25

23

BME 603/606: Computational Methods for Biological Modeling & Simulation

Python Implementation

def pagerank(A, alpha=0.85, tol=1e-6, max_iter=100):

"""PageRank via power iteration."""

n = A.shape[0]

# Build column-stochastic matrix; handle dangling nodes

d = A.sum(axis=0) # out-degrees

dangling = (d == 0)

d[dangling] = 1 # avoid divide-by-zero

M = A / d[np.newaxis, :] # normalize columns

M[:, dangling] = 1.0 / n # uniform teleport for dangling

# Power iteration

r = np.ones(n) / n # uniform initialization

for _ in range(max_iter):

r_new = alpha * M @ r + (1 - alpha) / n

if np.linalg.norm(r_new - r, 1) < tol:

return r_new

r = r_new

return r # return after max_iter

24 of 25

24

BME 603/606: Computational Methods for Biological Modeling & Simulation

Application: disease-gene prioritization

Motivation

  • Given a disease, identify candidate causal genes using a PPI network
  • Seed proteins: a small set of known disease-associated genes

Method: network propagation (Vanunu et al., 2010)

Initialize a score vector from the seed set S:

​

​

Propagate scores through the network iteratively:

​

​

Rank all genes/proteins by the converged score.

Vanunu et al., PLoS Comput Biol. 2010�Pham et al., Comput Struct Biotechnol J. 2025

25 of 25

25

BME 603/606: Computational Methods for Biological Modeling & Simulation

In-Class Exercises

Please ask Colin to mark you for completion before end of class.

Course Website: https://bio-modeling-uw-madison-f26.github.io/