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
BME 603/606: Computational Methods for Biological Modeling & Simulation
Announcements
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
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
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
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
BME 603/606: Computational Methods for Biological Modeling & Simulation
Quiz Performance
8
BME 603/606: Computational Methods for Biological Modeling & Simulation
Quiz Performance
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
BME 603/606: Computational Methods for Biological Modeling & Simulation
Recipe for Modeling Biochemical Processes
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
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:
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:
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:
31
BME 603/606: Computational Methods for Biological Modeling & Simulation
Hill Functions: Modeling Cooperative Regulation
Typical ODE for a repressed gene:
32
BME 603/606: Computational Methods for Biological Modeling & Simulation
Hill Functions: Modeling Cooperative Regulation
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/