1 of 33

1

Today’s Topic:�Modeling Chemical Reactions

Welcome to BME 603/606�

Computational Methods for�Biological Modeling & Simulation

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

2 of 33

2

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

Announcements

​

  • Quiz 2 grades have been released on Canvas.
    • Congrats - Nithila, Tarun, Shlok, and Jenny for perfect score in Qs 1-3!
    • Congrats - Matthew, Yuqing, and Saivarshini for perfect score in Qs 4-5!
  • Project proposal due on Nov 9
    • Start forming teams now!

3 of 33

3

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

Reflections

Q: Could you also use some sort of normalization function to normalize the derivatives in a way that solves the vanishing/exploding gradient problem?

​

A: This is what Backward Gradient Normalization (BGN) does! However, it is tricky to implement – it must act like an identity function during the forward pass and normalize gradients during backprop. It is more common to normalize inputs into the activation function during the forward pass (BatchNorm and LayerNorm), which also tends to stabilize the gradients during backprop. Especially useful when saturating activations (sigmoid and tanh) are being used.

4 of 33

4

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

Reflections

Q: Can you have attention weights for both individual words as well as groups of words (so one as well as multiple tokens) together for interpretability?

A: Yes, this is the idea behind multi-token attention!

Q: What is the key gain we have from bidirectional RNN to transformer?

A: Long-range dependencies are easier to model. Better performance, all tokens are processed in parallel. RNNs are sequential by design.

5 of 33

5

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

Reflections

Q: How common is triangle attention?

A: Firstly, triangle attention can refer to an upper triangular or lower triangular attention matrix, also sometimes called autoregressive or causal self-attention.

​

In the case of AlphaFold however, as we discussed in the last lecture, triangle attention refers to higher-order triplet attention, which is only really used in structural biology (molecules and proteins). We are just beginning to see it being used in a few other areas...it is computationally expensive!

6 of 33

6

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

Reflections

Q: What can cause the hallucinations seen in some language models? Is it an error with these attention values?

A: In long sequences attention can be spread across too many tokens, which can dilute context. Check out the Longformer architecture!

​

However, hallucinations are not caused by accumulation of errors. They result from broader statistical, architectural and training choices.

7 of 33

7

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

Quiz Performance

8 of 33

8

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

Quiz Performance

9 of 33

9

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

Today’s Agenda

Every molecule in a cell has a concentration that changes over time.�

�Our goal: write an equation that tells us how fast each concentration is changing, and why.�

�We will describe each biological process - synthesis, degradation, binding, phosphorylation - as a rate term in a differential equation.

10 of 33

10

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

Notation

[X] = concentration of species X (units: µM, nM, or molecules/cell)��d[X]/dt = rate of change of [X] with respect to time� positive → [X] is increasing� negative → [X] is decreasing��k = rate constant (always a positive number; units depend on reaction)

11 of 33

11

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

Constant Production

Some molecules are made at a steady, fixed rate.

​

Examples:

a gene that is always "on" (constitutive expression)

a metabolite supplied at constant rate.

​

This contributes a constant positive term to the equation:

Units of kₛ : concentration / time (e.g., nM/s)

12 of 33

12

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

First-Order Decay

Proteins and mRNAs are continuously degraded.

The more there is, the faster it disappears.

​

Each molecule has a constant probability per unit time of being degraded.

​

This gives a negative term proportional to the current amount:

Units of kᵈ : 1/time (e.g., s⁻¹)

13 of 33

13

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

First-Order Decay

If a molecule only degrades (no production), the solution is an exponential decline:

Half-life (definition): the time for [X] to drop to 50% of its starting value:

14 of 33

14

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

Combining production and decay

Most real molecules are both produced and degraded.

Simply add both terms - one positive, one negative:

​

(+) for each process that makes X

(−) for each process that removes X

15 of 33

15

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

Steady state

A steady state is reached when d[X]/dt = 0

​

Biologically, at equilibrium, the rate of production is equal to the rate of degradation.

​

Set the right-hand side to zero and solve:

16 of 33

16

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

The Law of Mass Action

This is the fundamental principle governing elementary chemical reactions:�

The rate of an elementary reaction is proportional to the product of the concentrations of its reactants.

​

Why? Because the rate depends on how often molecules collide, which is proportional to how many of each there are.

​

This gives us a systematic recipe for converting any reaction scheme into a differential equation.

17 of 33

17

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

Unimolecular Reactions: A → B

One molecule spontaneously converts to another.

Notice: d[A]/dt + d[B]/dt = 0 → [A] + [B] = constant (conservation)

​

​

e.g. protein conformational change, mRNA degradation, radioactive decay.

