Title: Modelling Course in Population and Evolutionary Biology
1Modelling Course in Population and Evolutionary
Biology
Introduction
Part I The Course Part II R Part III The
Modules (2 x 15 min break)
2Part I The Course
3People
Prof. Sebastian Bonhoeffer Course Director
Viktor Müller Course Instructor
4People module developers
- Martin Ackermann
- Tobias Bergmiller
- Sebastian Bonhoeffer
- Lucy Crooks
- Florence Debarre
- David Fouchet
- Nicole Freed
- Roger Kouyos
- Dusan Misevic
- Viktor Müller
- Roland Regoes
- Olin Silander
- Orkun Soyer
5Feedback
- This course takes place for the third time.
Everything can be changed flexibly, and we
appreciate your feedback!
6Goals
- To get familiar with basic approaches in the
modelling of biological processes - To obtain a conceptual insight into interesting
biological questions - To learn to appreciate the excitement and utility
of computational modelling in biology - To learn team work
7Focus how to make these transitions?
- Foreground modelling
- Background biology math
computer implementation
biological problem
math model/ algorithm
interpretation of model results
8Time table
Place CHN F 46
Daily schedule 9-13 Work on
modules 13-14 Lunch break 14-18
Work on modules Last day (15 June)
presentations in the afternoon
- NOTES
- You are free to take short breaks during the
work sessions. - You can run simulations in the weekends.
Breakdown 4 5 1 10 days total Introduction
½ day Module 1 3.5 days Module 2 4.5
days Preparing presentations 1 day Final
presentations ½ day
- Recommendation
- Complete Module 1 this week.
- Prepare slides on the fly.
flexible
9Organisation of the course
- Team and module choice
- Each team should have at least one member with
some experience in programming - Teams should choose two modules that use
different methods - The same module can be chosen by several teams
- Extensive development of a level 1 module may be
accepted as level 2 at the instructors decision.
In this case the team should choose another level
1 module in addition. - Work on modules
- 1 student/computer
- Instructors help as needed
10Evaluation
- Marks will be based on
- performance during the course
- instructors monitor progress
- completion of modules
- model design
- implementation (functionality of R code)
- scientific results
- final presentation
- ppt or pdf slideshow on level 2 module results
- get the message across
Important note to enable individual evaluation,
each team member should be given responsibility
for particular tasks and participate in the final
presentation.
Students with no prior knowledge of R should also
be able to achieve the highest mark.
11Webpage
https//www.tb.ethz.ch/education/model
- modules
- R resources
- practical information
12Part II R
- Note this section focuses on getting started
with R and on some useful tricks. You should
certainly read the designated chapters of
Introduction to R and you are advised to have
the R reference card at hand.
13What is R?
- R is an integrated suite of software facilities
for data manipulation, calculation and graphical
display. - It is often used for statistics, but it can do
much more. - R is a free implementation of the S language.
14Downloading R
go to http//www.r-project.org/
15Downloading R
scroll down to ETH mirror
16Downloading R
choose your operating system
17Downloading R Windows
click on base
then click on the setup program
and save it to your hard drive.
18Installing R Windows
- Run the setup program from your hard drive.
- install to c\Program Files\R
- Set up a desktop icon for R
- right-click over Desktop
- New gt Shortcut
- browse to c\Program Files\R\R-2.9.0\bin\Rgui.exe
- right-click on desktop icon gt Properties gt Start
from set to \course - Double-click on the icon ready to go!
19Downloading and installing R Mac
CTRL click to download install disk image
Double-click on icon of the multi-package
"R.mpkg" contained in the R-2.4.1.dmg disk image.
20Installing packages in R
go to Packages gt Install packages
- select mirror in Zürich
- click on package odesolve
21Using R
- Type commands directly at the prompt (command
line) - separate commands by newline (ltENTERgt) or
semicolon (ltgt) - use braces to group several commands into an
expression - starting with a hashmark (), everything to the
end of the line is a comment - use vertical arrows to recall previous commands
- Load code from the file menu or with
source(filename) - Code is written as a plain text file.
- on Mac use Rs internal editor
- on Windows Tinn-R (http//www.sciviews.org/Tinn-R
/) provides user-friendly editing of R code
22Getting help
- Type help(command) or ?command
- Or go to help menu.
- If these approaches fail to help
- call us.
23Exiting R
- Type quit() or q()
- or close window.
- You can save all objects at quitting into .RData.
Starting R from the same directory, the workspace
is loaded and you can continue working where you
stopped it.
Keep in mind if you do this, you may have
objects (variables, functions) defined that you
have long forgotten about.
Recommendation use this feature only for short
interruptions in your work, but not on a
day-to-day basis.
24A sample session
switch to R/Tinn-R Options/MainApplication/
/R/General/Path of your preferred
RGui Options/Shortcut customization
(main) R_Sending Line (edit ALTL) download
https//www.tb.ethz.ch/education/model/sample.r
25A sample session function definition
distance lt- function(p1,p2) xdiff p1"x"
- p2"x" ydiff p1"y" - p2"y" diff
sqrt(xdiff2 ydiff2) as.numeric(diff)
gt source(distance.r) gt point1 lt- c(x5,y3) gt
point2 lt- c(x1,y6) gt distance(point1,point2)
Modify the function to calculate distance in n
dimensions.
26Demo a simple reaction kinetics model
k1
k3
E S C E P
k2
EC constant etot
C etot - E
SCP constant stot
P stot S C stot etot S E
27Demo a simple reaction kinetics model
k1
k3
E S C E P
k2
28Demo a simple reaction kinetics model
k1
k3
E S C E P
k2
29Demo a simple reaction kinetics model
- source and read reaction.r
- create pdf figure
- try
- simulationcopy
- simulation-copy
- comment pdf() and print on screen
30Miscellaneous notes
- Introduction to R read Sections 1-3 (pp1-15),
5.1-5.4 (pp18-20), 5.7.1 (p22), 5.8-5.9 (p24), 6
(pp26-28), 7.1-7.2 (pp30-31), 9 (pp40-41), 10.1
(p42), 10.3 (p43), 12.1-12.2 (pp62-66), 12.4-12.6
(pp67-75), 13 (p76). 44 pages total. - Keep a working script for the solution of each
exercise. When a module is completed, we will
check the functionality of the scripts and
discuss their answers to the questions.
31Part III The Modules
32The organization of modules
- Webpage brief description links for download
- Reader (PDF)
- biological and modelling background
- instructions to develop the model
- exercises (basic advanced/additional)
- Starting R script (not all modules)
- Glossary
- Literature Weblinks (optional reading)
- Unless otherwise stated in the reader, completion
of a module requires solving all basic exercises. - this rule is just as flexible as all the others.
33List of modules
- Level 1
- The logistic difference equation and the route to
chaotic behaviour - SIR models of epidemics
- Stochastic effects on the genetic structure of
populations - Within-host HIV dynamics estimation of
parameters - Within-host HIV dynamics the emergence of drug
resistance - Level 2
- Discrete vs. continuous time models of malaria
infections - Evolution of the sex ratio
- Rock-paper-scissors dynamics in space
- Spatial cooperation games
- Stability and complexity of model ecosystems
Are large ecosystems more stable than small ones? - Stochastic simulation of epidemics
- Unstable oscillations and spatial structure The
Nicholson-Bailey model of host-parasitoid dynamics
34Level 1 modules
35The logistic difference equation andthe route to
chaotic behaviour
- Basic problem
- many species have non-overlapping generations and
may therefore be described better in discrete
time - logistic growth self-limitation
- discrete steps allow for overshooting ?
oscillations, chaos - General approach iterate difference equation
- Concepts
- chaos
- periodic behaviour
- bifurcations
36The logistic difference equation and the route
tochaotic behaviour
- Methods
- time plots
- phase diagrams
- bifurcation diagrams
- Questions
- what types of behaviour are possible in the LDE?
- what defines chaotic behaviour?
- analyse bifurcation diagram
- introduce space
37SIR models of epidemics
- Basic problem what factors govern the spread of
infectious diseases? - General approach
- numerical integration of ODE model
- Concepts
- basic reproductive ratio
- herd immunity
- Methods
- time plot
- phase portrait
- contour plot
38SIR models of epidemics
- Questions
- what are the conditions for the outbreak of an
epidemic? - what fraction of a population is going to be
infected? - can partial vaccination be protective?
- model treatment, drug resistance and birth-death
dynamics
39Stochastic effects on the geneticstructure of
populations
- Basic problem
- genetic drift can destroy variation, counteract
selection and build up associations between loci - General approach
- simple population genetic models with mutation,
selection, recombination and random sampling of
offspring - Concepts methods
- iteration of discrete time population genetics
model - interplay of selection and drift
- benefits of recombination
- sampling from binomial distribution
- Questions
- How does drift reduce the diversity that mutation
builds up? - How does drift affect the elimination of
detrimental alleles through selection? - How do bottlenecks affect the diversity at
neutral and selected loci? - What do effective population sizes tell about the
magnitude of stochastic effects?
40Within-host HIV dynamics 1estimation of
parameters
- Basic problem
- The apparent latency of HIV infection conceals a
highly dynamic steady state. Perturbation by drug
treatment reveals the dynamics. - General approach
- Estimation of decay parameters by fitting a
simple ODE model to real and simulated treatment
data.
41Within-host HIV dynamics 1estimation of
parameters
- Concepts methods
- Model fitting Parameter estimation by
non-linear minimization. - Numerical simulation of ODEs.
- Questions
- What factors influence the quality of parameter
estimation? - How does random noise (measurement error) affect
the estimation? - What if treatment is not 100 effective?
- What is the effect of long-lived virus-producing
cells?
42Within-host HIV dynamics 2the emergence of
drug resistance
- Basic problem
- Mutations in the enzymes of HIV can render the
virus resistant to drugs. - General approach
- ODE models to simulate wild-type and mutant virus.
43Within-host HIV dynamics 2the emergence of
drug resistance
- Concepts methods
- numerical simulation of ODEs
- mutation-selection equilibrium
- Questions
- What are the conditions for the emergence of drug
resistance? - How does the efficacy of the drugs affect the
time to the emergence of resistance? - Resistance mutations can exist in a
mutation-selection equilibrium even before
treatment how does this affect the emergence of
resistance under therapy? - What is the advantage of administering a
combination of different drugs? - Devise optimal treatment strategy
44Level 2 modules
45Unstable oscillations and spatial structure The
Nicholson-Bailey model of host-parasitoid dynamics
- Basic problem
- A discrete-time model of host-parasite
interactions is unstable. Can the implementation
of space stabilize the system? - General approach
- Model host-parasite interactions and dispersal on
a 2D lattice.
46Unstable oscillations and spatial structure The
Nicholson-Bailey model of host-parasitoid dynamics
- Concepts methods
- Simulation of simple two-species difference
equations - Simulate spatial structure and observe emerging
patterns - Questions
- Why is the simple NB model unstable?
- What is the effect of spatial structure?
- What is the effect of lattice size and boundary
conditions? - Do initial conditions affect the outcome?
- Can parasitoids facilitate the coexistence of
different host types?
47Spatial cooperation games
- Basic problem altruistic behaviour decreases the
fitness of the actor. So how can it evolve and be
maintained? - General approach simulate iterated cooperation
games in unstructured and spatially structured
populations. - Concepts
- Game theory Prisoners dilemma and snowdrift
games. - Spatial structure and the evolution of
cooperation.
- Methods
- Spatially explicit simulation of population
interactions on a lattice - Cellular automaton
48Spatial cooperation games
- Questions
- How does spatial structure affect the evolution
of cooperation? - What is the effect of the payoff parameters
(cost, benefit)? - Investigate the effects of
- neighbourhood size (3,4,6)
- updating scheme (synchronous vs. asynchronous
pair-wise vs. multiple competitions) - population size (500, 1000, 2000)
- heterogeneous environment
- on the evolution of cooperation and the
significance of spatial structure.
49Rock-paper-scissors dynamics in space
- Basic problem can intransitive fitness
interactions facilitate the maintenance of
diversity? - General approach model local competition in a
cellular automaton - Concepts
- intransitive interaction AltB, BltC, CltA
- density dependent selection
lt
lt
lt
50Rock-paper-scissors dynamics in space
- Questions
- How does the maintenance of diversity depend on
- the type and strength of fitness interactions
- initial population size and species frequencies
- The distance over which organisms
interact/disperse? - What factors affect the magnitude of population
fluctuations? - How do the dynamics of the system change when
there are greater numbers of species interacting? - What is the effect of disturbance (e.g. local
fires) on the maintenance of diversity?
51Stability and complexity in model ecosystems
- Basic problem Does complexity help stability?
- General approach study stability of randomly
generated multi-species Lotka-Volterra systems. - Concepts methods
- Connectivity, diversity and stability of an
ecosystem/network - Numerical simulation of (large) systems of
ordinary differential equations - Questions
- How does ecosystem stability depend on the size
(i.e. number of species) and connectivity of the
ecosystem? - What are useful measures of ecosystem stability?
- Does the coexistence of a set of species depend
on the order in which they were introduced into
an ecosystem? - How does the ecosystem respond to the removal or
invasion of a species? - How does stability change if some interactions
are predatory?
52Discrete versus continuous-time modelsof malaria
infections
- Basic problem
- Malaria parasites reproduce in discrete
generations. What is the effect of simplifying
this to continuous-time models?
53Discrete versus continuous-time modelsof malaria
infections
- General approach
- Compare discrete and continuous-time models of
malaria. - Concepts methods
- Numerical simulation of ODEs and difference
equations - Trade-offs and evolutionary optimum
- Questions
- How to parameterize the models to achieve maximal
equivalence? - Can you obtain identical behaviour?
- What level of gametocyte investment maximises
transmission? - Model an immune function/compartments/variable
investment
54Evolution of the sex ratio
- Basic problem why is the typical sex ratio 11?
- General approach
- simulate a population of males and females
- sex ratio of offspring determined by a diploid
locus in the mother - introduce sex ratio mutants and run until
evolutionary equilibrium - Concepts methods
- evolutionary optimization
- individual-based modelling
- stochastic simulation
- Questions
- optimal sex ratio for various inheritance schemes
of the SR gene - what happens if the sexes have different survival
or cost? - what if the SR gene is located on a sex
chromosome?
55Stochastic simulation of epidemics
- Basic problem
- Introduce stochasticity and discrete populations
into the SIR model - General approach
- Stochastic modelling with the Gillespie algorithm
- Concepts methods
- Comparison of deterministic and stochastic models
- Simulation and analysis of stochastic models
- Questions
- What is the extinction probability of the
infection for different R0's? - Does the average dynamics of the stochastic model
differ from the deterministic SIR model? - Are population sizes across runs normally
distributed?
56Note
- Completion of a module is defined flexibly you
are free to deviate from the pre-defined
exercises and work on your own ideas. Consult the
instructor. - Keep a working version of your script for each
exercise.
57Background information
- Ecology and Evolution II Populations
- 701-0273-00l WS (Bachelor BIOL 5th term/ Master
UWIS) - by Sebastian Bonhoeffer
58Reminder team and module choice
- Each team should have at least one member with
some experience in programming - Teams should choose two modules that use
different methods - The same module can be chosen by several teams
- Extensive development of a level 1 module may be
accepted as level 2 at the instructors decision.
In this case the team should choose another level
1 module in addition.
59Contact
- viktor.mueller_at_env.ethz.ch