Skip to content

Commit 13d758f

Browse files
committed
Update website with latest changes and new BTV refit content
1 parent 45797ba commit 13d758f

17 files changed

Lines changed: 1005 additions & 4 deletions

BT_temp_updated.qmd

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
format: html
3+
toc: false
4+
---
5+
6+
```{r setup, include=FALSE}
7+
library(nimble)
8+
library(bayesTPC)
9+
library(dplyr)
10+
library(ggplot2)
11+
library(coda)
12+
library(HDInterval)
13+
library(patchwork)
14+
```
15+
16+
# Bluetongue Virus: Midge Fecundity Analysis
17+
18+
**Source:** El Moustaid et al. 2021 Supplement | **Original experiment:** Lysyk & Danyk 2007
19+
20+
This analysis recreates the fecundity thermal performance curve from the Bluetongue virus transmission study, showing how midge reproduction varies with temperature.
21+
22+
## Dataset
23+
24+
We analyze 29 fecundity measurements (eggs per female per day) across 5 temperature groups:
25+
26+
```{r fecundity-data, echo=FALSE, message=FALSE, warning=FALSE}
27+
fecundity <- tibble(
28+
T = c(
29+
rep(10, 6), # 10 C
30+
rep(15, 6), # 15 C
31+
rep(20, 6), # 20 C
32+
rep(25, 7), # 25 C
33+
rep(30, 7) # 30 C
34+
),
35+
F = c(
36+
5.528, 3.122, 13.11, 9.745, 6.206, 31.191,
37+
19.034, 16.0, 1.361, 1.242, 11.08, 13.961,
38+
17.93, 41.531, 60.535, 39.856, 51.724, 69.951,
39+
12.731, 1.154, 36.417, 0.465, 5.844, 7.048, 19.469,
40+
31.938, 21.195, 12.255, 22.332, 0.365, 1.703, 1.536
41+
)
42+
)
43+
44+
# Display data summary
45+
cat("Temperature groups:\n")
46+
print(fecundity %>% count(T))
47+
cat("\nFecundity range:", round(min(fecundity$F), 1), "to", round(max(fecundity$F), 1), "eggs per female per day\n")
48+
```
49+
50+
## Thermal Performance Curve
51+
52+
We fit a Brière model to capture the temperature-dependent fecundity pattern:
53+
54+
**Model:** F(T) = k × T × (T - T_min) × √(T_max - T)
55+
56+
```{r fit-fecundity, echo=FALSE, message=FALSE, warning=FALSE}
57+
# Prepare data for bayesTPC
58+
data_list <- list(Temp = fecundity$T, Trait = fecundity$F)
59+
60+
# Fit Brière model with biologically realistic priors
61+
set.seed(123)
62+
fit_fec <- b_TPC(
63+
data = data_list,
64+
model = "briere",
65+
priors = list(
66+
T_min = "dunif(5, 15)", # Lower thermal limit
67+
T_max = "dunif(32, 36)", # Upper thermal limit
68+
q = "dunif(0, 200)" # Scaling parameter
69+
),
70+
nchains = 4,
71+
burn = 6000,
72+
niter = 18000
73+
)
74+
```
75+
76+
## Results
77+
78+
### Fecundity Thermal Performance Curve
79+
80+
```{r plot-fecundity, echo=FALSE, message=FALSE, warning=FALSE, fig.width=8, fig.height=5}
81+
# Generate temperature grid for predictions
82+
temp_grid <- seq(0, 50, by = 0.1)
83+
84+
# Get posterior samples
85+
samples <- as.matrix(fit_fec$samples[[1]])
86+
87+
# Generate predictions for each sample
88+
predictions <- apply(samples, 1, function(params) {
89+
T_min <- params["T_min"]
90+
T_max <- params["T_max"]
91+
q <- params["q"]
92+
93+
# Brière function
94+
ifelse(temp_grid >= T_min & temp_grid <= T_max,
95+
q * temp_grid * (temp_grid - T_min) * sqrt(pmax(T_max - temp_grid, 0)),
96+
0)
97+
})
98+
99+
# Calculate median and HPD intervals
100+
median_pred <- apply(predictions, 1, median)
101+
hpd_lower <- apply(predictions, 1, function(x) HPDinterval(as.mcmc(x), prob = 0.95)[1])
102+
hpd_upper <- apply(predictions, 1, function(x) HPDinterval(as.mcmc(x), prob = 0.95)[2])
103+
104+
# Create single plot matching screenshot style
105+
par(mfrow = c(1, 1), mar = c(4, 4, 2, 1))
106+
plot(temp_grid, median_pred,
107+
type = "l",
108+
lwd = 2,
109+
col = "black",
110+
xlab = "T (°C)",
111+
ylab = "Eggs per Female per Day",
112+
main = "",
113+
ylim = c(0, 80),
114+
xlim = c(0, 50),
115+
cex.lab = 1.1,
116+
cex.axis = 1.0,
117+
bty = "l")
118+
119+
# Add HPD interval as dashed lines
120+
lines(temp_grid, hpd_lower, lty = 2, lwd = 1.5, col = "black")
121+
lines(temp_grid, hpd_upper, lty = 2, lwd = 1.5, col = "black")
122+
123+
# Add data points as solid black circles
124+
points(fecundity$T, fecundity$F, pch = 16, col = "black", cex = 1.0)
125+
```
126+
127+
### Key Parameters
128+
129+
```{r param-summary, echo=FALSE, message=FALSE, warning=FALSE}
130+
# MAP Estimates (Maximum A Posteriori)
131+
map_params <- MAP_estimate(fit_fec)
132+
cat("**MAP Estimates:**\n")
133+
cat("• T_min =", round(map_params["T_min"], 2), "°C\n")
134+
cat("• T_max =", round(map_params["T_max"], 2), "°C\n")
135+
cat("• q =", round(map_params["q"], 3), "\n")
136+
cat("• sigma.sq =", round(map_params["sigma.sq"], 4), "\n\n")
137+
138+
# Extract key parameter estimates
139+
param_summary <- summary(fit_fec)
140+
key_params <- param_summary$parameters[c("T_min","T_max","q"), ]
141+
142+
cat("**Posterior Medians:**\n")
143+
cat("• Lower limit (T_min):", round(as.numeric(key_params["T_min", "50%"]), 1), "°C\n")
144+
cat("• Upper limit (T_max):", round(as.numeric(key_params["T_max", "50%"]), 1), "°C\n")
145+
cat("• Scaling factor (q):", round(as.numeric(key_params["q", "50%"]), 1), "\n\n")
146+
147+
cat("**Optimal Temperature:**\n")
148+
# Calculate optimal temperature (where fecundity peaks)
149+
T_opt <- (as.numeric(key_params["T_min", "50%"]) + as.numeric(key_params["T_max", "50%"])) / 2
150+
cat("• Peak fecundity at:", round(T_opt, 1), "°C\n")
151+
```
152+
153+
## Biological Interpretation
154+
155+
The thermal performance curve reveals critical insights about midge reproduction:
156+
157+
### **Thermal Limits**
158+
- **Lower limit (T_min):** Below this temperature, midges cannot reproduce
159+
- **Upper limit (T_max):** Above this temperature, reproduction ceases due to heat stress
160+
161+
### **Optimal Range**
162+
- **Peak performance:** Maximum fecundity occurs around the midpoint of the thermal range
163+
- **Temperature sensitivity:** The curve shows how reproduction drops off rapidly at thermal extremes
164+
165+
### **Transmission Implications**
166+
These results inform disease transmission models by quantifying how temperature affects vector population growth and disease spread potential.
167+