18 of 33

18

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

Bimolecular Reactions: A + B → C

Two molecules collide and combine.

Examples: protein-protein binding, kinase meeting its substrate, ligand docking to receptor.

​

The nonlinear term [A][B] is due to law of mass action.

19 of 33

19

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

Reversible Reactions: A ⇌ B

Most biological reactions go in both directions.

Forward rate constant kf , reverse rate constant kr

At equilibrium (d/dt = 0):

​

[A]eq / [B]eq = kr / kf = Kd (the dissociation constant)

​

A small Kd means tight binding: the forward reaction is favored.

20 of 33

20

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

Activation

A signaling molecule A switches protein X from inactive to active.

​

Let X denote the fraction of X that is active. Then (1 − X) is inactive.

​

A can only activate X if X is currently inactive - so the rate depends on both [A] and (1 − X):

21 of 33

21

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

Inactivation

A separate signal B drives active X back to its inactive state.

​

Inactivation can only occur when X is already active, so the rate depends on both [B] and X:

Combined:

22 of 33

22

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

Steady state of activation-deactivation

Set dX/dt = 0 and solve for Xₛₛ:

Biological interpretation:

​

If [A] is large (strong kinase signal), then Xₛₛ → 1 (fully active)

If [B] is large (strong phosphatase signal), then Xₛₛ → 0 (fully inactive)

​

The cell controls activity by adjusting the balance between kinase and phosphatase.

23 of 33

23

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

Steady state of activation-deactivation

Set dX/dt = 0 and solve for Xₛₛ:

Biological interpretation:

​

If [A] is large (strong kinase signal), then Xₛₛ → 1 (fully active)

If [B] is large (strong phosphatase signal), then Xₛₛ → 0 (fully inactive)

​

The cell controls activity by adjusting the balance between kinase and phosphatase.

24 of 33

24

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

Conservation laws

Often the total amount of a molecule is conserved - it just switches between forms.

​

Example: a receptor exists as either free (R) or bound (RL):

[R] + [RL] = [Rₜ] = constant

​

This means: if you track [RL], you automatically know [R] = [Rₜ] − [RL]

​

Every conservation law reduces your system by one equation.�

Always look for conserved quantities before writing your equations!

25 of 33

25

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

Receptor-ligand binding

Receptor (R) + Ligand (L) bind reversibly to form complex RL:

R + L ⇌ RL

​

​

Mass action gives:

Apply conservation [R] = [Rₜ] − [RL]:

26 of 33

26

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

Recipe for Modeling Biochemical Processes

  1. List all chemical species in your system
  2. For each species X: identify every process that creates it (+) and every process that removes it (−)
  3. Apply mass action to each elementary step to get the rate
  4. Sum all contributions: � d[X]/dt = Σ(production terms) − Σ(consumption terms)
  5. Use conservation laws to reduce the number of equations

27 of 33

27

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

Example: A three-tier signaling cascade

A activates B, B activates C. Each species is also degraded first-order.

(A is produced at a constant rate from an upstream signal.)

At steady state: [A]ₛₛ = kA/dA, [B]ₛₛ = kB[A]ₛₛ/dB, [C]ₛₛ = kC[B]ₛₛ/dC

28 of 33

28

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

Hill Functions: Modeling Cooperative Regulation

Many biological responses are switch-like.

​

A small change in signal triggers a large change in output. Linear terms cannot capture this.

Hill functions model cooperative binding and gene regulation.

​

Two parameters control the shape:

  • K (threshold) : the signal level at which the response is half-maximal
  • n (Hill coefficient) : how steep and switch-like the response is

29 of 33

29

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

Hill Functions: Modeling Cooperative Regulation

When a transcription factor X activates a gene, production scales with X in a cooperative way:

  • When X ≪ K, f ≈ 0 (gene is off)
  • When X = K, f = 0.5 (half-maximal)
  • When X ≫ K, f → 1 (gene is fully on)
  • Higher n = sharper switch; n = 1 is smooth; n ≥ 4 approaches a step function

30 of 33

30

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

Hill Functions: Modeling Cooperative Regulation

When repressor R inhibits a gene, we flip the function:

  • When R ≪ K, f ≈ 1 (gene is on - repressor absent)
  • When R = K, f = 0.5 (half-maximal)
  • When R ≫ K, f → 0 (gene is fully repressed)
  • Note: fact + f_inh = 1 when K and n are the same

31 of 33

31

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

Hill Functions: Modeling Cooperative Regulation

Typical ODE for a repressed gene:

32 of 33

32

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

Hill Functions: Modeling Cooperative Regulation

33 of 33

33

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/