SantaFe-Q-Bio-Tutorial

Download Report

Transcript SantaFe-Q-Bio-Tutorial

Biological and Biomedical
Modeling Using CompuCell3D
Tutorial
Indiana University
Bloomington, Indiana
Maciej Swat, James Glazier
Tutorial Goals
• Introduce Glazier Graner Hogeweg Model (GGH)
aka Cellular Potts Model (CPM) and its potential
applications
• Introduce CompuCell3D – GGH based Modeling
Environment
• Teach how to design, build and run GGH models
using CompuCell3D
Recommended but not required:
Laptop computer with MS Windows, OS X or
latest Ubuntu/Debian Linux
Timeline
•
•
•
•
GGH model introduction – 30 minutes
Introduction to CompuCell3D – 40 minutes
Demo of CompuCell models - 30 minutes
Hands on tutorials – 120 minutes
Demo Simulations
Somitogenesis
In most animal species, the anteroposterior
(AP) body axis is generated by the formation
of repeated structures: segments. The brain,
thorax and limbs are formed through
segmentation.
In vertebrates segmentation, mesodermal
structures called somites gives rises to the
skeletal muscles, occipital bone, vertebrae,
ribs, some dermis and vascular endothelium.
Dictyostelium morphogenesis
Slug Formation
(from Nick Savill)
Contact Inhibition of Motility
“Context-dependent” effect of VEGF-A (Vascular-endothelial
growth-factor A: stimulates vasculogenesis)
• VE-Cadherin clusters at adherens junctions between
endothelial cells
• VE-Cadherin-binding → dephosporylation of VEGFR-2
• VEGF-A signaling:
– in presence of VE-Cadherin: AKT/PKB ↑
• cell survival
– In absence of VE-Cadherin: ERK/MAPK ↑
• Actin polymerization: cell motility / filopodia
In model: suppress chemotaxis at cell
interfaces
Vasculogenesis
Roeland Merks, Abbas Shirinifard
Vascular System Development in 3D
Abbas Shirinifard
GGH Model - an Introduction
Context
• How does the pattern of gene expression act
through physical and chemical mechanisms to
result in the structures we observe? Genetics is
just the beginning.
• Same mechanisms occur repeatedly in different
developmental examples.
• Begin by using phenomenological descriptions.
In many cases very complex pathways have
fairly simple effects under conditions of interest.
Main Processes in Development
•
•
•
•
•
Cell Differentiation
Cell Polarization
Cell Movement
Cell Proliferation and Death
Cellular Secretion and Absorption
Key Questions Concerning
Differentiation
• What are the types of cells in a given process?
• What signals cause cells to change types?
–
–
–
–
Due to diffusible substances?
Due to Cell-Cell Contacts?
Due to Cell History?
Due to Cell-Extracellular Matrix Contact?
• What are the thresholds for these transitions?
• How do these signals interact?
• What are the rates or probabilities of these
transitions?
Cell Movement and Adhesion
•Cells Move Long Distances During Development.
•Move by Protruding and Retracting Filopodia or
Lamellipodia (Leading Edge)
•Shape Changes During Movement May be
Random or Directed.
•Move By Sticking Selectively to Other Cells
(Differential Adhesion)
•Move By Sticking to Extracellular Material
(Haptotaxis)
•Move By Following External Chemical Gradients
(Chemotaxis)
•Can also have Bulk Movement:
•
Secretion of ECM
•
Differential Cell Division
•
Oriented Cell Division
Chemotaxis:
Play Movies
Cells Adhesion
• Cells of a given type have
characteristic
adhesion
strengths to cells of the same
or different types.
• The cells comprising an
aggregate are motile.
• The equilibrium configuration
of
cells
minimizes
their
interfacial energy summed
over all the adhesive contacts
in the aggregate.
Key Questions
• How strongly do cells of one type adhere
to cells of another type?
• How strongly do cells of a given type
adhere to ECM?
• How does cell adhesion change in time?
Cells Send and Respond to
Signals—Chemotaxis (Haptotaxis)
• Cell moves up (down) a
gradient of a diffusible
(non-diffusible) chemical.
• Cell senses diffusible
chemicals through their
receptors on surface.
• Intracellular signal
transduction and
cytoskeleton
rearrangement.
Regular Chemotaxis
Gunther Gerisch (JHU)
Key Questions
• How do cells move in response to
chemical signals in their environment?
• How do cells change type in response to
these signals?
Cell Growth and Death
• What signals cause cells to grow?
• What signals cause cells to die?
(In many cases very little cell growth or
death during a given developmental
phase)
Secretion and Absorption
• What chemicals do cells secrete and
absorb?
• If they diffuse, how rapidly do these
chemicals diffuse?
• If they do not diffuse, what are their
mechanical properties?
• How stable are they (what is their decay
rate)?
Feedback Loops
• Not Simply:
SignalDifferentiationPattern (Known
as Prepatterning).
• Cells Create Their Own Environment, by
Moving and Secreting New Signals, so
Signaling Feeds Back on Itself.
• Hence Self-Organization and Robustness.
Cell-Centered Modeling
• Genetics primarily drives the individual cell
– Response to extracellular signals;
secretion of signaling agents and
extracellular matrix proteins.
• To understand how genetics drive
multicellular patterning, distinguish two
questions:
– How does genetics drive cell
phenomenology?
– How does cell phenomenology drive
multicellular patterning?
Why a Cell Level Model?
• Most mammalian cells are fairly limited in their behaviors. They can:
–
–
–
–
–
–
–
–
–
–
–
Grow
Divide
Change Shape
Move Spontaneously
Move in Response to External Cues (Chemotaxis, Haptotaxis)
Stick (Cell Adhesion)
Absorb External Chemicals (Fields)
Secrete External Chemicals
Exert Forces
Change their Local Surface Properties
(Send Electrical Signals)
A long list, but not compared to 1010 gene product interactions.
Many cells have relatively simple phenomenological behaviors
most of the time.
Physical and Mathematical
Background
• The Glazier-Graner-Hogeweg Model (GGH) is a
Metropolis-Type Lattice-Based PseudoHamiltonian Model
• Monte Carlo Methods
– Metropolis Algorithm (StatisticalKinetic)
• Pseudo-Hamiltonian Lattice-Based Methods
– Ising Model
• Monte Carlo Methods Use Statistical
Physics Techniques to Solve Problems
that are Difficult or Inconvenient to Solve
Deterministically.
• Two Basic Applications:
– Evaluation of Complex Multidimensional
Integrals (e.g. in Statistical Mechanics)
[1950s]
– Optimization of Problems where the
Deterministic Problem is Algorithmically Hard
(NP Complete—e.g. the Traveling Salesman
Problem) [1970s].
• Both Applications Important in Biology.
GGH Model Basics
Lattice based model where cells are represented as spatially extended objects
occupying several lattice sites
x 20
Experiment
Mathematical/Computer Representation
Cell Id=20 Type Id=1
Cell Id=21 Type Id=2
s(x) –denotes id of the cell
occupying position x. All
pixels pointed by arrow
have same cell id , thus
they belong to the same cell
Cell Id=25 Type Id=4
Cell Id=23 Type Id=3
t(s(x)) denotes cell type of cell with id s(x). In the
picture above blue and yellow cells have different
cell types and different cell id. Arrows mark
different cell types
Cell motility – GGH dynamics
GGH is Monte Carlo algorithm where cells randomly are trying to extend their
boundaries by overwriting neighboring pixels. This results in volume increase of
expanding cell and volume decrease for cell whose pixel is being
overwritten
Change pixel
Spin copy “blue” pixel
(newCell) replaces
“yellow” pixel (oldCell)
Not All Pixel Copy Attempts Are Created Equal –
Energy of Cellular System
GGH Model is based on energy minimization using Metropolis algorithm. Most
biological interactions between cells are encapsulated in the Effective Energy, E.
•H is generally the sum of many separate terms.
•Each term in H encapsulates a single biological mechanism.
•Additional Cell Properties described as Constraints.
E   Jt (s ( x )),t (s ( x ')) (1  s ( x ),s ( x ') ) 
x, x '
s ( ss  Ss ) 2  v (vs  Vs ) 2 
Echem  Ehapt  ...
•Metropolis algorithm: probability of configuration change
•The key to the GGH is its use of an Effective Energy or Hamiltonian, H, and Modified
Metropolis Dynamics to provide the Cell Lattice Dynamics.
•This Dynamics means that cells fluctuate, with an Intrinsic Motility T, representing their
cytoskeletally-induced motility.
•The Cell Lattice evolves at any time to gradually reduce the Effective Energy with a
velocity proportional to the gradient of the Energy (Perfect Damping).
For a given H, the Acceptance
Probability is:
H   Jt (s ( x )),t (s ( x ')) (1  s ( x ),s ( x ') )
x, x '
if H  Y
 1
