Tools for agent-based modelling in
developmental biology
Steffen Plunder
Kyoto University
Institute for the Advanced Study of Human Biology (ASHBi)
JuliaCon 2024 Einhoven
1. Challenges of
Agent-Based Models
in
Developmental Biology
2. Moving towards
GPUs... SpatialHashTables.jl
3. Small helper for dynamic networks
BoundedDegreeGraphs.jl
)
4.
Next steps:
GPU implementations of
Position-Based Dynamics (PBD)
and
Vertex Block Decent (VBD)
Overview
Show me some code...
SpatialHashTables.jl
:
GPU-capable iteration over pairs
of positions within cutoff.
BoundedDegreeGraphs.jl
:
Allocation free graph type. (But not quite GPU ready yet.)
+ examples for usage in interdisciplinary projects with biologists.
Part I:
Applications in Developmental Biology
What is Agent-Based/Individual-Based Modelling?
Find relation between
interaction laws
and
emergent behaviour
:
Your browser does not support the video tag.
"Agent-based models are not per se elegant or structured models, rather,
they are a last resort when the nature of things is messy and complex."
Developmental Biology
Figure Source:
Gilbert et al,
Developmental Biology
Too complex for elegant math/physics models...
Project #1:
Modelling of epithelial-to-mesemchymal transitions
think:
skin becomes cancer
2019:
Started my PhD rewriting the
FORTRAN/MATLAB
into
Julia
.
Obviously, the combined pipeline became easily 1000x faster ;)
Your browser does not support the video tag.
Key Challenge
Input:
Timing of phenotype changes
∈
{ never, early, normal, late}
A: loss of apical adhesion
B: loss of basal adhesion
S: loss of polarity
P: protrusive activities
INM: rapid apical movement
Simulation
"Black-Box"
Heterogeneity between cells!
Biological relevant parameters
are not single values, but large ranges!
Need for Speed
Previous FORTRAN/MATLAB combination:
~
30 seconds
per simulation
+
1-2 minutes
for video/plots
Monte-Carlo
Parameter Study
with
N = 150.000
52 days
Julia Code (same algorithm):
~
8 seconds
per simulation
+
20 seconds
per video/plots
(GLMakie.jl)
13 days
Julia code (+ position-based dynamics):
~
0.04 seconds
per simulation
100 minutes
0.07 days
Your browser does not support the video tag.
SP
, Cathy Danesin, Bruno Glise, Marina A. Ferreira, Sara Merino Aceituno, and Eric Theveneau.
“Modelling Variability and Heterogeneity of EMT Scenarios Highlights Nuclear Positioning and Protrusions as Main Drivers of Extrusion.”
(2024) [Accepted in Nature Communications]
Despin-Guitard, Evangéline,
SP
, Navrita Mathiah, Eric Theveneau, and Isabelle Migeotte.
“Occurrence of Non-Apical Mitoses at the Primitive Streak, Induced by Relaxation of Actomyosin and
Acceleration of the Cell Cycle, Contributes to Cell Delamination during Mouse Gastrulation.”
bioRxiv,
(2024)
Biological results...
Project:
Understanding limb morphogenesis
with Antoine Diez (math) and Rio Tsutsumi (biology)
Combined
Agent-based Model
with
Reaction-Diffusion equations
(OrdinaryDiffEq/ROCK2 solver)
Your browser does not support the video tag.
Your browser does not support the video tag.
Your browser does not support the video tag.
experimental data (R. Tsutsumi)
Able to recapitulate several complex biological steps (symmetry breaking &
convergent extension) and give new ideas how elongation might be orchestrated.
(Work in progress.)
Other models
Bacteria model
from Michéle Romanos
Your browser does not support the video tag.
Anisotropic repulsion
from Claudia Wytrzens,
Sara Merino-Aceituno
Your browser does not support the video tag.
Germinal center growth
with Seirin-Lee
Your browser does not support the video tag.
Lessons learned
1. Plain Julia
is already a
pretty decent framework
for Agent-Based Models.
Allows fast development!
2. Analysis of simulation results
requires often more effort
than simulation themselves.
Part II:
Towards GPU Agents
(SpatialHashTables.jl)
A toy model: a sphere of spheres
Consider
N
particles with pairwise repulsion (within radius R)
and attraction to center.
Your browser does not support the video tag.
Cannonical simulation strategy:
Local detection of neighbours
(e.g. cell list method)
https://github.com/SteffenPL/GPUAgents
Cell list method: Partition space and only iterate neigbouring boxes:
SpatialHashTables.jl:
Basic Example
Well known method, very similar to
CellListMaps.jl!
Key features:
Unbounded domain
thanks to hashing!
Allocation free &
GPU kernel friendly.
Minimal interface.
Idea of Spatial Hash Grids
spacial
position
lattice
position
cell list
index
BoundedGrid
1
2
3
4
5
6
1
2
3
4
5
6
1
2
3
4
5
6
(maybe periodically)
HashGrid
1
6
3
4
2
6
5
4
2
4
1
6
1
3
4
2
5
2
Details about GPU implementation:
See
GPU Germs 3, NVIDIA Warp
or
Teschner et al, Optimized Spatial Hashing for Collision Detection of Deformable Objects
Minimal interface
Constructors
Update
Iterator
Usage with KernelAbstractions.jl
Basically, user decides
how to parallelize
(for example also via Threads)
Current alternatives in the Julia ecosystem
CellListMap.jl
...also based on grid based cell lists
+ more general cells (e.g. if the domain is not a square)
+
sometimes
faster CPU multithreading,
especially for dense particles like in atomic simulations
+ requires less boilderplate code
- No GPU support (yet)
NearestNeighbours.jl
... uses KDTrees
+ adaptive and good for non uniform particle distributions
+ slower update of new positions
- No GPU support
These are both
great packages!
Benchmarks
Few neighbours
(e.g. collision setting)
Many neighbours
(intermediate range forces)
Next steps
Improve CPU performance...
Implementation on M1
(I don't have a Mac)
?
Big bottleneck is lack of suitable sorting algorithms for GPUs.
Radix sort including pre-allocation would be ideal...
Bugs & Documentation
Examples with Agents.jl
Part III:
BoundedDegreeGraphs.jl
and a few tips for coding agents
Dynamic networks and allocations
Biological cells have adhesive bonds which might get created/destroyed.
Your browser does not support the video tag.
To avoid allocations, one can essentially store edges in a matrix of size:
BoundedDegreeGraphs.jl
is a
Graphs.jl
compliant implementation for that.
Basic usage and metadata
Benchmark:
allocation free and a bit faster "add/has/rem_edge"
Example Code for Plain Julia Agent-Based Models
Part IV:
Next steps:
GPU accelerated contact resolution
with
Position-Based Dynamics/Vertex Block Decent
Contact mechanics
and
stiffness
Feasible states: "swiss cheese set"
With penalty terms:
Going non-smooth:
set of orthogonally outward pointing vectors
Comparing position based dynamics (PBD) and a penalty method
Models:
PBD is fast,
stable
and easy to implement! 🥳
... there must be a catch?! 🤨
History of PBD
(2006)
Müller, Heidelberger, Hennix, Ratcliff
Position Based Dynamics
(2013)
Macklin, Müller:
Position Based Fluids
(2015)
Wang et al:
Chebyshev Semi-Iterative Approach
for Accelerating Projective and Position-based Dynamics
(2016)
Macklin, Müller:
XPBD
(2019)
Macklin et al:
Small Steps in Physics Simulation
(2024)
Anka Chen et al:
Vertex Block Decent
Recall the
Gauss-Seidel principle:
"Use always the newest information available"
Linear Algebra:
solve only for
i
th coordinate, easy!
Nonlinear equations:
Non-smooth equations:
Classical numerical methods for non-smooth dynamical systems
Moreau's catch-up scheme:
Typical approach for time-stepping schemes:
Use Lagranian multipliers
Taylor (+ index reduction)
Solve for multipliers with
iterative methods.
Projected Nonlinear Gauss-Seidel (PNGS):
Position Based Dynamics:
"Don't worry about convergence of local solver, j
ust use n = 1."
Theoretical result
Thm. [SP, Sara Merino (2023) arxiv]
For first order dynamics, Position-Based Dynamics converges (uniformly).
cp. (2011)
Bertrand Maury, Juliette Venel:
A discrete contact model for crowd motion,
ESAIM
computational cost
Experiment:
github.com/SteffenPL/DifferentialInclusions.jl
Large, accurate time-steps (PNGS)
vs
small, inaccurate time-steps (PBD)
Relatively easy
to implement in Julia with
KernelAbstractions.jl & Atomix.jl
https://github.com/SteffenPL/LearnGPUParticles
Your browser does not support the video tag.
Many contacts and self-collisions:
G
r
a
p
h
c
o
l
o
r
i
n
g
needed
We cannot compute the sequential Gauss-Seidel steps in parallel.
But with a graph coloring we can break it
down into a few parallel steps!
(Often, last color can use a Jaccobi step which
always works in parallel.)
Currently missing: Inaccurate but fast graph coloring (on GPUs).
Next steps:
1. More interesting
open source examples
(maybe in Agents.jl)
2. Combine SpatialHashTables.jl + BoundedDegreeGraphs.jl for
Graph coloring within PBD
3. Possibly, work towards GPU (Newton-Gauss-Seidel style)
PDE solver
on
unstructured meshes
Thanks
To you, the amazing Julia community:
Your browser does not support the video tag.
Your browser does not support the video tag.
Your browser does not support the video tag.
Your browser does not support the video tag.
Your browser does not support the video tag.
Your browser does not support the video tag.