Upload
lewis-wilcox
View
218
Download
0
Tags:
Embed Size (px)
Citation preview
Modelling Course in Population and Evolutionary Biology
1 June 2015, Zürich
Introduction
1. The Course
2. Getting Started with R
3. The Modules
4. Teams form
5. R continued
1. The Course
People
Prof. Sebastian Bonhoeffer
Course Director
Viktor Müller
Course Instructor
Wim Delva
Course Instructor
People: 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
And you are?
Goals
To get familiar with basic approaches in the modelling of biological processes
To learn to appreciate the excitement and utility of computational modelling in biology
To obtain conceptual insight into interesting biological questions
To learn team work
To see a project through from beginning to end
Focus: how to make these transitions?
Foreground: modelling Background: biology + math
biologicalproblem
math model/algorithm
computerimplementation
interpretation of model results
Walking the fine line
Everything should be made as simple as possible … but not simpler.
Focus: how to make these transitions?
Foreground: modelling Background: biology + math
biologicalproblem
math model/algorithm
computerimplementation
interpretation of model results
Time table
Daily schedule:
8.30-12.30 Work on modules12.30-13.30 Lunch break13.30-17.30 Work on modules
Last day (12 June): presentations in the afternoon
NOTES:
• You are free to take short breaks during the work sessions.
• Please, report your absence in advance.
Recommendation:
• Switch to Module 2 on Thursday.
• Prepare slides on the fly.
flexible
Place: CHN F 46
Breakdown
10 days total
Introduction: 3/4 day
Module 1: ~2 ¼ days
Module 2: 6 days
Finalizing presentations: 1/2 day
Presentations: 1/2 day
Team and module choice
Each team should ideally have at least one member with some experience in programming
Teams should choose two modules that use different methods (topics might be connected)
The same module can be chosen by several teams
Extensive development of a level 1 module may be accepted as level 2 at the instructor’s decision.
Team work
Discuss the problems.
Consult about the implementation.
Discuss the results.
BUT: write code independently (as well)
Keep a working script for the solution of each exercise and a record of the results to help us check and discuss your progress.
Instructors help as needed
Evaluation
Marks will be based on performance during the course
instructors monitor progress completion of modules
model design, questions (creativity)implementation (functionality of R code)“scientific” results
final presentationppt or pdf slideshow on level 2 module resultsget 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.
Webpage
modules R resources practical
information
http://www.tb.ethz.ch/education/learningmaterials/modelingcourse.html
How To
Connect to the net: wi-fi network: public/eth ETH or guest account to access external sites VPN or website login
Print: send to public printers (VPP) register VPP password:
www.passwort.ethz.ch /Meine Services / VPP PIN
vpp.ethz.ch (easy to remember central link) http://idvpp01.ethz.ch/vpppdf.html (direct link
for pdf printing) PIN + <E> the nearest printer is CHNF43. (device: X5550)
2. Getting Started with 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.
What 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.
Download and install R
go to http://www.r-project.org/
Download and install RStudio
go to http://rstudio.org/available for all platforms: Win/Mac/Linux
Using R
Type commands directly at the prompt (command line/console)
separate commands by newline (<ENTER>) or semicolon (<;>)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 R’s internal editor or RStudioon Windows: RstudioLinux: Rstudio or RKWard
Getting help
Type help(command) or ?command
Or: go to help menu (+links for online help).
Careful: versions might differ.
If these approaches fail to help…
call us.
Exiting 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.
A sample session
switch to R/RStudio
download: sample.r
3. The Modules
The organization of modules
Webpage: brief description + links for download Reader (PDF)
biological and modelling backgroundinstructions to develop the modelexercises (basic + advanced/additional)
Starting R script (not all modules) Glossary Literature & Weblinks (optional reading)
use the Internet wisely
Unless otherwise stated in the reader, completion of a module requires solving all basic exercises.
List 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
• Network models of epidemics
• 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
Level 1 modules
The logistic difference equation andthe route to chaotic behaviour
Basic problem:Many species have non-overlapping generations and may therefore be described better in discrete timeLogistic growth: self-limitationDiscrete steps allow for overshooting oscillations, chaos
General approach: iterate difference equation Concepts
ChaosPeriodic behaviourBifurcations
The logistic difference equation and the route tochaotic behaviour
Methodstime plotsphase diagramsbifurcation diagrams
QuestionsWhat types of behaviour are possible in the LDE?What defines chaotic behaviour?Analyse bifurcation diagramIntroduce space
SIR models of epidemics
Basic problem: what factors govern the spread of infectious diseases?
General approachnumerical integration of ODE model
Conceptsbasic reproductive ratioherd immunity
Methodstime plotphase portrait
SIR models of epidemics
QuestionsWhat 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
Stochastic effects on the geneticstructure of populations
Basic problemGenetic drift can destroy variation, counteract selection and build up associations between loci.
General approachSimple population genetic models with mutation, selection, recombination and random sampling of offspring
Concepts & methodsIteration of discrete time population genetics modelInterplay of selection and driftBenefits of recombinationSampling from binomial/multinomial distribution
QuestionsHow 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?
Within-host HIV dynamics #1:estimation of parameters
Basic problemThe apparent latency of HIV infection conceals a highly dynamic steady state. Perturbation by drug treatment reveals the dynamics.
General approachEstimation of decay parameters by fitting simple ODE models to real and simulated treatment data.
Within-host HIV dynamics #1:estimation of parameters
Concepts & methodsModel fitting – Parameter estimation by non-linear minimization.Lesson: no such thing as an “objective” estimate.Numerical simulation of ODEs.
QuestionsWhat 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?
Within-host HIV dynamics #2:the emergence of drug resistance
Basic problemMutations in the enzymes of HIV can render the virus resistant to drugs.
General approachODE models to simulate wild-type and mutant virus.
Within-host HIV dynamics #2:the emergence of drug resistance
Concepts & methodsNumerical simulation of ODEsMutation-selection equilibrium
QuestionsWhat 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
Level 2 modules
Unstable oscillations and spatial structure: The Nicholson-Bailey model of host-parasitoid dynamics
Basic problemA discrete-time model of host-parasite interactions is unstable. Can the implementation of space stabilize the system?
General approachModel host-parasite interactions and dispersal on a 2D lattice.
Unstable oscillations and spatial structure: The Nicholson-Bailey model of host-parasitoid dynamics
Concepts & methodsSimulation of simple two-species difference equationsSimulate spatial structure and observe emerging patterns
QuestionsWhy 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?
Spatial 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.
ConceptsGame theory: Prisoner’s dilemma and snowdrift games.Spatial structure and the evolution of cooperation.
MethodsSpatially explicit simulation of population interactions on a latticeCellular automaton
Spatial 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.
Rock-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
Conceptsintransitive interaction: A<B, B<C, C<A
density dependent selection
< < <
Rock-paper-scissors dynamics in space
Questions: How does the maintenance of diversity depend
onthe type and strength of fitness interactionsinitial population size and species frequenciesThe 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?
Stability 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/networkNumerical simulation of (large) systems of ordinary differential equations
QuestionsHow 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?
Discrete 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?
Discrete versus continuous-time modelsof malaria infections
General approachCompare discrete and continuous-time models of malaria.
Concepts & methodsNumerical simulation of ODEs and difference equationsTrade-offs and evolutionary optimum
QuestionsHow 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
Evolution of the sex ratio
Basic problem: why is the typical sex ratio 1:1? General approach
Simulate a population of males and femalesSex ratio of offspring determined by a diploid locus in the motherIntroduce sex ratio mutants and run until evolutionary equilibrium
Concepts & methodsEvolutionary optimizationIndividual-based modellingStochastic simulation
QuestionsOptimal sex ratio for various inheritance schemes of the SR geneWhat happens if the sexes have different survival or cost?What if the SR gene is located on a sex chromosome?
Stochastic simulation of epidemics
Basic problemIntroduce stochasticity and discrete populations into the SIR model
General approachStochastic modelling with the Gillespie algorithm
Concepts & methodsComparison of deterministic and stochastic modelsBasic reproductive ratio, herd immunity etc
QuestionsWhat is the extinction probability of the infection for different values of R0?
Does the average dynamics of the stochastic model differ from the deterministic SIR model? Are population sizes across runs normally distributed?
Network models of epidemics
Basic problemMany infectious diseases require close contact for transmission: this is not so in simple models.
General approachImplement a contact network.Let the infection spread over contacts.
Network models of epidemics
Concepts & methods Individual-based models Simulation and analysis of networks (graphs)
Questions How does network structure affect epidemic spread? What is the optimal treatment or vaccination strategy
over a network? How do networks change over time? “Asexual” and sexual contact networks Network structure and the evolution of virulence
Note
“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.
See the “Big Picture”, do not get (overly) lost in details.
Consider the time limit.
Keep a working version of your script for each exercise.
Background information
Ecology and Evolution II: Populations701-0273-00l WS (Bachelor BIOL 5th term/ Master
UWIS)by Sebastian Bonhoeffer
Reminder: 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 instructor’s decision.
A sample session: function definition
> source(“distance.r”)
> point1 <- c(5,3)
> point2 <- c(1,6)
> distance(point1,point2)
Modify the function to calculate distance in n dimensions.
distance <- function(p1,p2){
diff1 = p1[1] – p2[1]
diff2 = p1[2] – p2[2]
diff = sqrt(diff1^2 + diff2^2)
diff
}
Demo: a simple reaction kinetics model
E + S C E + Pk1
k2
k3
Ckdt
dP
CkkESkdt
dC
CkkESkdt
dE
CkESkdt
dS
3
321
321
21
E+C = constant : etot
S+C+P = constant : stot
C = etot - E
P = stot – S – C = stot – etot – S + E
Demo: a simple reaction kinetics model
E + S C E + Pk1
k2
k3
ESesP
EeC
CkkESkdt
dE
CkESkdt
dS
tottot
tot
321
21
Demo: a simple reaction kinetics model
E + S C E + Pk1
k2
k3
ESesP
EeC
EekkESkdt
dE
EekESkdt
dS
tottot
tot
tot
tot
321
21
Demo: a simple reaction kinetics model
source and read reaction.r tip: read the main program first, then the functions
create pdf figure try:
> simulation==copy> simulation-copy> comment pdf() and print on screen
Contact
Structure of the presentation
Scientific presentation! Introduction:
Biological background Define the problem. Why is it important? Outline the methods (model structure).
Results & Discussion: Interpret the model results: relevance? Limits of the results (assumptions)
Conclusions: Summarize the main points.
Target audience: The interested non-specialist.
Technical notes
Schedule:
Prepare until Friday, 12.00. (plan your time!)
Presentations: 13.00–
30 minutes per group (10 min/person)
Rule of thumb: 1 slide per minute
Everyone should present (but: 1 file/group). Select appropriate font size!!!
Feel free to ask questions during the talks.
ppt(x) or pdf
Schedule of talks
I need to receive the files by 12.50.
13.00-13.30 Rock-paper-scissors
13.40-14.10 Spatial cooperation games
14.20-15.00 Evolution of the sex ratio
break
15.30-16.10 Stochastic sim of epidemics
16.20-16.50 Network models of epidemics
16.50- Final “round-table” discussion
PLEASE, COMPLETE ONLINE EVALUATION FORM.