Pacceptance  H    H Y
e T if H  Y
Y is a Dissipation Threshold.
Also introduce concept of Copy or
Protrusion Direction d̂ , which May
Affect the Acceptance Probability.
invalid attempt
valid attempt
reject
valid attempt
accept
accept
valid attempt
valid attempt
accept
Constraints
• Most Important Constraints:
– Cell Volume
– Cell Surface Area
• Additional Examples:
– Cell Elongation
– Viscous Drag
Volume Constraints
• Most Cells (except Generalized Cells
representing fluid media) have defined volumes.
H volume   volume s V s   Vtarget s 
2
s
• Provides an easy way to implement Cell growth:
dVtarget s 
dt
• And Cell Death:
 f (system state, cell state)
Vtarget s   0
Surface Constraints
• Many Cells also have defined membrane areas.
H surface   surface s S s   S target s 
2
s

V s 
R
S s 
1
• The ratio:
d
target
1
d 1
(d=dimension)
target
controls the Cell’s general shape:
• Small R means the Cell is floppy (underinflated
basketball)
• Large R means the Cell is spherical and rigid.
Cell sorting
E   Jt (s ( x )),t (s ( x ')) (1  s ( x ),s ( x ') )  v (vs  Vs ) 2
x, x '
Field Equations
• Most Fields evolve via diffusion, secretion and
absorption and cells and by decay.





