-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigS1_mosquito_overview.Rmd
79 lines (68 loc) · 2.62 KB
/
figS1_mosquito_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
---
title: "Mosquito overview"
author: "Zena Lapp"
date: "2023-10-29"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(tidyverse)
library(ggpubr)
library(lubridate)
# set plotting theme
theme_set(theme_bw() +
theme(text = element_text(size = 15),
strip.background = element_rect(fill = 'white', color = 'white')))
f_anoph <- read_csv('analysis/clean_data/data/female_anopheles.csv') |>
mutate(species = paste0('*', species, '*'),
species = gsub('SS', 's.s.', species))
```
## Summaries
```{r}
nrow(f_anoph)
f_anoph |> group_by(species) |> tally() |>
ungroup() |>
filter(species != '*Undetermined*') |>
mutate(tot = sum(n),
prop = n/tot)
f_anoph |> group_by(reared) |> tally() |> ungroup() |> mutate(prop = n/sum(n))
f_anoph |>
group_by(year(collection_date), month(collection_date)) |>
tally() |>
mutate(high_trans_2021 = `year(collection_date)` == 2021 & `month(collection_date)` %in% 3:8) |>
group_by(high_trans_2021) |>
summarize(n = sum(n)) |>
ungroup() |>
mutate(tot = sum(n),
prop = n/tot)
```
## Plots
```{r, fig.width = 6.5, fig.height = 3.5}
(moz_overview <- ggarrange(f_anoph |>
mutate(species = factor(ifelse(species %in% c('*An. gambiae s.s.*', '*An. funestus*'), species, 'Other')),
species = factor(species, levels = rev(levels(species))),
reared = ifelse(reared == 'yes', 'Reared', 'Immediately processed')) |>
ggplot(aes(x = collection_date, fill = species)) +
facet_grid(reared~., scales = 'free', space = 'free') +
geom_histogram(binwidth = 14) +
scale_fill_grey(start = 0.8, end = 0.2) +
scale_x_date(date_breaks = "6 months", date_labels = "%b %Y") +
labs(x = 'Collection date', y = 'Number of female<br>*Anopheles* collected', fill = 'Species') +
theme(legend.text = element_markdown(),
axis.title.y = element_markdown()),
f_anoph |>
mutate(species = factor(ifelse(species %in% c('*An. gambiae s.s.*', '*An. funestus*'), species, 'Other')),
species = factor(species, levels = rev(levels(species))),
reared = ifelse(reared == 'yes', 'Reared', 'Immediately processed')) |>
ggplot(aes(x = village, fill = species)) +
geom_bar() +
scale_fill_grey(start = 0.8, end = 0.2) +
labs(x = 'Village', y = 'Number of female<br>*Anopheles* collected', fill = 'Species') +
theme(legend.text = element_markdown(),
axis.title.y = element_markdown()),
common.legend = TRUE, labels = 'AUTO'))
ggsave(plot = moz_overview, filename = 'analysis/manuscript_figures/figures/mosquito_overview.png',
width = 6.5, height = 3.5)
```