docs/BT_temp.html

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
88

99

10-
<title>bt_temp – bayesTPC Tutorials</title>
10+
<title>Bluetongue data reanalysis – bayesTPC Tutorials</title>
1111
<style>
1212
code{white-space: pre-wrap;}
1313
span.smallcaps{font-variant: small-caps;}
@@ -135,12 +135,51 @@
135135
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-full page-navbar">
136136
<!-- sidebar -->
137137
<!-- margin-sidebar -->
138-
138+
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
139+
<nav id="TOC" role="doc-toc" class="toc-active">
140+
<h2 id="toc-title">On this page</h2>
141+
142+
<ul>
143+
<li><a href="#bluetongue-virus-midge-fecundity-analysis" id="toc-bluetongue-virus-midge-fecundity-analysis" class="nav-link active" data-scroll-target="#bluetongue-virus-midge-fecundity-analysis">Bluetongue Virus: Midge Fecundity Analysis</a>
144+
<ul class="collapse">
145+
<li><a href="#dataset" id="toc-dataset" class="nav-link" data-scroll-target="#dataset">Dataset</a></li>
146+
<li><a href="#thermal-performance-curve" id="toc-thermal-performance-curve" class="nav-link" data-scroll-target="#thermal-performance-curve">Thermal Performance Curve</a></li>
147+
<li><a href="#results" id="toc-results" class="nav-link" data-scroll-target="#results">Results</a>
148+
<ul class="collapse">
149+
<li><a href="#fecundity-thermal-performance-curve" id="toc-fecundity-thermal-performance-curve" class="nav-link" data-scroll-target="#fecundity-thermal-performance-curve">Fecundity Thermal Performance Curve</a></li>
150+
<li><a href="#key-parameters" id="toc-key-parameters" class="nav-link" data-scroll-target="#key-parameters">Key Parameters</a></li>
151+
</ul></li>
152+
<li><a href="#biological-interpretation" id="toc-biological-interpretation" class="nav-link" data-scroll-target="#biological-interpretation">Biological Interpretation</a>
153+
<ul class="collapse">
154+
<li><a href="#thermal-limits" id="toc-thermal-limits" class="nav-link" data-scroll-target="#thermal-limits"><strong>Thermal Limits</strong></a></li>
155+
<li><a href="#optimal-range" id="toc-optimal-range" class="nav-link" data-scroll-target="#optimal-range"><strong>Optimal Range</strong></a></li>
156+
<li><a href="#transmission-implications" id="toc-transmission-implications" class="nav-link" data-scroll-target="#transmission-implications"><strong>Transmission Implications</strong></a></li>
157+
</ul></li>
158+
</ul></li>
159+
</ul>
160+
</nav>
161+
</div>
139162
<!-- main -->
140-
<main class="content column-page" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block"></header>
163+
<main class="content column-page-left" id="quarto-document-content">
164+
165+
<header id="title-block-header" class="quarto-title-block default">
166+
<div class="quarto-title">
167+
<h1 class="title">Bluetongue data reanalysis</h1>
168+
</div>
141169

142170

143171

172+
<div class="quarto-title-meta column-page-left">
173+
174+
175+
176+
177+
</div>
178+
179+
180+
181+
</header>
182+
144183

145184
<section id="bluetongue-virus-midge-fecundity-analysis" class="level1">
146185
<h1>Bluetongue Virus: Midge Fecundity Analysis</h1>
154 KB
Loading
113 KB
Loading
80.8 KB
Loading
185 KB
Loading
43.2 KB
Loading
39.1 KB
Loading
37.2 KB
Loading
38.7 KB
Loading

0 commit comments

Comments
 (0)