C i 
2
 Dc C i    cC i   Sc s i   Ac s i 
t
Diffusion
Decay
Secretion
Absorption
• Sometimes we couple two or more Fields via
Reaction-Diffusion Equations of Form:





C1 i 
2
 f (C1 , C2 )  Dc1  C1 i    c1 C1 i   Sc1 s i   Ac1 s i 
t





C2 i 
2
 g (C1 , C2 )  Dc2  C2 i    c2 C2 i   S c2 s i   Ac2 s i 
t
In GGH we can couple evolving fields to cell
properties/behaviors
•Chemotaxis/Haptotaxis
•Chemical Concentration Dependent Cell Growth rate
- mitosis
•Chemical Concentration Dependent Cell
Differentiation
Chemotaxis Term – Most Basic Form
Echem   (c( xdestination )  c( xsource))
If concentration at the spin-copy destination pixel (c(xdestination)) is higher than
concentration at the spin-copy source (c(xsource)) AND  is positive then E is negative
and such spin copy will be accepted. The cell chemotacts up the concentration gradient
C(x)
Lower concentration
Higher concentration
x
Chemorepulsion can be obtained by making  negative
Chemotaxis – Example
CompuCell3D simulation
What Is CompuCell3D?
1. CompuCell3D is a modeling environment used to build, test, run and visualize
GGH-based simulations
2. CompuCell3D has built-in scripting language (Python) that allows users to quite
easily write extension modules that are essential for building sophisticated
biological models.
3. CompuCell3D thus is NOT a specialized software
4. Running CompuCell3D simulations DOES NOT require recompilation
5. CompuCell3D model is described using CompuCell3D XML syntax and in the
case of using Python language , a Python script(s)
6. CompuCell3D platform is distributed with a GUI front end – CompuCell Player
or simply Player. The Player provides 2- and 3-D visualization capabilities.
7. Models developed by one CompuCell3D user can be “replayed” by another user
regardless the operating system/hardware on which CompuCell is installed.
8. CompuCell3D is a cross platform application that runs on Linux/Unix, Windows,
Mac OSX
Why Use CompuCell3D? What Are the Alternatives?
1. CompuCell3D allows users to set up and run their simulations within minutes,
maybe hours. A typical development of a specialized GGH code takes orders of
magnitudes longer time.
2. CompuCell3D simulations DO NOT need to be recompiled. If you want to
change parameters (in XML or Python scripts) or logic (in Python scripts) you
just make the changes and re-run the simulation. With hand-compiled
simulations there is much more to do. Recompilation of every simulation is also
error prone and often limits users to those who have significant programming
background.
3. CompuCell3D is actively developed , maintained and supported. On
www.compucell3d.org website users can download manuals, tutorials and
developer documentation. CompuCell3D has approx. 10 releases each year –
some of which are bug-fix releases and some are major
4. CompuCell3D has many users around the world. This makes it easier to
collaborate or exchange modules and results saving time spent on developing
new model.
5. The Biocomplexity Institute organizes training workshops and mentorship
programs. Those are great opportunities to visit Bloomington and learn
biological modeling using CompuCell3D. For more info see
www.compucell3d.org
Demo Simulations
CompuCell3D Architecture
Object oriented implementation in C++ and Python
Visualization, Steering,
User Interface
Python Interpreter
Biologo Code Generator
Kernel
Runs Metropolis Algorithm
Plugins
Calculate change
in energy
PDE Solvers
Lattice monitoring
Typical “Run-Time” Architecture of CompuCell
CompuCellPlayer
CompuCell can be run in a
variety of ways:
•Through the Player with or
without Python interpreter
Python
•As a Python script
CompuCell3D
Kernel
Plugins
•As a stand alone
computational kernel+plugins
CompuCell3D terminology
1. Pixel-copy attempt is an event where program randomly picks a lattice site in an
attempt to copy its value to a neighboring lattice site.
2. Monte Carlo Step (MCS) consists of series pixel-copy attempts. Usually the
number of pixel copy-attempts in single MCS is equal to the number of lattice
sites, but this is can be customized
3. CompuCell3D Plugin is a software module that either calculates an energy term
in a Hamiltonian or implements action in response to pixel copy (lattice
monitors). Note that not all spin-copy attempts will trigger lattice monitors to run.
4. Steppables are CompuCell3D modules that are run every MCS after all pixelcopy attempts for a given MCS have been exhausted. Most of Steppables are
implemented in Python. Most cell behavior alterations are done in steppables
5. Steppers are modules that are run for those pixel-copy attempts that actually
resulted in energy calculation. They are run regardless whether actual pixelcopy occurred or not. For example cell mitosis is implemented in the form of
stepper.
6. Fixed Steppers are modules that are run every pixel-copy attempt.
CompuCell3D Terminology – Visual Guide
Change pixel
Pixel copy - “blue”
pixel (newCell)
replaces “yellow” pixel
(oldCell)
100x100x1 square lattice = 10000 lattice sites (pixels)
MCS 21
MCS 22
10000 pixelcopy attempts
MCS 23
10000 pixelcopy attempts
MCS 24
10000 pixelcopy attempts
10000 pixelcopy attempts
Run
Run
Run
Steppables
Steppables
Steppables
Nearest neighbors in 2D and their Euclidian distances from the central pixel
4
4
4
3
2
4
3
4
2
1
2
4
4
2
3
1
4
2
1
1
2
3
4
4
3
1
1
2
2D Hexagonal Lattice
Neighbo
r Order
Number of
Neighbors
Euclidian
Distance
Number of
Neighbors
1
4
1
6
2/ 3
2
4
6
6/ 3
3
4
2
6
4
8
5
12
Euclidian
Distance
8/ 3
14 / 3
3
4
2
4
3
2
3
4
2D Square Lattice
4
2
1
1
3
4
2
1
1
4
4
4
3
4
4
Your First CompuCell3D Simulation
– Cell Sorting
E   Jt (s ( x )),t (s ( x ')) (1  s ( x ),s ( x ') )  v (vs  Vs ) 2
x, x '
• Users can describe their simulations using XML,
Python, or both XML and Python
• Most recent version (development version) of
CompuCell3D has Java interface => support of
many scripting languages through Java
ScriptEngine
Configure lattice and general
simulation parameters
def configureSimulation(sim):
import CompuCell
import CompuCellSetup
ppd=CompuCell.PottsParseData()
ppd.Steps(20000)
ppd.Temperature(5)
ppd.NeighborOrder(2)
ppd.Dimensions(CompuCell.Dim3D(100,100,1))
if H  Y
 1
