-
Notifications
You must be signed in to change notification settings - Fork 0
/
fig1andS3_match_overview.Rmd
441 lines (381 loc) · 23.1 KB
/
fig1andS3_match_overview.Rmd
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
---
title: "STR matching overview"
author: "Zena Lapp"
date: "2023-10-27"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Packages, theme, data
```{r}
library(tidyverse)
library(ggpubr)
library(ggtext)
library(geomtextpath)
library(Hmisc)
# set plotting theme
theme_set(theme_bw() +
theme(text = element_text(size = 15),
strip.background = element_rect(fill = 'white', color = 'white')))
matches <- read_csv('analysis/clean_data/data/mosquito_bistro.csv')
f_anoph <- read_csv('analysis/clean_data/data/female_anopheles.csv') |>
filter(reared == 'no')
hu_profs <- read_csv('analysis/clean_data/data/STR_human_database.csv')
```
## Imbibe overview figure
### Overview numbers
```{r}
(n_f_anoph <- nrow(f_anoph))
(n_bf <- f_anoph |> filter(abdominal_status == 'Freshly fed') |> nrow())
(n_str <- n_distinct(matches$bloodmeal_id))
(n_str_successful <- matches |> filter(locus_count > 0) |> pull(bloodmeal_id) |> n_distinct())
n_str_successful/n_str
(n_moz_match <- matches |> filter(match == 'yes') |> pull(bloodmeal_id) |> n_distinct())
n_moz_match/n_str_successful
(n_multi <- matches |> filter(est_noc > 1) |> pull(bloodmeal_id) |> n_distinct())
(n_multi_match <- matches |> filter(match == 'yes' & est_noc > 1) |> pull(bloodmeal_id) |> n_distinct())
(n_multi_2_match <- matches |> group_by(bloodmeal_id) |> filter(n() > 1) |> pull(bloodmeal_id) |> n_distinct())
n_multi_2_match/n_multi_match
(n_match <- matches |> filter(match == 'yes') |> nrow())
(max_match <- matches |> filter(match == 'yes') |> group_by(human_id) |> count() |> pull(n) |> max())
(med_match <- matches |> filter(match == 'yes') |> group_by(human_id) |> count() |> pull(n) |> median())
(mean_match <- matches |> filter(match == 'yes') |> group_by(human_id) |> count() |> pull(n) |> mean())
```
```{r}
#### Mosquitoes over time
hist_breaks <- c(18459, 18473, 18487, 18501, 18515, 18529, 18543, 18557, 18571,
18585, 18599, 18613, 18627, 18641, 18655, 18669, 18683, 18697,
18711, 18725, 18739, 18753, 18767, 18781, 18795, 18809, 18823,
18837, 18851, 18865, 18879, 18893, 18907, 18459, 18473, 18487,
18501, 18515, 18529, 18543, 18557, 18571, 18585, 18599, 18613,
18627, 18641, 18655, 18669, 18683, 18697, 18711, 18725, 18739,
18753, 18767, 18781, 18795, 18809, 18823, 18837, 18851, 18865,
18879, 18893, 18907, 18459, 18473, 18487, 18501, 18515, 18529,
18543, 18557, 18571, 18585, 18599, 18613, 18627, 18641, 18655,
18669, 18683, 18697, 18711, 18725, 18739, 18753, 18767, 18781,
18795, 18809, 18823, 18837, 18851, 18865, 18879, 18893, 18907,
18459, 18473, 18487, 18501, 18515, 18529, 18543, 18557, 18571,
18585, 18599, 18613, 18627, 18641, 18655, 18669, 18683, 18697,
18711, 18725, 18739, 18753, 18767, 18781, 18795, 18809, 18823,
18837, 18851, 18865, 18879, 18893, 18907) #generated by making the graph and pulling out of the data layer. This is just to make white lines so it looks pretty
anoph_matched <- f_anoph %>%
mutate(sample_id_mosquito = gsub(' ', '_', sample_id_mosquito)) %>%
left_join(matches %>%
rename(sample_id_mosquito = bloodmeal_id) %>%
mutate(str_typed = 'Yes')) %>%
mutate(mosq_type = factor(case_when(match == 'yes' ~ 'Matched to human (n = 662)',
locus_count > 0 ~ 'Returned human alleles (n = 777)',
str_typed == 'Yes' & locus_count ==0 ~ 'Fresh bloodmeal spot (n = 1064)',
TRUE ~ 'Collected (n = 3038)'),
levels = c('Collected (n = 3038)', 'Fresh bloodmeal spot (n = 1064)', 'Returned human alleles (n = 777)', 'Matched to human (n = 662)')),
collection_date = ymd(collection_date)) %>%
select(collection_date, sample_id_mosquito, mosq_type) %>%
distinct() %>%
ggplot(aes(x = collection_date, fill = mosq_type)) +
geom_histogram(binwidth = 14, linewidth = 0.2) +
scale_fill_manual(values = c('grey85', '#d4afb1','#a96062','#482728')
) +
scale_x_date(date_breaks = "3 months", date_labels = "%b %Y") +
geom_vline(xintercept = hist_breaks, col = "white") +
labs(x = 'Collection date', y = 'Number of female *Anopheles*', fill = NULL) +
theme(axis.title.y = element_markdown(),
legend.position = c(0.275,0.775),
legend.background = element_rect(linetype = "solid", color = "grey"),
legend.title = element_blank(),
legend.margin = margin(-4,5,5,5))
```
```{r}
#### Distribution of minimum number of contributors
match_noc_fig <- matches %>%
group_by(bloodmeal_id, est_noc) %>%
mutate(n_matches = sum(!is.na(human_id)),
est_noc = factor(ifelse(est_noc > 2, '≥3', as.character(est_noc)),
levels = c(0, 1, 2, '≥3'))) %>%
group_by(bloodmeal_id, est_noc, n_matches) %>%
dplyr::summarize() %>%
ggplot(aes(x = est_noc, fill = as.character(n_matches))) +
geom_bar() +
scale_fill_manual(values = c('#c5d7e7', '#477eae', '#1c3144')) +
labs(x = 'Estimated human bloodmeals', y = 'Number of female *Anopheles*',
fill = 'Number of\nmatches to\nsomeone in\nthe cohort') +
theme(axis.title.y = element_markdown())
```
```{r}
#### Mosquito-human match types
match_locs_dat <- matches %>%
filter(match == 'yes') %>%
group_by(match_type) %>%
tally() %>%
ungroup() %>%
mutate(tot = sum(n),
match_type = str_to_sentence(gsub('Same ', '', match_type))) %>%
add_row(match_type = 'z', n = sum(.$n)) %>%
filter(match_type != 'Different villages') %>%
mutate(n = case_when(match_type == 'Village' ~ sum(n[match_type %in% c('Village', 'Household', 'Building')]),
match_type == 'Household' ~ sum(n[match_type %in% c('Household', 'Building')]),
TRUE ~ n)) %>%
add_row(match_type = 'a', n = 1) %>%
add_row(match_type = 'Sleeping space', n = 1) %>%
mutate(match_type = factor(match_type, levels = c("a", rev(c("Village", "Household", "Building", 'Sleeping space')), "z"), labels = c("a", rev(c("Village", "Family compound", "Building", 'Sleeping space')), "z"))) %>%
rowwise() %>%
# wilson - score-test-based (preferred)
mutate(ci = ifelse(is.na(tot), NA, str_c(binconf(n, tot, alpha = 0.05, method = 'wilson'), collapse = ','))) %>%
ungroup() %>%
separate(ci, c('point_est', 'lower', 'upper'), ',') %>%
mutate(match_type_num = ifelse(match_type %in% c('a', 'z', 'Sleeping space'), NA,
paste0(paste0(match_type), '\n',
round(as.numeric(point_est)*100, 0), '% (',
round(as.numeric(lower)*100, 0), '%, ',
round(as.numeric(upper)*100, 0), '%)')))
match_locs_dat |>
filter(match_type %in% c('Building', 'Family compound', 'Village')) |>
select(match_type, n, tot, point_est)
```
```{r}
mh_match_locs_fig <- match_locs_dat %>%
ggplot(aes(y = match_type, x = n, fill = match_type_num)) +
geom_col(width = 0.85) +
scale_fill_manual(values = c('#70a9a1', '#365954', '#1f3330'),
na.value = 'white',
na.translate = FALSE) +
geom_textpath(aes(label = match_type_num), fontface = "bold", x = 5, size = 2.5,
hjust = 0, upright = FALSE, col = 'white', angle = 180, halign = 'left') +
geom_text(x = 0, y = 6, label = "Mosquito and human from the same:", size = 5) +
geom_text(x = 0, y = -4.75, label = paste0("n = ", unique(match_locs_dat$tot)[1]), size = 5) +
coord_polar(start = 2*pi) +
theme_void() +
theme(legend.position = 'none')
```
```{r}
#### Sleeping locations of people bitten by the same mosquito
multisource_sleep <- matches %>%
filter(match == 'yes') %>%
group_by(bloodmeal_id) %>%
mutate(n_matches = n()) %>%
filter(n_matches > 1) %>%
summarise(n_village = n_distinct(h_village),
n_hh = n_distinct(h_hh),
n_buildings = n_distinct(h_building),
n_sleeping_spaces = n_distinct(ss_id)) %>%
mutate(same_village = factor(ifelse(n_village == 1, 'Yes', 'No'), levels = c('Yes', 'No')),
same_hh = factor(ifelse(n_hh == 1, 'Yes', 'No'), levels = c('Yes', 'No')),
same_building = factor(ifelse(n_buildings == 1, 'Yes', 'No'), levels = c('Yes', 'No')),
same_sleeping_space = factor(ifelse(n_sleeping_spaces == 1, 'Yes', 'No'), levels = c('No', 'Yes')),
share = factor(case_when(same_sleeping_space == 'Yes' ~ 'Sleeping space',
same_building == 'Yes' ~ 'Building',
same_hh == 'Yes' ~ 'Family compound',
same_village == 'Yes' ~ 'Village',
TRUE ~ 'Different villages'),
levels = rev(c('Village','Family compound', 'Building', 'Sleeping space', 'Different villages')))) %>%
group_by(share) %>%
tally() %>%
ungroup() %>%
mutate(tot = sum(n)) %>%
add_row(share = 'z', n = sum(.$n)) %>%
mutate(n = case_when(share == 'Village' ~ sum(n[share %in% c('Village', 'Family compound', 'Building', 'Sleeping space')]),
share == 'Family compound' ~ sum(n[share %in% c('Family compound', 'Building', 'Sleeping space')]),
share == 'Building' ~ sum(n[share %in% c('Building', 'Sleeping space')]),
share == 'Sleeping space' ~ sum(n[share %in% c('Sleeping space')]),
TRUE ~ n)) %>%
add_row(share = 'a', n = 1) %>%
rowwise() %>%
# wilson - score-test-based (preferred)
mutate(ci = ifelse(is.na(tot), NA, str_c(binconf(n, tot, alpha = 0.05, method = 'wilson'), collapse = ','))) %>%
ungroup() %>%
separate(ci, c('point_est', 'lower', 'upper'), ',') %>%
mutate(share_num = ifelse(share %in% c('a', 'z'), NA,
paste0(paste0(share), '\n', #n, '/', tot, ', ',
round(as.numeric(point_est)*100, 0), '% (',
round(as.numeric(lower)*100, 0), '%, ',
round(as.numeric(upper)*100, 0), '%)')),
share = factor(share, levels = c('a', 'Sleeping space', 'Building', 'Family compound', 'Village', 'z')))
multisource_sleep |>
filter(share %in% c('Sleeping space', 'Building', 'Family compound', 'Village')) |>
select(share, n, tot, point_est)
```
```{r}
hh_match_locs_fig <- multisource_sleep %>%
filter(!is.na(share)) %>%
ggplot(aes(y = share, x = n, fill = share_num)) +
geom_col(width = 0.85) +
scale_fill_manual(values = c('#4e3e7a', '#3c305f', '#8e7dbe', '#231b36'),
na.value = 'white',
na.translate = FALSE) +
geom_textpath(aes(label = share_num), fontface = "bold", x = 0.5, size = 2.5,
hjust = 0, upright = FALSE, col = 'white', angle = 180, halign = 'left') +
geom_text(x = 0, y = 6, label = "People bitten by the same mosquito\nslept in the same:", size = 5, lineheight = 0.7) +
geom_text(x = 0, y = -4.75, label = paste0("n = ", unique(multisource_sleep$tot)[1]), size = 5) +
coord_polar(start = 2*pi) +
theme_void() +
theme(legend.position = 'none')
```
### Plot
```{r, fig.width=10, fig.height=8}
(fig_overview <- ggarrange(NULL,
ggarrange(anoph_matched, match_noc_fig,
widths = c(2, 1),
labels = 'AUTO',
vjust = 0.5,
align = 'h'),
ggarrange(mh_match_locs_fig +
theme(plot.margin = margin(rep(-10, 4))),
hh_match_locs_fig +
theme(plot.margin = margin(rep(-10, 4))),
labels = c('C','D')),
ncol = 1,
heights = c(0.025, 1, 1.2)) +
theme(plot.margin = margin(0.1,0.1,0.1,0.1, "cm")))
ggsave(plot = fig_overview, filename = 'analysis/manuscript_figures/figures/match_overview.png',
width = 10, height = 8)
```
## Supplemental figure
#### Sample flowchart
```{r}
str_mosq_info <- matches %>%
group_by(bloodmeal_id, est_noc) %>%
summarise(n_matches = sum(!is.na(human_id)))
# numbers for flowchart
# mosquitoes
n_col_mosq <- f_anoph %>% nrow() #3038
n_ff_mosq <- f_anoph %>% filter(abdominal_status == 'Freshly fed') %>% nrow() #1563
n_ff_spot <- nrow(str_mosq_info) #1064
n_ff_no_spot <- n_ff_mosq - n_ff_spot #499
n_no_peaks <- sum(str_mosq_info$est_noc == 0) #284
n_w_hu_alleles <- sum(str_mosq_info$est_noc != 0) #780
# mosquito-human matches
n_no_match <- sum(str_mosq_info$est_noc != 0 & str_mosq_info$n_matches == 0) #105
n_match <- sum(str_mosq_info$est_noc != 0 & str_mosq_info$n_matches > 0) #675
n_match_1 <- sum(str_mosq_info$est_noc != 0 & str_mosq_info$n_matches > 0 &
str_mosq_info$n_matches == 1) #621
n_match_2 <- sum(str_mosq_info$est_noc != 0 & str_mosq_info$n_matches > 0 &
str_mosq_info$n_matches == 2) #54
# humans
n_participants <- n_distinct(hu_profs$SampleName) #592
n_twin_sets <- 2
n_unq_prof <- n_participants - 2*n_twin_sets #588
n_bitten <- n_distinct(matches$human_id, na.rm = TRUE) #206
n_not_bitten <- n_unq_prof - n_bitten #382
# biting events
n_biting_events <- sum(str_mosq_info$n_matches) #729
# plot stuff
boxwidth = 16
boxheight = 12
mozzie_center = 65
hu_center = 35
# set up plot
sample_flowchart_fig <- tibble(x = 1:100, y = 1:100) %>%
ggplot(aes(x,y)) +
scale_x_continuous(minor_breaks = seq(10,100,10)) +
scale_y_continuous(minor_breaks = seq(10,125,10)) +
# collected
geom_rect(xmin = mozzie_center - boxwidth/2, xmax = mozzie_center + boxwidth/2, ymax = 100 + 1.5*boxheight, ymin = 100 + 0.5*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center, y = 100 + boxheight, label = paste0(n_f_anoph, " female\nAnopheles"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center, y = 100 + 0.5*boxheight, yend = 100, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# freshly fed
geom_rect(xmin = mozzie_center - boxwidth/2, xmax = mozzie_center + boxwidth/2, ymax = 100, ymin = 100 - boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center, y = 100 - boxheight/2, label = paste0(n_ff_mosq, " freshly-fed\nmosquitoes"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center, y = 100 - boxheight, yend = 100-1.5*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# not juicy
geom_rect(xmin = mozzie_center + 0.75*boxwidth, xmax = mozzie_center + 1.75*boxwidth, ymax = 100 - 0.75*boxheight, ymin = 100 - 1.75*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center + 1.25*boxwidth, y = 100 - 1.25* boxheight, label = paste0(n_ff_no_spot, " mosquitoes\nno bloodmeal\nspot"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center + 0.75*boxwidth, y = 100 - 1.25*boxheight, yend = 100 - 1.25*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# juicy
geom_rect(xmin = mozzie_center - boxwidth/2, xmax = mozzie_center + boxwidth/2, ymax = 100 - 1.5*boxheight, ymin = 100 - 2.5*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center, y = 100 - 2*boxheight, label = paste0(n_ff_spot, " bloodmeal\nspots"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center, y = 100 - 2.5*boxheight, yend = 100-3*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# no peaks
geom_rect(xmin = mozzie_center + 0.75*boxwidth, xmax = mozzie_center + 1.75*boxwidth, ymax = 100 - 2.25*boxheight, ymin = 100 - 3.25*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center + 1.25*boxwidth, y = 100 - 2.75* boxheight, label = paste0(n_no_peaks, " returned\nno peaks"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center + 0.75*boxwidth, y = 100 - 2.75*boxheight, yend = 100 - 2.75*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# Hu alleles
geom_rect(xmin = mozzie_center - boxwidth/2, xmax = mozzie_center + boxwidth/2, ymax = 100 - 3*boxheight, ymin = 100 - 4*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center, y = 100 - 3.5*boxheight, label = paste0(n_w_hu_alleles, " bloodmeals\nwith human alleles"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center, y = 100 - 4*boxheight, yend = 100-4.5*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# Mozzies no matches
geom_rect(xmin = mozzie_center + 0.75*boxwidth, xmax = mozzie_center + 1.75*boxwidth, ymax = 100 - 3.75*boxheight, ymin = 100 - 4.75*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center + 1.25*boxwidth, y = 100 - 4.25* boxheight, label = paste0(n_no_match, " did not\nmatch participants"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center + 0.75*boxwidth, y = 100 - 4.25*boxheight, yend = 100 - 4.25*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# Mozzies matches
geom_rect(xmin = mozzie_center - boxwidth/2, xmax = mozzie_center + boxwidth/2, ymax = 100 - 4.5*boxheight, ymin = 100 - 5.5*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center, y = 100 - 5*boxheight, label = paste0(n_match, " matched\nto database"), size = 2.5) +
geom_segment(x = mozzie_center, xend = mozzie_center - 0.75*boxwidth, y = 100 - 5.5*boxheight, yend = 100-6*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
geom_segment(x = mozzie_center, xend = mozzie_center + 0.75*boxwidth, y = 100 - 5.5*boxheight, yend = 100-6*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# matched to 1 person
geom_rect(xmin = mozzie_center - 1.1*boxwidth, xmax = mozzie_center - 0.1*boxwidth, ymax = 100 - 6*boxheight, ymin = 100 - 7*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center - 0.6*boxwidth, y = 100 - 6.5*boxheight, label = paste0(n_match_1, " matched\nto 1 participant"), size = 2.5) +
# matched to 2 people
geom_rect(xmin = mozzie_center + 0.1*boxwidth, xmax = mozzie_center + 1.1*boxwidth, ymax = 100 - 6*boxheight, ymin = 100 - 7*boxheight, fill = "white", color = "black") +
annotate('text', x = mozzie_center + 0.6*boxwidth, y = 100 - 6.5*boxheight, label = paste0(n_match_2, " matched\nto 2 participants"), size = 2.5) +
# participants in study period that we have STR profiles for (only missing a few)
geom_rect(xmin = hu_center - boxwidth/2, xmax = hu_center + boxwidth/2, ymax = 100 - 1.5*boxheight, ymin = 100 - 2.5*boxheight, fill = "white", color = "black") +
annotate('text', x = hu_center, y = 100 - 2*boxheight, label = paste0(n_participants, " participants"), size = 2.5) +
geom_segment(x = hu_center, xend = hu_center, y = 100 - 2.5*boxheight, yend = 100-3*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# twins
geom_rect(xmin = hu_center - 1.75*boxwidth, xmax = hu_center - 0.75*boxwidth, ymax = 100 - 2.25*boxheight, ymin = 100 - 3.25*boxheight, fill = "white", color = "black") +
annotate('text', x = hu_center - 1.25*boxwidth, y = 100 - 2.75* boxheight, label = paste0(n_twin_sets, " sets of twins"), size = 2.5) +
geom_segment(x = hu_center, xend = hu_center - 0.75*boxwidth, y = 100 - 2.75*boxheight, yend = 100 - 2.75*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# potential human matches
geom_rect(xmin = hu_center - boxwidth/2, xmax = hu_center + boxwidth/2, ymax = 100 - 3*boxheight, ymin = 100 - 4*boxheight, fill = "white", color = "black") +
annotate('text', x = hu_center, y = 100 - 3.5*boxheight, label = paste0(n_unq_prof, " unique human\nSTR profiles"), size = 2.5) +
geom_segment(x = hu_center, xend = hu_center, y = 100 - 4*boxheight, yend = 100-4.5*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# humans no matches
geom_rect(xmin = hu_center - 1.75*boxwidth, xmax = hu_center - 0.75*boxwidth, ymax = 100 - 3.75*boxheight, ymin = 100 - 4.75*boxheight, fill = "white", color = "black") +
annotate('text', x = hu_center - 1.25*boxwidth, y = 100 - 4.25* boxheight, label = paste0(n_not_bitten, " did not\nmatch a mosquito"), size = 2.5) +
geom_segment(x = hu_center, xend = hu_center - 0.75*boxwidth, y = 100 - 4.25*boxheight, yend = 100 - 4.25*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# humans that matched
geom_rect(xmin = hu_center - boxwidth/2, xmax = hu_center + boxwidth/2, ymax = 100 - 4.5*boxheight, ymin = 100 - 5.5*boxheight, fill = "white", color = "black") +
annotate('text', x = hu_center, y = 100 - 5*boxheight, label = paste0(n_bitten, " matched to at\nleast one mosquito"), size = 2.5) +
geom_segment(x = hu_center, xend = hu_center, y = 100 - 5.5*boxheight, yend = 100-6*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# biting events
geom_rect(xmin = hu_center - boxwidth/2, xmax = hu_center + boxwidth/2, ymax = 100 - 6*boxheight, ymin = 100 - 7*boxheight, fill = "white", color = "black", size = 1) +
annotate('text', x = hu_center, y = 100 - 6.5*boxheight, label = paste0(n_biting_events, " biting events"), size = 2.5, fontface = 2) +
#final segments
geom_segment(x = mozzie_center + 0.1*boxwidth, xend = mozzie_center - 0.1*boxwidth, y = 100 - 6.5*boxheight, yend = 100-6.5*boxheight, size=0.15, linejoin = "mitre", lineend = "butt") +
geom_segment(x = mozzie_center - 1.1*boxwidth, xend = hu_center + 0.5*boxwidth, y = 100 - 6.5*boxheight, yend = 100-6.5*boxheight, size=0.15, linejoin = "mitre", lineend = "butt",
arrow = arrow(length = unit(1, "mm"), type= "closed")) +
# section labels
annotate('text', x = hu_center, y = 100 - 1.3*boxheight, label = "Humans", size = 3, fontface = 2) +
annotate('text', x = mozzie_center, y = 121, label = "Mosquitoes", size = 3, fontface = 2) +
#theme
theme_void()
sample_flowchart_fig
```
```{r}
ggsave(plot = sample_flowchart_fig, filename = 'analysis/manuscript_figures/figures/sample_flowchart.png')
```
###### Mosquitoes per collection day
Here, we care about how many bloodfed mozzies were collected per day
```{r}
f_anoph %>%
filter(abdominal_status == "Freshly fed") %>%
group_by(collection_date) %>%
summarise(n = n(),
village = first(village)) %>%
ggplot(aes(x = collection_date, y = n, color = village)) +
geom_point() +
labs(x = "Collection Date", y = "Number of freshly fed\nmosquitoes collected")
f_anoph %>%
filter(abdominal_status == "Freshly fed") %>%
group_by(collection_date) %>%
count() %>%
ungroup() %>%
summarise(mean = mean(n),
median = median(n),
max = max(n),
sd = sd(n))
```