Paclitaxel and trastuzumab with antibody binding
HER2+ breast cancer cells under trastuzumab and paclitaxel.
- Class:
HER2TargetedTherapySystem - Import:
from skcomplex.systems.biology.oncology import HER2TargetedTherapySystem - Field:
biology/oncology - Topics:
chemotherapy,targeted therapy,combination therapy,HER2,antibody,ode - References:
- Padmanabhan, Meskin, and Al Moustafa 2021
- Jarrett et al. 2019
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.biology.oncology import HER2TargetedTherapySystem
trajectory = HER2TargetedTherapySystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
A |
0.035 |
antibody |
0.2 |
paclitaxel |
2.0 |
t_antibody |
1.0 |
t_a |
2.0 |
t_p |
1.0 |
sigma |
1.0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | none |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class HER2TargetedTherapySystem(DynamicalSystem):
"""HER2+ breast cancer cells under trastuzumab and paclitaxel.
The model includes antibody binding and drug uptake.
The free antibody and the free paclitaxel are drivers held at their levels from their doses on. The antibody binds
the receptors, which are in excess, so the bound antibody rises to the free antibody, and from the time `t_a` on it
lowers the growth rate to `r (1 - a1 Ab)`. The paclitaxel enters the cells and briefly lowers the carrying capacity.
The cytotoxicity falls from one at the dose, so `t_p` is the dose time. The book's units cannot hold 35,000 cells
with a capacity of 0.67, so cells are counted in millions and the antibody in millions of molecules. The dose levels
and times are a choice. Time is in days. The system has the cells `tumour.A`, the bound antibody `tumour.Ab`, and
the internalized paclitaxel `tumour.Pin`.
Args:
A:
The initial number of cells, in millions.
antibody:
The level of free antibody from its dose on.
paclitaxel:
The level of free paclitaxel from its dose on, in pmol.
t_antibody:
The time of the antibody dose.
t_a:
The time from which the bound antibody inhibits proliferation.
t_p:
The time of the paclitaxel dose.
sigma:
The synergy of the two drugs, 1 for none.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.biology.oncology import HER2TargetedTherapySystem
>>> HER2TargetedTherapySystem(sigma=1.5).prepare().system_.elements[0].values['sigma']
1.5
"""
field = 'biology/oncology'
topics = ('chemotherapy', 'targeted therapy', 'combination therapy', 'HER2', 'antibody', 'ode')
references = (BOOK, 'Jarrett et al. 2019')
until = 10.0
dt = 0.02
def __init__(
self,
A: float = 0.035,
*,
antibody: float = 0.2,
paclitaxel: float = 2.0,
t_antibody: float = 1.0,
t_a: float = 2.0,
t_p: float = 1.0,
sigma: float = 1.0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label=label, solver=solver, backend=backend)
self.A = A
self.antibody = antibody
self.paclitaxel = paclitaxel
self.t_antibody = t_antibody
self.t_a = t_a
self.t_p = t_p
self.sigma = sigma
def _get_solver(self) -> BaseSolver:
"""Return the solver the system is tuned to."""
return ScipyODESolver(method='LSODA', rtol=1e-8, atol=1e-10)
def _get_element_label(self) -> str:
"""Return the label of the element that holds the states."""
return 'tumour'
def _get_states(self) -> dict[str, object]:
"""Return the initial value of every state by name."""
return {
'A': self.A,
'Ab': 0.0,
'Pin': 0.0,
}
def _get_parameters(self) -> dict[str, object]:
"""Return the value of every parameter by name."""
return {
'r': 0.83,
'kc': 0.67,
'a1': 2.51,
'a2': 23.0,
'gamma_p': 6.35,
'sigma': self.sigma,
'theta_ab': 8.78,
'theta_r': 1940000.0,
'alpha_p': 0.68,
'antibody': self.antibody,
'paclitaxel': self.paclitaxel,
}
def _get_equations(self) -> Equations:
"""Return the tumour growth, the antibody binding, and the paclitaxel uptake."""
return {'A': self._get_growth, 'Ab': self._get_binding, 'Pin': self._get_uptake}
def _get_growth(self, s: SimpleNamespace) -> Expression:
"""Return the logistic growth of the cells, slowed by the antibody and capped by the paclitaxel."""
tumour = s.target
inhibition = where(s.t > self.t_a, tumour.a1 * tumour.Ab, 0)
cytotoxicity = where(
s.t >= self.t_p,
tumour.sigma * tumour.a2 * exp(-tumour.gamma_p * (s.t - self.t_p)) * tumour.Pin,
0,
)
return tumour.r * (1 - inhibition) * (1 - tumour.A / (tumour.kc - cytotoxicity)) * tumour.A
def _get_binding(self, s: SimpleNamespace) -> Expression:
"""Return the binding of the free antibody to the receptors while it is present."""
tumour = s.target
free_antibody = where(s.t >= self.t_antibody, tumour.antibody, 0)
binding = tumour.theta_ab * (free_antibody - tumour.Ab) * (tumour.theta_r * tumour.A - tumour.Ab)
return where(free_antibody > 0, binding, 0)
def _get_uptake(self, s: SimpleNamespace) -> Expression:
"""Return the uptake of the free paclitaxel into the cells while it is present."""
tumour = s.target
free_paclitaxel = where(s.t >= self.t_p, tumour.paclitaxel, 0)
return where(free_paclitaxel > 0, tumour.alpha_p * (free_paclitaxel - tumour.Pin) * tumour.A, 0)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
AnnotatedElement, fromElement, through the shared recipeAnnotatedElement
Interactions:
EquationInteraction, fromInteraction, through the shared recipeEquationInteraction
class AnnotatedElement(Element):
"""An element of values by name, with the allowed values and quantities of some.
It holds what a class would write in `Annotated`, for values known only as data. The values
`{'n': 40.0}` with `allowed={'n': RealSet.closed_open(0, oo)}` and `quantities={'n': 'people'}` are read as
`n: Annotated[float, RealSet.closed_open(0, oo), Quantity('people')] = 40.0`, so a negative `n` is rejected and the
conservation monitor follows the people. The generic systems that build one element from a mapping of states, such
as `DynamicalSystem` and `StockFlowSystem`, build this element.
Unlike `Element`, whose subclass writes the allowed values and quantities in `Annotated` on its arguments, it takes
them as data. Choose it when the names of the values are known only when a system is built.
It appears in many fields. The stocks of a bathtub, the people of a diffusion of innovations, and the oil of an
economy are each its values.
Args:
label:
The name of the element, unique among the components of its system, such as `'population'`.
values:
The values by name, such as `{'n': 40.0, 'r': 0.5}`, or `None` for none.
allowed:
The allowed values of some values by name, a `RealSet` such as `RealSet.closed_open(0, oo)` or a set such
as `{'S', 'I', 'R'}`, or `None` for none.
quantities:
The quantity some values hold by name, such as `{'n': 'people'}`, or `None` for none.
Examples:
>>> from sage.all__sagemath_symbolics import oo
>>> from sage.sets.real_set import RealSet
>>> from skcomplex.systems.general.dynamics import AnnotatedElement
>>> from skcomplex.core.errors import ValidationError
>>> from skcomplex.core.systems import System
>>> tank = AnnotatedElement('tank', values={'level': -1.0}, allowed={'level': RealSet.closed_open(0, oo)})
>>> try:
... System(elements=[tank]).prepare()
... except ValidationError as error:
... print(error)
The system is not valid, with 1 error(s):
- tank: tank.level = -1.0 is not in its domain [0, +oo). Correct the component as the message describes. [value]
"""
def __init__(
self,
label: str,
*,
values: Mapping[str, object] | None = None,
allowed: Mapping[str, object] | None = None,
quantities: Mapping[str, str] | None = None,
) -> None:
super().__init__(label, values=values)
self.allowed = allowed
self.quantities = quantities
def _get_hints(self) -> dict[str, object]:
"""Return the hint of every value with allowed values or a quantity.
Each hint is what `Annotated` would write. The arguments `allowed` and `quantities` describe the values, so they
are no values themselves.
"""
allowed, quantities = self.allowed or {}, self.quantities or {}
hints: dict[str, object] = {}
for name in [*allowed, *(name for name in quantities if name not in allowed)]:
items = [allowed[name]] if name in allowed else []
items += [Quantity(quantities[name])] if name in quantities else []
hints[name] = Annotated[object, *items]
return hints
class EquationInteraction(Interaction):
"""An interaction that gives one state of an element its rate or its next value.
In continuous time the equation is the rate of the state, or of its derivative of order `k` when the state is named
with `k` primes, such as `"x''"` for an acceleration, and a noise amplitude adds a noise in the Itô or Stratonovich
convention. In discrete time the equation is the next value of the state, read from the values at the start of the
step. An equation and a noise are functions of the namespace whose `target` holds the values of the element and
whose `t` holds the time.
Unlike `Interaction`, which a subclass gives laws of its own, it takes the equation as a function. Choose it when
one state follows one formula, with no class of its own.
It appears in many fields. The decay of a tank, the logistic map of a population, and the income of an economy are
each one equation of one state.
Args:
label:
The label of the interaction, unique among the components of its system.
target:
The path of the element whose state the equation changes.
state:
The name of the state, with a prime for every order of the derivative the equation gives.
equation:
The rate or the next value as a function of the namespace, or `None` for a noise alone.
noise:
The noise amplitude as a function of the namespace or a number, or `None` for none.
convention:
The stochastic calculus of the noise, `'ito'` or `'stratonovich'`.
time:
The time of the equation, `'continuous'` for a rate or `'discrete'` for a next value.
Examples:
>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.general.dynamics import EquationInteraction
>>> decay = EquationInteraction('decay', target='tank', state='x', equation=lambda s: -s.target.k * s.target.x)
>>> system = System(elements=[Element('tank', values={'x': 1.0, 'k': 0.5})], interactions=[decay])
>>> round(float(system.prepare().simulate(until=2.0, dt=2.0).get_values('tank.x')[-1]), 4)
0.3679
"""
law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (RateLaw, NoiseLaw, UpdateLaw)
def __init__(
self,
label: str,
*,
target: Role,
state: str,
equation: Callable[[SimpleNamespace], object] | None = None,
noise: Callable[[SimpleNamespace], object] | float | None = None,
convention: str = 'ito',
time: str = 'continuous',
) -> None:
super().__init__(label)
self.target = target
self.state = state
self.equation = equation
self.noise = noise
self.convention = convention
self.time = time
def _get_tags(self) -> Tags:
"""Return the tags of the update, or of the rate and the noise the equation has."""
if self.time == 'discrete':
return self._get_variant_tags((UpdateLaw,))
classes = (RateLaw,) if self.equation is not None else ()
return self._get_variant_tags((*classes, NoiseLaw) if self.noise is not None else classes)
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the rate and the noise, or the next value, of the state.
Args:
context:
The namespace of the element.
"""
super()._prepare(context)
name = self.state.rstrip("'")
order = len(self.state) - len(name)
state = getattr(context.target, name)
laws: list[BaseLaw] = []
if self.time == 'discrete' and self.equation is not None:
laws.append(UpdateLaw(state, self.equation(context)))
elif self.equation is not None:
laws.append(RateLaw(state.diff(context.t, max(order, 1)), self.equation(context)))
if self.time != 'discrete' and self.noise is not None:
noise = self.noise(context) if callable(self.noise) else self.noise
laws.append(NoiseLaw(state.diff(context.t, max(order, 1)), noise, convention=self.convention))
self.laws_: list[BaseLaw] = laws
Equations
The equations are those that symbolic returns for the system with its default parameters.
tumour.A: diff(A_tumour(t), t) == r_tumour*(A_tumour(t)/(kc_tumour - where(t >= 1.0, a2_tumour*sigma_tumour*Pin_tumour(t)*e^(-gamma_p_tumour*(t - 1.0)), 0)) - 1)*(where(t > 2.0, a1_tumour*Ab_tumour(t), 0) - 1)*A_tumour(t)
tumour.Ab: diff(Ab_tumour(t), t) == where(where(t >= 1.0, antibody_tumour, 0) > 0, -(theta_r_tumour*A_tumour(t) - Ab_tumour(t))*theta_ab_tumour*(Ab_tumour(t) - where(t >= 1.0, antibody_tumour, 0)), 0)
tumour.Pin: diff(Pin_tumour(t), t) == where(where(t >= 1.0, paclitaxel_tumour, 0) > 0, -alpha_p_tumour*(Pin_tumour(t) - where(t >= 1.0, paclitaxel_tumour, 0))*A_tumour(t), 0)