Pacceptance  H    H Y
e T if H  Y
Tell Compucell3D what cell
types you will use. Remember
to list Medium with type id 0
ctpd=CompuCell.CellTypeParseData()
ctpd.CellType("Medium",0)
ctpd.CellType("Condensing",1)
ctpd.CellType("NonCondensing",2)
cpd=CompuCell.ContactParseData()
cpd.Energy("Medium","Medium",0)
cpd.Energy("NonCondensing","NonCondensing",16)
cpd.Energy("Condensing","Condensing",2)
cpd.Energy("NonCondensing","Condensing",11)
E  ... 
cpd.Energy("NonCondensing","Medium",16)
cpd.Energy("Condensing","Medium",16)
Type Id
Type Name
 Jt s
( ( x )),t (s ( x '))
(1   s ( x ),s ( x ') )  ...
x, x'
vpd=CompuCell.VolumeParseData()
vpd.TargetVolume(25.0)
vpd.LambdaVolume(1.0)
E  ...  v (vs  Vs ) 2  ...
Specifying initial configuration of cells
bipd=CompuCell.BlobInitializerParseData()
region=bipd.Region()
region.Center(CompuCell.Point3D(50,50,0))
region.Radius(40)
region.Types("Condensing")
region.Types("NonCondensing")
region.Width(5)
Cell types use to fill region
Width of a single cell
Register ParseData objects
#remember to register ParseData
CompuCellSetup.registerPotts(sim,ppd)
Register lattice configuration section
CompuCellSetup.registerPlugin(sim,ctpd)
CompuCellSetup.registerPlugin(sim,cpd)
CompuCellSetup.registerPlugin(sim,vpd)
Register energy functions and cell type
specification
CompuCellSetup.registerSteppable(sim,bipd)
Register initial configuration steppable
Complete listing
def configureSimulation(sim):
import CompuCell
import CompuCellSetup
ppd=CompuCell.PottsParseData()
ppd.Steps(20000)
ppd.Temperature(5)
ppd.NeighborOrder(2)
ppd.Dimensions(CompuCell.Dim3D(100,100,1))
ctpd=CompuCell.CellTypeParseData()
ctpd.CellType("Medium",0)
ctpd.CellType("Condensing",1)
ctpd.CellType("NonCondensing",2)
cpd=CompuCell.ContactParseData()
cpd.Energy("Medium","Medium",0)
cpd.Energy("NonCondensing","NonCondensing",16)
cpd.Energy("Condensing","Condensing",2)
cpd.Energy("NonCondensing","Condensing",11)
cpd.Energy("NonCondensing","Medium",16)
cpd.Energy("Condensing","Medium",16)
vpd=CompuCell.VolumeParseData()
vpd.LambdaVolume(1.0)
vpd.TargetVolume(25.0)
bipd=CompuCell.BlobInitializerParseData()
region=bipd.Region()
region.Center(CompuCell.Point3D(50,50,0))
region.Radius(40)
region.Types("Condensing")
region.Types("NonCondensing")
region.Width(5)
#remember to register ParseData
CompuCellSetup.registerPotts(sim,ppd)
CompuCellSetup.registerPlugin(sim,ctpd)
CompuCellSetup.registerPlugin(sim,cpd)
CompuCellSetup.registerPlugin(sim,vpd)
CompuCellSetup.registerSteppable(sim,bipd)
35 lines of straightforward code vs at least 1000 lines of C++/Java/Fortran code
To finish the simulation code - reuse boiler-plate code from CompuCell3D examples
import sys
from os import environ
import string
sys.path.append(environ["PYTHON_MODULE_PATH"])
import CompuCellSetup
sim,simthread = CompuCellSetup.getCoreSimulationObjects()
configureSimulation(sim)
CompuCellSetup.initializeSimulationObjects(sim,simthread)
from PySteppables import SteppableRegistry
steppableRegistry=SteppableRegistry()
CompuCellSetup.mainLoop(sim,simthread,steppableRegistry)
Opening a Python-based simulation in the Player
Go to File->Open Simulation ; Click Python script “Browse…” button to
select python script. Do not forget to check “ Run Python script” checkbox!
Cell-sorting in XML - cellsort_2D.xml
<CompuCell3D>
<Potts>
<Dimensions x="100" y="100" z="1"/>
<Steps>10000</Steps>
<Temperature>2</Temperature>
</Potts>
<Plugin Name="CellType">
<CellType TypeName="Medium" TypeId="0"/>
<CellType TypeName=“Light" TypeId="1"/>
<CellType TypeName=“Dark" ="2"/>
</Plugin>
<Plugin Name="Volume">
<TargetVolume>25</TargetVolume>
<LambdaVolume>1.0</LambdaVolume>
</Plugin>
<Plugin Name="Surface">
<TargetSurface>21</TargetSurface>
<LambdaSurface>0.5</LambdaSurface>
</Plugin>
<Plugin Name="Contact">
<Energy Type1="Medium" Type2="Medium">0
</Energy>
<Energy Type1="Light" Type2="Medium">16
</Energy>
<Energy Type1="Dark" Type2="Medium">16
</Energy>
<Energy Type1="Light" Type2="Light">16
</Energy>
<Energy Type1="Dark" Type2="Dark">2.0
</Energy>
<Energy Type1="Light" Type2="Dark">11
</Energy>
</Plugin>
<Steppable Type="BlobInitializer">
<Region>
<Radius>30</Radius>
<Center x="40" y="40" z="0"/>
<Gap>0</Gap>
<Width>5</Width>
<Types>Dark,Light</Types>
</Region>
</Steppable>
</CompuCell3D>
Coding the same simulation in C/C++/Java/Fortran would take you at least 1000 lines
of code…
Exercise 1
• Modify simulation so that cells produce
checkerboard pattern
Crawling Neutrophil Chasing
Bacterium
Richard Firtel (UCSD)
Simulation Building Blocks in
CompuCell3D
• Four Cell Types: Bacterium, Macrophage,
Wall, Red Blood Cells
• Assumption 1:Bacterium secretes
chemoattractant (call it ATTR) which
diffuses and Macrophage responds to the
ATTR gradient
• Assumption 2: Macrophage secretes
chemorepellant (REPL) which affects
Bacterium
Initial configuration
ppd=CompuCell.PottsParseData()
ppd.Steps(20000)
ppd.Temperature(15)
ppd.Flip2DimRatio(1.0)
ppd.Dimensions(CompuCell.Dim3D(100,100,1))
ctpd=CompuCell.CellTypeParseData()
ctpd.CellType("Medium",0)
ctpd.CellType("Bacterium",1)
ctpd.CellType("Macrophage",2)
ctpd.CellType("Wall",3,True)
cpd=CompuCell.ContactParseData()
cpd.Energy("Medium","Medium",0)
cpd.Energy("Macrophage","Macrophage",15)
cpd.Energy("Macrophage","Medium",8)
cpd.Energy("Bacterium","Bacterium",15)
cpd.Energy("Bacterium","Macrophage",15)
cpd.Energy("Bacterium","Medium",8)
cpd.Energy("Wall","Wall",0)
cpd.Energy("Wall","Medium",0)
cpd.Energy("Wall","Bacterium",50)
cpd.Energy("Wall","Macrophage",50)
cpd.NeighborOrder(2)
vpd=CompuCell.VolumeParseData()
vpd.LambdaVolume(15.0)
vpd.TargetVolume(25.0)
spd=CompuCell.SurfaceParseData()
spd.LambdaSurface(4.0)
spd.TargetSurface(20.0)
Make Wall cells frozen
chpd=CompuCell.ChemotaxisParseData()
chfield=chpd.ChemicalField()
chfield.Source("FastDiffusionSolver2DFE")
chfield.Name("ATTR")
chbt=chfield.ChemotaxisByType()
chbt.Type("Macrophage")
chbt.Lambda(2.0)
fdspd=CompuCell.FastDiffusionSolver2DFEParseData()
df=fdspd.DiffusionField()
diffData=df.DiffusionData()
secrData=df.SecretionData()
diffData.DiffusionConstant(0.1)
diffData.DecayConstant(0.001)
diffData.FieldName("ATTR")
diffData.DoNotDiffuseTo("Wall")
secrData.Secretion("Bacterium",200)
pifpd=CompuCell.PIFInitializerParseData()
pifpd.PIFName("bacterium_macrophage_2D_wall.pif")
CompuCellSetup.registerPotts(sim,ppd)
CompuCellSetup.registerPlugin(sim,ctpd)
CompuCellSetup.registerPlugin(sim,vpd)
CompuCellSetup.registerPlugin(sim,spd)
CompuCellSetup.registerPlugin(sim,chpd)
CompuCellSetup.registerSteppable(sim,pifpd)
CompuCellSetup.registerSteppable(sim,fdspd)
Chemotaxis: choosing PDE solver and
chemical field name
Setting chemotacting type and
chemotaxis strength
Diffusion field ATTR
Diffusion and decay constants
Preventting ATTR from entering
Wall cels
Bacterium secretion constant
Exercise 2 - Making simulation look
more realistic
• Introduce moving Red Blood Cells instead
of rigid walls
• Make Bacterium small and Macrophage
large
• Introduce few Macrophages and Bacteria
• Introduce new chemorepellant (REP)
secreted by Macrophage and afecting
bacterium (Exercise 2a)
Simulation Screenshots
Using PIFInitilizer
Use PIFInitializer to create sophisticated initial conditions. PIF file allows you to
compose cells from single pixels or from larger rectangular blocks
The syntax of the PIF file is given below:
Cell_id Cell_type x_low x_high y_low y_high z_low z_high
Example (file: amoebae_2D_workshop.pif):
0 amoeba 10 15 10 15 0 0
This will create rectangular cell with x-coordinates ranging from 10 to 15
(inclusive), y coordinates ranging from 10 to 15 (inclusive) and z coordinates
ranging from 0 to 0 inclusive.
0,0
Python syntax:
pifpd=CompuCell.PIFInitializerParseData()
pifpd.PIFName(“amoebae_2D_workshop.pif")
Let’s add another cell:
Example (file: amoebae_2D_workshop.pif):
0 Amoeba 10 15 10 15 0 0
1 Bacteria 35 40 35 40 0 0
Notice that new cell has different cell_id (1) and different type (Bacterium)
Let’s add pixels and blocks to the two cells
from previous example:
Example (file: amoebae_2D_workshop.pif):
0 Amoeba 10 15 10 15 0 0
1 Bacteria 35 40 35 40 0 0
0 Amoeba 16 16 15 15 0 0
1 Bacteria 35 37 41 45 0 0
To add pixels, start new pif line with existing cell_id (0 or 1 here ) and specify pixels.
This is what happens when you do not reuse
cell_id
Example (file: amoebae_2D_workshop.pif):
0 Amoeba 10 15 10 15 0 0
1 Bacteria 35 40 35 40 0 0
0 Amoeba 16 16 15 15 0 0
2 Bacteria 35 37 41 45 0 0
Introducing new cell_id (2) creates new cell.
PIF files allow users to specify arbitrarily complex cell shapes and cell arrangements.
The drawback is, that typing PIF file is quite tedious task and , not recommended.
Typically PIF files are created using scripts.
In the future release of CompuCell3D users will be able to draw on the screen cells or
regions filled with cells using GUI tools. Such graphical initialization tools will greatly
simplify the process of setting up new simulations. This project has high priority on our
TO DO list.
PIFDumper - yet another way to create initial condition
PIFDumper is typically used to output cell lattice every predefined number of MCS. It is
useful because, you may start with rectangular cells, “round them up” by running
CompuCell3D , output cell lattice using PIF dumper and reload newly created PIF file
using PIFInitializer.
pifpd=CompuCell.PIFDumperParseData()
pifpd.PIFName(“amoebae.100.pif")
pifpd.frequency=100
Above syntax tells CompuCell3D to store cell lattice as a PIF file every 100 MCS.
The files will be named amoebae.100.pif , amoebae.200.pif etc…
To reload file , say amoebae.100.pif use already familiar syntax:
pifpd=CompuCell.PIFInitializerParseData()
pifpd.PIFName(“amoebae.100.pif")
Writing Python Extension Modules
for CompuCell3D
• Most of CompuCell3D simulations will require
certain level of customization.
• Using “traditional” approach , this would be done
in C++/Java/Fortran and would require
recompilation
• CompuCell3D allows users to conveniently
develop their own extension modules using
Python that DO NOT NEED to be recompiled
• Typically users develop steppable modules
(called every MCS) which alter cellular behavior
as simulation progresses.
Printing information about all the cells present in the simulation
class InfoPrinterSteppable(SteppablePy):
def __init__(self,_simulator,_frequency=10):
SteppablePy.__init__(self,_frequency)
self.simulator=_simulator
self.inventory=self.simulator.getPotts().getCellInventory()
self.cellList=CellList(self.inventory)
def step(self,mcs):
for cell in self.cellList:
print "CELL ID=",cell.id, " CELL TYPE=",\
cell.type," volume=",cell.volume
Class constructor – used
to initialize Steppable
object.
Creating iterable cell
inventory
Iterating through cell
inventory and printing
basic cell information
Code of the constructor is a boiler-plate code and typically is reused without any
alterations in many steppables.
class InfoPrinterSteppable(SteppablePy)………… #include earlier code
def configureSimulation(sim)……………………….. #include earlier code
#import useful modules
import sys
from os import environ
from os import getcwd
import string
#setup search patths
sys.path.append(environ["PYTHON_MODULE_PATH"])
sys.path.append(getcwd()+"/demo") #add search path
import CompuCellSetup
sim,simthread = CompuCellSetup.getCoreSimulationObjects()
CompuCellSetup.initializeSimulationObjects(sim,simthread)
#Add Python steppables here
steppableRegistry=CompuCellSetup.getSteppableRegistry()
infoPrinterSteppable=InfoPrinterSteppable(_simulator=sim,_frequency=10)
steppableRegistry.registerSteppable(infoPrinterSteppable)
CompuCellSetup.mainLoop(sim,simthread,steppableRegistry)
Info Printer results
Exercise 3
• Enhance cell-sorting simulation by writing
a Python steppable that at the beginning
of the simulation assigns Type ID=1 to
cells in the upper half of the lattice and
Type ID=2 to cells in the lower half of
the lattice.
Hint: you have to include
compd=CompuCell.CenterOfMassParseData()
To ensure that CompuCell3D updates COM position for each cell:
centerOfMassX = cell.xCM / float(cell.volume)
Exercise 4
• For cell-sorting simulation, write Python
Steppable that every 100 MCS switches
cell types 2 -> 1 and 1->2
Summary
• CompuCell3D is indeed environment
rather than specialized program
• It can be extended by writing modules in
Python, C++, Java.
• Actively developed and supported
• Annual Training Workshops in
Bloomington, Indiana
• www.compucell3d.org