Biological and Biomedical Modeling Using CompuCell3D Tutorial Indiana University Bloomington,...
-
Upload
eric-martin -
Category
Documents
-
view
218 -
download
1
Transcript of Biological and Biomedical Modeling Using CompuCell3D Tutorial Indiana University Bloomington,...
Biological and Biomedical Modeling Using CompuCell3D
Tutorial
Indiana University
Bloomington, IndianaMaciej 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
VasculogenesisRoeland 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 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.
Cells Adhesion
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: SignalDifferentiationPattern (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 Pseudo-Hamiltonian Model
• Monte Carlo Methods– Metropolis Algorithm (StatisticalKinetic)
• 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=1Cell Id=21 Type Id=2
Cell Id=25 Type Id=4 Cell Id=23 Type Id=3
(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
((x)) denotes cell type of cell with id (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
Spin copy “blue” pixel (newCell) replaces “yellow” pixel (oldCell)
Change pixel
Not All Pixel Copy Attempts Are Created Equal – Energy of Cellular System
( ( )), ( ( ')) ( ), ( '), '
2 2
(1 )
( ) ( )
...
x x x xx x
s v
chem hapt
E J
s S v V
E E
•Metropolis algorithm: probability of configuration change
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.
•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).
acceptance
1 if
if H Y
T
H YP H
e H Y
Y is a Dissipation Threshold.
Also introduce concept of Copy or Protrusion Direction , which May Affect the Acceptance Probability.
d̂
For a given H, the Acceptance Probability is:
( ( )), ( ( ')) ( ), ( '), '
(1 )x x x xx x
H J
invalid attempt valid attempt accept
valid attempt accept
valid attempt accept
valid attempt
reject
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.
• Provides an easy way to implement Cell growth:
• And Cell Death:
2targetvolumevolume VVH
state) cell state, system(
dttarget f
dV
0target V
Surface Constraints• Many Cells also have defined membrane areas.
• The ratio: (d=dimension)
controls the Cell’s general shape:
• Small R means the Cell is floppy (underinflated basketball)
• Large R means the Cell is spherical and rigid.
2targetsurfacesurface SSH
1
1
1
target
target
d
d
S
VR
Cell sorting2
( ( )), ( ( ')) ( ), ( '), '
(1 ) ( )x x x x vx x
E J v V
Field Equations• Most Fields evolve via diffusion, secretion and
absorption and cells and by decay.
• Sometimes we couple two or more Fields via Reaction-Diffusion Equations of Form:
iAiSiCiCDt
iCcccc
2
Diffusion Decay Secretion Absorption
iAiSiCiCDCCgt
iC
iAiSiCiCDCCft
iC
cccc
cccc
2222
1111
222
212
112
211
),(
),(
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
))()(( sourcendestinatiochem xcxcE
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
x
C(x)
Lower concentrationHigher concentration
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
KernelRuns Metropolis Algorithm
PluginsCalculate change
in energy
PDE Solvers
Python InterpreterBiologo Code Generator
Visualization, Steering,User Interface
Lattice monitoring
Object oriented implementation in C++ and Python
CompuCellPlayer
CompuCell3D Kernel
Plugins
Python
Typical “Run-Time” Architecture of CompuCell
CompuCell can be run in a variety of ways:
•Through the Player with or without Python interpreter
•As a Python script
•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 pixel-copy 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 pixel-copy 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.
Pixel copy - “blue” pixel (newCell) replaces “yellow” pixel (oldCell)
Change pixel
MCS 21
10000 pixel-copy attempts
MCS 22 MCS 23 MCS 24
10000 pixel-copy attempts
10000 pixel-copy attempts
10000 pixel-copy attempts
Run
Steppables
Run
Steppables
Run
Steppables
100x100x1 square lattice = 10000 lattice sites (pixels)
CompuCell3D Terminology – Visual Guide
Nearest neighbors in 2D and their Euclidian distances from the central pixel
1
1
1
1
2
22
2
3
3
3
3
4
4
4
4 4
4
4
41
1
11
1
1
2 2
2
22
2
3
3
3
3
3
3
4
4
444
4
4
4
44 4
4
2D Square Lattice 2D Hexagonal Lattice
Neighbor Order
Number of Neighbors
Euclidian Distance
Number of Neighbors
Euclidian Distance
1 4 1 6
2 4 6
3 4 2 6
4 8 12
3/2
2 3/6
3/8
14 / 35
Your First CompuCell3D Simulation – Cell Sorting
• 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
2( ( )), ( ( ')) ( ), ( ')
, '
(1 ) ( )x x x x vx x
E J v V
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.TargetVolume(25.0) vpd.LambdaVolume(1.0)
Configure lattice and general simulation parameters
Tell Compucell3D what cell types you will use. Remember to list Medium with type id 0
...)1(...',
)'(),())'(()),(( xx
xxxxJE
Type NameType Id
...)(... 2 VvE v
acceptance
1 if
if H Y
T
H YP H
e H Y
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)
Register lattice configuration section
Register energy functions and cell type specification
Register initial configuration steppable
Width of a single cell
Cell types use to fill region
Specifying initial configuration of cells
Register ParseData objects
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)
Complete listing
35 lines of straightforward code vs at least 1000 lines of C++/Java/Fortran code
import sysfrom os import environimport stringsys.path.append(environ["PYTHON_MODULE_PATH"]) import CompuCellSetup
sim,simthread = CompuCellSetup.getCoreSimulationObjects()
configureSimulation(sim)
CompuCellSetup.initializeSimulationObjects(sim,simthread)
from PySteppables import SteppableRegistrysteppableRegistry=SteppableRegistry()
CompuCellSetup.mainLoop(sim,simthread,steppableRegistry)
To finish the simulation code - reuse boiler-plate code from CompuCell3D examples
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” check-box!
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)
Diffusion field ATTR
Diffusion and decay constants
Preventting ATTR from entering Wall cels
Bacterium secretion constant
Chemotaxis: choosing PDE solver and chemical field name
Setting chemotacting type and chemotaxis strength
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.
Python syntax:
pifpd=CompuCell.PIFInitializerParseData() pifpd.PIFName(“amoebae_2D_workshop.pif")
0,0
Let’s add another cell:
Example (file: amoebae_2D_workshop.pif):
0 Amoeba 10 15 10 15 0 01 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 01 Bacteria 35 40 35 40 0 00 Amoeba 16 16 15 15 0 01 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 01 Bacteria 35 40 35 40 0 00 Amoeba 16 16 15 15 0 02 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…
pifpd=CompuCell.PIFInitializerParseData() pifpd.PIFName(“amoebae.100.pif")
To reload file , say amoebae.100.pif use already familiar syntax:
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.
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
Printing information about all the cells present in the simulation
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 codedef configureSimulation(sim)……………………….. #include earlier code
#import useful modulesimport sysfrom os import environfrom os import getcwdimport string#setup search patthssys.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 heresteppableRegistry=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 includecompd=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