-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMigVsStat.html
More file actions
125 lines (121 loc) · 5.43 KB
/
MigVsStat.html
File metadata and controls
125 lines (121 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="R package animation 2.4">
<title>Parasite dynamics of migratory and non-migratory host populations</title>
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/scianimator.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css">
<script src="js/jquery-1.4.4.min.js"></script>
<script src="js/jquery.scianimator.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div class="scianimator"><div id="MigVsStat_longHTML" style="display: inline-block;"></div></div>
<div class="scianimator" style="width: 800px; text-align: left"><pre><code class="r">## Simulations for two scenarios - a stationary population (dashed lines) and a migratory host
## population (solid lines) - illustrating the influence of migration on disease dynamics.
## Spatial dynamics are on the left and the changes in time at the location of peak host
## population density are on the right. Parameters for the simulation are: beta=0, mu=0,
## alpha=0.1, sigma = 5, rho = 0, omega = 0, gamma = 0, theta = 0, c = 10000, kappa = 10, lambda
## = 0.01 and mu_L = 5.
library(animation)
for (j in plot.ind) {
layout(matrix(1:8, 4, 2, byrow = TRUE))
par(mar = c(1, 2, 1, 0), oma = c(4, 3, 3, 1), mgp = c(3,
1, 0))
migInd <- c(mean.start + 2 * dx + params["c."] * dt *
j)/dx
for (i in 1:4) {
y1 <- V[[1]][c(4:7)[i], x.ind, j]
y1.all <- y1
if (i < 4)
y1[which(round(V[[1]][4, x.ind, j]) <= 1)] <- NA
y2 <- V[[2]][c(1:3, 7)[i], x.ind, j]
y2.all <- y2
if (i < 4)
y2[which(round(V[[2]][1, x.ind, j]) <= 1)] <- NA
plot(x[x.ind], y1, "l", bty = "l", xaxt = "n", xlab = "",
ylab = "", las = 1, ylim = range(c(V[[1]][c(4:7)[i],
, ], V[[2]][c(1:3, 7)[i], , ])), las = 1, col = col.mig[1],
lwd = 1.2, yaxt = "n")
if (i == 4) {
axis(side = 2, at = c(0, 1000, 2000, 3000), labels = c(0,
1, 2, 3), las = 1, cex = big)
}
else if (i == 1) {
axis(side = 2, at = c(0, 500, 1000), labels = c(0,
0.5, 1), las = 1, cex = big)
}
else if (i == 3) {
axis(side = 2, at = c(2, 4, 6), las = 1, cex = big)
}
else {
axis(side = 2, las = 1)
}
if (i < 4)
lines(x[x.ind], y1.all, col = col.mig[1], lty = 3)
lines(x[x.ind], y2, col = col.mig[2], lwd = 1.2)
if (i < 4)
lines(x[x.ind], y2.all, col = col.mig[2], lty = 3)
points(x[migInd], V[[1]][c(4:7)[i], migInd, j], pch = 19,
cex = 0.8, col = col.mig[1])
points(x[c(mean.start + 2 * dx)/dx], V[[2]][c(1:3,
7)[i], c(mean.start + 2 * dx)/dx, j], pch = 19,
col = col.mig[2], cex = 0.8)
if (i == 4)
axis(side = 1, cex = big)
else axis(side = 1, labels = FALSE, cex = big)
mtext(side = 2, line = 3, c("Host population\n(thousands)",
"Parasite burden", "VMR", "Free-living parasites\n(thousands)")[i],
cex = big)
if (i == 4)
mtext(side = 1, "Distance", cex = big, line = 3)
mtext(side = 3, adj = 0, paste(" ", letters[(i -
1) * 2 + 1]), cex = big)
Ind <- cbind(rep(c(4:7)[i], j), round(c(mean.start +
2 * dx + params["c."] * dt * c(1:j))/dx), 1:j)
plot(c(1:j) * dt, V[[1]][Ind], "l", bty = "l", xaxt = "n",
xlab = "", ylab = "", las = 1, ylim = range(c(V[[1]][c(4:7)[i],
, ], V[[2]][c(1:3, 7)[i], , ])), xlim = c(0,
n.t * dt), yaxt = "n", col = col.mig[1], lwd = 1.2)
if (i == 4) {
axis(side = 2, at = c(0, 1000, 2000, 3000), labels = FALSE)
}
else if (i == 1) {
axis(side = 2, at = c(0, 500, 1000), labels = FALSE)
}
else if (i == 3) {
axis(side = 2, at = c(2, 4, 6), labels = FALSE)
}
else {
axis(side = 2, labels = FALSE)
}
if (i == 4)
axis(side = 1, cex = big)
else axis(side = 1, labels = FALSE)
lines(c(1:j) * dt, V[[2]][c(1:3, 7)[i], c(mean.start +
2 * dx)/dx, 1:j], col = col.mig[2], lwd = 1.2)
points(j * dt, V[[1]][Ind[dim(Ind)[1], 1], Ind[dim(Ind)[1],
2], Ind[dim(Ind)[1], 3]], pch = 19, cex = 0.8,
col = col.mig[1])
points(j * dt, V[[2]][c(1:3, 7)[i], c(mean.start +
2 * dx)/dx, j], pch = 19, col = col.mig[2], cex = 0.8)
if (i == 4)
mtext(side = 1, "Time", cex = big, line = 3)
mtext(side = 3, adj = 0, paste(" ", letters[(i -
1) * 2 + 2]), cex = big)
}
reset()
legend("top", lwd = 1.2, col = col.mig, ncol = 2, c("Migratory",
"Non-migratory"), xpd = NA, bty = "n", cex = big)
}
## R version 3.3.1 (2016-06-21)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Other packages: animation 2.4</code></pre></div>
<script src="js/MigVsStat_longHTML.js"></script>
<!-- highlight R code -->
</body>
</html>