Skip to content

Commit 45797ba

Browse files
committed
Update BT_temp.qmd: Move MAP estimates to top of findings
- Added MAP_estimate() function to extract Maximum A Posteriori parameters - Moved MAP estimates to top of Key Parameters section - Renamed 'Thermal Limits' to 'Posterior Medians' for clarity - MAP estimates show single best parameter set from Bayesian analysis - Maintains scientific publication style with clean plot aesthetics
1 parent 7978d47 commit 45797ba

2 files changed

Lines changed: 81 additions & 83 deletions

File tree

BT_temp.qmd

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
title: "Bluetongue Virus: Midge Fecundity Analysis"
32
format: html
43
toc: false
54
---
@@ -79,41 +78,68 @@ fit_fec <- b_TPC(
7978
### Fecundity Thermal Performance Curve
8079

8180
```{r plot-fecundity, echo=FALSE, message=FALSE, warning=FALSE, fig.width=8, fig.height=5}
82-
# Create a clean, informative plot
83-
plot(fit_fec,
84-
temp_interval = seq(0, 50, by = 0.1),
85-
summaryType = "hdi",
86-
centralSummary = "median",
87-
prob = 0.95,
88-
main = "Midge Fecundity vs Temperature",
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)",
89111
ylab = "Eggs per Female per Day",
90-
xlab = "Temperature (°C)",
91-
ylim = c(0, max(fecundity$F) * 1.1),
92-
cex.main = 1.2,
112+
main = "",
113+
ylim = c(0, 80),
114+
xlim = c(0, 50),
93115
cex.lab = 1.1,
94-
cex.axis = 1.0)
95-
96-
# Add data points
97-
points(fecundity$T, fecundity$F, pch = 16, col = "red", cex = 1.2)
98-
99-
# Add legend
100-
legend("topright",
101-
legend = c("Data points", "Posterior median", "95% HPD interval"),
102-
col = c("red", "black", "black"),
103-
lty = c(NA, 1, 2),
104-
pch = c(16, NA, NA),
105-
cex = 0.9,
106-
bty = "n")
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)
107125
```
108126

109127
### Key Parameters
110128

111129
```{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+
112138
# Extract key parameter estimates
113139
param_summary <- summary(fit_fec)
114140
key_params <- param_summary$parameters[c("T_min","T_max","q"), ]
115141
116-
cat("**Thermal Limits:**\n")
142+
cat("**Posterior Medians:**\n")
117143
cat("• Lower limit (T_min):", round(as.numeric(key_params["T_min", "50%"]), 1), "°C\n")
118144
cat("• Upper limit (T_max):", round(as.numeric(key_params["T_max", "50%"]), 1), "°C\n")
119145
cat("• Scaling factor (q):", round(as.numeric(key_params["q", "50%"]), 1), "\n\n")
@@ -129,17 +155,12 @@ cat("• Peak fecundity at:", round(T_opt, 1), "°C\n")
129155
The thermal performance curve reveals critical insights about midge reproduction:
130156

131157
### **Thermal Limits**
132-
- **Lower threshold (5-15°C):** Midges require minimum temperatures above 5°C to begin reproduction
133-
- **Upper threshold (32-36°C):** Fecundity drops to zero above 32°C, indicating severe thermal stress
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
134160

135161
### **Optimal Range**
136-
- **Peak reproduction:** Occurs around 20-25°C, matching the expected thermal optimum for midge biology
137-
- **Sharp decline:** The curve drops rapidly above 28-30°C, reflecting the biological reality that high temperatures severely impair reproduction
138-
139-
### **Disease Transmission Implications**
140-
This temperature-dependent fecundity pattern is crucial for understanding Bluetongue virus transmission dynamics:
141-
- **Climate change impacts:** Rising temperatures may reduce midge reproduction in some regions
142-
- **Seasonal patterns:** Transmission risk varies with temperature-dependent vector abundance
143-
- **Geographic distribution:** Disease spread is limited by thermal constraints on vector reproduction
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
144164

145-
The tight constraint on the upper thermal limit (32-36°C) ensures the model accurately captures the biological reality that midge reproduction becomes severely impaired at high temperatures, providing reliable predictions for disease transmission modeling.
165+
### **Transmission Implications**
166+
These results inform disease transmission models by quantifying how temperature affects vector population growth and disease spread potential.

docs/BT_temp.html

Lines changed: 24 additions & 47 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>Bluetongue Virus: Midge Fecundity Analysis – bayesTPC Tutorials</title>
10+
<title>bt_temp – bayesTPC Tutorials</title>
1111
<style>
1212
code{white-space: pre-wrap;}
1313
span.smallcaps{font-variant: small-caps;}
@@ -137,25 +137,9 @@
137137
<!-- margin-sidebar -->
138138

139139
<!-- main -->
140-
<main class="content column-page" id="quarto-document-content">
141-
142-
<header id="title-block-header" class="quarto-title-block default">
143-
<div class="quarto-title">
144-
<h1 class="title">Bluetongue Virus: Midge Fecundity Analysis</h1>
145-
</div>
146-
147-
148-
149-
<div class="quarto-title-meta column-page">
150-
151-
152-
153-
154-
</div>
155-
140+
<main class="content column-page" id="quarto-document-content"><header id="title-block-header" class="quarto-title-block"></header>
156141

157142

158-
</header>
159143

160144

161145
<section id="bluetongue-virus-midge-fecundity-analysis" class="level1">
@@ -229,32 +213,26 @@ <h3 class="anchored" data-anchor-id="fecundity-thermal-performance-curve">Fecund
229213
</figure>
230214
</div>
231215
</div>
232-
<div class="cell-output-display">
233-
<div>
234-
<figure class="figure">
235-
<p><img src="BT_temp_files/figure-html/plot-fecundity-2.png" class="img-fluid figure-img"></p>
236-
</figure>
237216
</div>
217+
</section>
218+
<section id="key-parameters" class="level3">
219+
<h3 class="anchored" data-anchor-id="key-parameters">Key Parameters</h3>
220+
<div class="cell">
221+
<div class="cell-output cell-output-stdout">
222+
<pre><code>**MAP Estimates:**</code></pre>
238223
</div>
239-
<div class="cell-output-display">
240-
<div>
241-
<figure class="figure">
242-
<p><img src="BT_temp_files/figure-html/plot-fecundity-3.png" class="img-fluid figure-img"></p>
243-
</figure>
244-
</div>
224+
<div class="cell-output cell-output-stdout">
225+
<pre><code>• T_min = 5.01 °C</code></pre>
245226
</div>
246-
<div class="cell-output-display">
247-
<div>
248-
<figure class="figure">
249-
<p><img src="BT_temp_files/figure-html/plot-fecundity-4.png" class="img-fluid figure-img"></p>
250-
</figure>
227+
<div class="cell-output cell-output-stdout">
228+
<pre><code>• T_max = 32.01 °C</code></pre>
251229
</div>
230+
<div class="cell-output cell-output-stdout">
231+
<pre><code>• q = 0.018 </code></pre>
252232
</div>
233+
<div class="cell-output cell-output-stdout">
234+
<pre><code>• sigma.sq = 66.5715 </code></pre>
253235
</div>
254-
</section>
255-
<section id="key-parameters" class="level3">
256-
<h3 class="anchored" data-anchor-id="key-parameters">Key Parameters</h3>
257-
<div class="cell">
258236
<div class="cell-output cell-output-stdout">
259237
<pre><code>bayesTPC MCMC of Type:
260238
briere
@@ -300,7 +278,7 @@ <h3 class="anchored" data-anchor-id="key-parameters">Key Parameters</h3>
300278
sigma.sq 58.00772 64.5654 68.27074 72.25270 80.47774</code></pre>
301279
</div>
302280
<div class="cell-output cell-output-stdout">
303-
<pre><code>**Thermal Limits:**</code></pre>
281+
<pre><code>**Posterior Medians:**</code></pre>
304282
</div>
305283
<div class="cell-output cell-output-stdout">
306284
<pre><code>• Lower limit (T_min): °C</code></pre>
@@ -326,21 +304,20 @@ <h2 class="anchored" data-anchor-id="biological-interpretation">Biological Inter
326304
<section id="thermal-limits" class="level3">
327305
<h3 class="anchored" data-anchor-id="thermal-limits"><strong>Thermal Limits</strong></h3>
328306
<ul>
329-
<li><strong>Lower threshold (5-15°C):</strong> Midges require minimum temperatures above 5°C to begin reproduction</li>
330-
<li><strong>Upper threshold (32-36°C):</strong> Fecundity drops to zero above 32°C, indicating severe thermal stress</li>
307+
<li><strong>Lower limit (T_min):</strong> Below this temperature, midges cannot reproduce</li>
308+
<li><strong>Upper limit (T_max):</strong> Above this temperature, reproduction ceases due to heat stress</li>
331309
</ul>
332310
</section>
333311
<section id="optimal-range" class="level3">
334312
<h3 class="anchored" data-anchor-id="optimal-range"><strong>Optimal Range</strong></h3>
335313
<ul>
336-
<li><strong>Peak reproduction:</strong> Occurs around 20-25°C, matching the expected thermal optimum for midge biology</li>
337-
<li><strong>Sharp decline:</strong> The curve drops rapidly above 28-30°C, reflecting the biological reality that high temperatures severely impair reproduction</li>
314+
<li><strong>Peak performance:</strong> Maximum fecundity occurs around the midpoint of the thermal range</li>
315+
<li><strong>Temperature sensitivity:</strong> The curve shows how reproduction drops off rapidly at thermal extremes</li>
338316
</ul>
339317
</section>
340-
<section id="disease-transmission-implications" class="level3">
341-
<h3 class="anchored" data-anchor-id="disease-transmission-implications"><strong>Disease Transmission Implications</strong></h3>
342-
<p>This temperature-dependent fecundity pattern is crucial for understanding Bluetongue virus transmission dynamics: - <strong>Climate change impacts:</strong> Rising temperatures may reduce midge reproduction in some regions - <strong>Seasonal patterns:</strong> Transmission risk varies with temperature-dependent vector abundance - <strong>Geographic distribution:</strong> Disease spread is limited by thermal constraints on vector reproduction</p>
343-
<p>The tight constraint on the upper thermal limit (32-36°C) ensures the model accurately captures the biological reality that midge reproduction becomes severely impaired at high temperatures, providing reliable predictions for disease transmission modeling.</p>
318+
<section id="transmission-implications" class="level3">
319+
<h3 class="anchored" data-anchor-id="transmission-implications"><strong>Transmission Implications</strong></h3>
320+
<p>These results inform disease transmission models by quantifying how temperature affects vector population growth and disease spread potential.</p>
344321

345322

346323
</section>

0 commit comments

Comments
 (0)