Upload
pinedakrch
View
217
Download
0
Embed Size (px)
Citation preview
8/3/2019 Pineda-Krch CMB2011 2lides
1/56
Cycles in finite populations
A reproducible seminar in three acts
Mario Pineda-Krch
October 31, 2011
1
8/3/2019 Pineda-Krch CMB2011 2lides
2/56
Act 1: The ghost of Fermat
(The what, why and how of reproducible research)
Act 2: A tale of two cycles(Demonstrating the existence of quasi-cycles using reproducible
research)
Act 3: Cycles at the edge of existence(Emergence of quasi-cycles in strongly destabilized ecosystems)
2
8/3/2019 Pineda-Krch CMB2011 2lides
3/56
Act 1: The ghost of Fermat
3
8/3/2019 Pineda-Krch CMB2011 2lides
4/56
Irreproducible research
Randall J. LeVeque (2006)
Scientific and mathematical journals are filled with pretty pictures
these days of computational experiments that the reader has nohope of repeating. Even brilliant and well intentionedcomputational scientists often do a poor job of presenting theirwork in a reproducible manner. The methods are often very
vaguely defined, and even if they are carefully defined they wouldnormally have to be implemented from scratch by the reader inorder to test them. Most modern algorithms are so complicatedthat there is little hope of doing this properly.
Pierre de Fermat (1637)It is impossible to separate a cube into two cubes, or a fourthpower into two fourth powers, or in general, any power higher thanthe second, into two like powers. I have discovered a trulymarvellous proof of this, which this margin is too narrow to
contain.4
8/3/2019 Pineda-Krch CMB2011 2lides
5/56
What really happened?
Reproducible results = Reproducible research
5
8/3/2019 Pineda-Krch CMB2011 2lides
6/56
Reproducible research: Its not the destination. Its thejourney.
6
8/3/2019 Pineda-Krch CMB2011 2lides
7/56
Reproducible research: The What
LeVeque (2006):The idea of reproducible research in scientific computing is toarchive and make publicly available all of the codes used to createthe figures or tables in a paper in such a way that the reader can
download the codes and run them to reproduce the results.Wikipedia:
Reproducibility is one of the main principles of the scientificmethod, and refers to the ability of a test or experiment to be
accurately reproduced, or replicated, by someone else workingindependently.
7
8/3/2019 Pineda-Krch CMB2011 2lides
8/56
Reproducible research: The Why
American Physical Society
Science is the systematic enterprise of gathering knowledge aboutthe universe and organizing and condensing that knowledge into
testable laws and theories. The success and credibility of scienceare anchored in the willingness of scientists to: Expose their ideasand results to the independent testing and replication by others.This requires the open exchange of data, procedure and materials.
Reproducability = Transparency + Executability
8
8/3/2019 Pineda-Krch CMB2011 2lides
9/56
Journal article
Processed data
Raw data
Computer simulations
Computer code
Algorithms
6
?Autho
r
Reader
9
8/3/2019 Pineda-Krch CMB2011 2lides
10/56
Literate programmingA paradigm for reproducible research in computational sciences
The idea is that you do not
document programs (after thefact), but write documentsthat contain the programs. John Max Skaller
10
8/3/2019 Pineda-Krch CMB2011 2lides
11/56
Literate programming according to Donald Knuth
Prose
ProgramDocumentation
TangleWeave
11
8/3/2019 Pineda-Krch CMB2011 2lides
12/56
Literate programming systems
LP system Document formatting language Programming language Inventor(s) YearWEB TEX Pascal Knuth 1992CWEB TEX C/C++/Java Knuth & Levy 1993FWEB LATEX C/C++/FORTRAN Krommes 1993
noweb TEX/LATEX/HTML/troff agnostic Ramsey 1999Sweave LATEX R Leisch 2002PyLit reStructuredText Python Milde 2005Pweave LATEX/reST/Sphinx/Pandoc Python Pastell 2010
12
8/3/2019 Pineda-Krch CMB2011 2lides
13/56
Literate programming according to RThe evolution of the literate programming paradigm
Prose
CodeDocumentation
StangleSweave
13
8/3/2019 Pineda-Krch CMB2011 2lides
14/56
What really happens
Prose
CodeDocumentation
Results
StangleSweave
Sweave
Execute
Integrate
14
8/3/2019 Pineda-Krch CMB2011 2lides
15/56
This research is reproducible!
These slides are prepared using Sweave.
These slides are executable (look for ). The full project (source, code, results, etc.) will be available
at http://pineda-krch.com.
15
http://pineda-krch.com/http://pineda-krch.com/http://pineda-krch.com/8/3/2019 Pineda-Krch CMB2011 2lides
16/56
Implementing reproducible research
Attach code to publish results is good...,
executable manuscripts are better.
Adopt a habit of reproducibility, i.e. make it routine and
require it from others (students, postdocs, colleagues). Keep reproducibility in computational research to the same
rigorous standard as reproducibility in mathematical proofs.
Demand reproducibility in your role as journal editor and
reviewer of manuscripts and grants applications.
16
8/3/2019 Pineda-Krch CMB2011 2lides
17/56
Act 2: A tale of two cycles
17
O ( ) G
8/3/2019 Pineda-Krch CMB2011 2lides
18/56
Olaus Magnus (1555) Historia de Gentibus
First known depiction of of population cycles in Olaus Magnus
Historia de Gentibus Septentrionalibus (History of the NorthernPeoples) (1555) shows lemmings falling from the sky with twoweasels with lemmings in their mouths.
18
El (1924) B i i h J l f E i l Bi l
8/3/2019 Pineda-Krch CMB2011 2lides
19/56
Elton (1924) British Journal of Experimental Biology
19
K d ll l (1998) E l L
8/3/2019 Pineda-Krch CMB2011 2lides
20/56
Kendall et al. (1998) Ecology Letters
20
Fl t ti l ti
8/3/2019 Pineda-Krch CMB2011 2lides
21/56
Fluctuating populations
1750 1800 1850 1900
0
20000
60000
Lynx
1850 1860 1870 1880 1890 1900 1910
6000
10000
140
00
18000
Populationsize
Otter
1750 1800 1850 1900
0
500
1500
2500 Wolverine
21
E l i i l l ti d i i i l
8/3/2019 Pineda-Krch CMB2011 2lides
22/56
Explaining complex population dynamics using simplemodels
Classical Lotka-Volterra Exponential growth in prey, linear (Type 1) functional response
in predator Structurally unstable, mainly of historical interest
Lotka-Volterra Logistic growth in prey, linear (Type 1) functional response in
predator Does not cycle
Rosenzweig-MacArthur Logistic growth in prey, non-linear (Type 2) functional
response in predator (i.e. satiation) Cycles
22
R s ig M A th d t d l (RMPP)
8/3/2019 Pineda-Krch CMB2011 2lides
23/56
Rosenzweig-MacArthur predator-prey model (RMPP)
dNdt = rN
1 NK
a1 + wNNP
dPdt = c
a1 + wNNP gP
23
The deterministic RMPP in R
8/3/2019 Pineda-Krch CMB2011 2lides
24/56
The deterministic RMPP in R
> ode.rmpp
8/3/2019 Pineda-Krch CMB2011 2lides
25/56
The stochastic RMPP in R
> ssa.rmpp
8/3/2019 Pineda-Krch CMB2011 2lides
26/56
Structure of simulation model
rmpp.R
ssa.rmpp.Rode.rmpp.R
ssa_rmpp.c
26
Run a simulation in the stable node region
8/3/2019 Pineda-Krch CMB2011 2lides
27/56
Run a simulation in the stable node region
Set the parameters
> alpha beta gamma alpha; beta; gamma
[1] 0.5
[1] 1
[1] 1.2
Set equilibrium population size
> eq tmax n < - 1
27
Run a simulation in the stable node region
8/3/2019 Pineda-Krch CMB2011 2lides
28/56
Run a simulation in the stable node region
Run the simulation
> fn.node fn.node
[1] "../results/rmpp-alpha0.5-beta1-gamma1.2-eq1000-1.RData"
Loading the data> load(fn.node)
Looking at the contents of the data file
> ls()
[1] "alpha" "beta" "d.lynx" "d.otter" "d.wolveri[6] "eq" "fn" "fn.node" "gamma" "i"
[11] "n" "ode.res" "ode.rmpp" "parms" "rmpp"
[16] "ssa.res" "ssa.rmpp" "start.time" "tmax" "x0"
28
Plot results
8/3/2019 Pineda-Krch CMB2011 2lides
29/56
Plot results> layout(matrix(c(1,2), ncol=2))
> ymax ymin plot(N~time, ode.res, type='l', lwd=3, col=rgb(0,1,0,.75),
xlab="Time", ylab="Population size", xlim=c(0, 250), ylim=c(ymin, ymax), bty='n')
> points(P~time, ode.res, type='l', lwd=3, col=rgb(1,0,0,.75))> title('Deterministic')
> plot(N~time, ssa.res, type='l', lwd=3, col=rgb(0,1,0,.75),
xlab="Time", ylab="", xlim=c(0, 250), ylim=c(ymin, ymax), bty='n')> points(P~time, ssa.res, type='l', lwd=3, col=rgb(1,0,0,.75))
> title('Stochastic')
0 50 100 150 200 250
400
600
800
1000
1200
1400
Time
Population
size
Deterministic
0 50 100 150 200 250
400
600
800
1000
1200
1400
Time
Stochastic
Figure: Time series for RMPP model in stable node region ( = 0.5, = 1, = 1.2).
29
Run a simulation in the limit cycle region
8/3/2019 Pineda-Krch CMB2011 2lides
30/56
Run a simulation in the limit cycle region
0 50 100 150 200 250
0
500
1000
2000
3000
Time
Population
size
Deterministic
0 50 100 150 200 250
0
500
1000
2000
3000
Time
Stochastic
Figure: Time series for RMPP model in limit cycle region ( = 0.5,
= 1, = 3.5).
30
Run a simulation in the stable focus region
8/3/2019 Pineda-Krch CMB2011 2lides
31/56
Run a simulation in the stable focus region
0 50 100 150 200 250
500
1000
1500
Time
Population
size
Deterministic
0 50 100 150 200 250
500
1000
1500
Time
Stochastic
Figure: Time series for RMPP model in stable focus region = 0.5,
= 1, = 2.5).
31
Detecting periodic fluctuations in simulated time
8/3/2019 Pineda-Krch CMB2011 2lides
32/56
Detecting periodic fluctuations in simulated time
series
100 150 200 250 300 350
600
800
1000
1200
Node
100 150 200 250 300 350
600
1000
1400
18
00
Population
size
Focus
100 150 200 250 300 350
0
500
1500
2500
Limit cycle
32
Autocorrelation Function (ACF)
8/3/2019 Pineda-Krch CMB2011 2lides
33/56
( C )Detecting periodic fluctuations
0 10 20 30 40
0.0
0.2
0.4
0.6
0.8
1.0
ACF
Node
0 5 10 15 20 25 30
0.5
0.0
0.5
1.0
Lag
Focus
0 5 10 15 20 25 30
0.5
0.0
0.5
1.0
Limit cycle
Evidence of periodicity if ACF(T) > 2/tm where T is the lag ofthe dominant frequency (first maximum), tm is the number of datapoints in the time series.
33
8/3/2019 Pineda-Krch CMB2011 2lides
34/56
Marginal distribution
8/3/2019 Pineda-Krch CMB2011 2lides
35/56
gDistinguishing between quasi-cycles and noisy limit cycles
Node
Frequency
600 800 1000 1200
0
500
1000
150
0
2000
2500
3000
Focus
Prey population size
600 1000 1400 1800
0
50
100
150
200
Limit cycle
0 500 1500 2500
0
50
100
150
Evidence of limit cycle: bimodal distribution
35
8/3/2019 Pineda-Krch CMB2011 2lides
36/56
Detecting periodic fluctuations in natural time
8/3/2019 Pineda-Krch CMB2011 2lides
37/56
series
1750 1800 1850 1900
0
20000
60000
Lynx
1850 1860 1870 1880 1890 1900 1910
6000
10000
14000
18000
Population
size
Otter
1750 1800 1850 1900
0
500
1500
2500 Wolverine
37
Lynx timeseries
8/3/2019 Pineda-Krch CMB2011 2lides
38/56
1750 1800 1850 1900
0
20000
60000
Year
Populationsize
q qqq
qqqqqqqqq
qqq
q
qqqqqqqqqqqq
qqqq
q
qqqq
q
qqqqqqqqqqq
q
q
qqqqq
qqqqqqq
qqqq
2.0 1.5 1.0 0.5
4
5
6
7
8
9
10
log10(Cycle frequency)
log
10(Power)
0 5 10 15 200.2
0.2
0.4
0.6
0.8
1.0
Lag
ACF
Population size
F
requency
0 20000 40000 60000 80000
0
20
40
60
80
100
38
Otter timeseries
8/3/2019 Pineda-Krch CMB2011 2lides
39/56
1850 1870 1890 1910
6000
10000
14
000
18000
Year
Populationsize
q q q q
qqqq
qqqqqqqq
q
qqq
q
q
qqqq
1.5 1.0 0.5
4
5
6
7
8
9
10
log10(Cycle frequency)
log
10(Power)
0 5 10 15
0.2
0.2
0.40
.6
0.8
1.0
Lag
ACF
Population size
F
requency
5000 10000 15000 20000
0
5
10
15
39
Wolverine timeseries
8/3/2019 Pineda-Krch CMB2011 2lides
40/56
1750 1800 1850 1900
0
500
1000
2000
Year
Populationsize
q
q
q
qqqqq
q
q
qqq
qqqqqq
q
q
q
qqqqq
qqqqqq
q
qqqq
qqq
qqqq
qqqq
q
qqqq
q
q
qqqq
2.0 1.5 1.0 0.5
4
5
6
7
8
9
10
log10(Cycle frequency)
log10(Power)
0 5 10 15 20
0.2
0.2
0.4
0.6
0.8
1.0
Lag
ACF
Population size
F
requency
0 500 1000 2000
0
5
10
15
20
25
30
40
Conclusions
8/3/2019 Pineda-Krch CMB2011 2lides
41/56
Time series ACF Power spectrum Marginal distribution Stochastic behaviourSimulated
node none uniform normal noisy equilibriumfocus periodic periodic normal quasi-cycles
limit cycle periodic periodic non-normal noisy limit cycleReal
lynx periodic periodic non-normal noisy limit cycleotter none uniform normal noisy equilibriumwolverine periodic ambiguous normal quasi-cycles
41
Quasi-cycles are not new
8/3/2019 Pineda-Krch CMB2011 2lides
42/56
Nisbet & Gurney, 1976
...population cycles of rather large amplitude may occur when anunderdamped control system is subject to random environmentalnoise, and we suggest that this mechanism is worthy ofconsideration when analyzing real populate data.
McKane & Newman, 1998We expect that this resonance mechanism will occur in otherstochastic systems in which the mean field theory shows dampedoscillations, for instance, biochemical reactions in microscopicsystems.
Pineda-Krch, 2007...the existence of quasi-cycles should generalize to anydeterministic model that exhibits a stable focus and is perturbed bynoise.
42
Parameter space for RMPP model
8/3/2019 Pineda-Krch CMB2011 2lides
43/56
0.0 0.2 0.4 0.6 0.8 1.0
0
2
4
6
8
10
Saddle point (unstable)
Nod
eFocus
Limit cycle
q
q
q
43
8/3/2019 Pineda-Krch CMB2011 2lides
44/56
Act 3: Cycles at the edge of
existence
44
Lotka Volterra predator-prey (LVPP) model
8/3/2019 Pineda-Krch CMB2011 2lides
45/56
dNdt = rN
1 NK
cNP
dPdt = bNP mP
45
Simplifying the model
8/3/2019 Pineda-Krch CMB2011 2lides
46/56
To simplify the LVPP model the number of parameters are reducedby defining x
N/K, y
Pa/r and t
rt the model can be
rescaled todxdt
= x(1 x y)
dy
dt
= y
caKr
x
g
caK
.
Setting (g/(caK)) and (caK)/r, this further simplifies todxdt
= x(1 x y)
dydt
= y(x )
where > 0 and > 0.
46
Stable coexistence equilibrium
8/3/2019 Pineda-Krch CMB2011 2lides
47/56
q
0.001 0.200 0.400 0.600 0.800 1.000
0
1
2
3
4
5
6
7
8
9
10
Node
Focus
47
Structure of simulation model
8/3/2019 Pineda-Krch CMB2011 2lides
48/56
lvpp.R
ssa.lvpp.Rode.lvpp.R
ssa_lvpp.c
(The R code is here..., but the output is suppressed) 48
Simulations
8/3/2019 Pineda-Krch CMB2011 2lides
49/56
Set the parameter combinations> alpha.vec beta.vec eq.vec tmax n for (beta in beta.vec) {
for (alpha in alpha.vec) {
for (eq in eq.vec) {file.names
8/3/2019 Pineda-Krch CMB2011 2lides
50/56
0.1
0.1
0.2
0.20.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.001 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000
0
1
2
3
4
5
6
7
8
9
10
0.95
50
Quasi-cycle rate
8/3/2019 Pineda-Krch CMB2011 2lides
51/56
0.1 0.1
0.2
0.2
0.30.4
0.5
0.6
0.7
0.8
0.9
1
0.001 0.200 0.400 0.600 0.800 1.000
0
1
2
3
4
5
6
7
8
9
10
0.95
eq=500
0.1
0.1
0.2
0.2
0.3
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.001 0.200 0.400 0.600 0.800 1.000
0
1
2
3
4
5
6
7
8
9
10
0.95
eq=1000
0.1
0.1
0.2
0.2
0.3
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.001 0.200 0.400 0.600 0.800 1.000
0
1
2
3
4
5
6
7
8
9
10
0.95
eq=5000
0.1 0.1
0.2
0.2
0.30.4
0.5
0.60.7
0.8
0.9
1
0.001 0.200 0.400 0.600 0.800 1.000
0
1
2
3
4
5
6
7
8
9
10
0.95
eq=10000
51
Extinction rate, eq=500
8/3/2019 Pineda-Krch CMB2011 2lides
52/56
0
.1
0.1
0.2
0.2
0.3
0.3
0.4
0.4
0.5
0.6
0.7
0.8
0.9
1
0.001 0.100 0.200 0.300 0.400 0.500 0.600 0.700 0.800 0.900 1.000
0
1
2
3
4
5
6
7
8
9
10
0.95
52
Conclusions
8/3/2019 Pineda-Krch CMB2011 2lides
53/56
In non-cyclic models quasi-cycles arise only in part of theregion exhibition damped oscillations
These results are consistent for population sizes across 3orders of magnitude
For small population sizes quasi-cycles arise close to the pointof extinction
Potential for using quasi-cyclicity for quantifying extinctionrisks in PVA
How common are limit cycles in natural populations?
53
AcknowledgementsAct 1:
8/3/2019 Pineda-Krch CMB2011 2lides
54/56
Act 1:
The Tria Project (Genome Canada, Genome Alberta, GenomeBC)
Lewis Research Group
Act 2:
Rob J. Hyndman (Time Series Data Library) for permission touse the otter and wolverine time series
James S. McDonnell Foundation
NSERC
PIMS
Act 3:
The Tria Project (Genome Canada, Genome Alberta, GenomeBC)
National Institute for Mathematical and Biological Synthesis(NIMBioS)
54
Background
8/3/2019 Pineda-Krch CMB2011 2lides
55/56
Act 1: Pineda-Krch. 2011. The Joy of Sweave Abeginners guide to reproducible research withSweave. http://pineda-krch.com/2011/01/17/the-joy-of-sweave/
Act 2: Pineda-Krch, Blok, Dieckmann, Doebeli. 2007. A
tale of two cycles distinguishing quasi-cycles andlimit cycles in finite predator-prey populations. Oikos116: 5364.
Act 3: Pineda-Krch. 2011. Cycles at the edge of existence:
Emergence of quasi-cycles in strongly destabilizedecosystems. Submitted
55
Session information
http://pineda-krch.com/2011/01/17/the-joy-of-sweave/http://pineda-krch.com/2011/01/17/the-joy-of-sweave/http://pineda-krch.com/2011/01/17/the-joy-of-sweave/http://pineda-krch.com/2011/01/17/the-joy-of-sweave/8/3/2019 Pineda-Krch CMB2011 2lides
56/56
R version 2.13.1 (2011-07-08), x86_64-apple-darwin9.8.0
Locale: C
Base packages: base, datasets, grDevices, graphics, methods,stats, utils
Other packages: odesolve 0.5-20, spatial 7.3-3
Loaded via a namespace (and not attached): tools 2.13.1
The R code in this vignette took 21 seconds to execute on Mon
Oct 31 23:40:05 2011.
56