-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalysis.Rmd
More file actions
254 lines (211 loc) · 6.72 KB
/
analysis.Rmd
File metadata and controls
254 lines (211 loc) · 6.72 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
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
---
title: "AMR selective pressure"
csl: the-american-naturalist.csl
output:
html_document:
theme: cerulean
toc: yes
pdf_document:
toc: yes
<!-- bibliography: references.bib -->
editor_options:
chunk_output_type: console
---
<!--
IMAGES:
Insert them with: 
You can also resize them if needed: convert image.png -resize 50% image.png
If you want to center the image, go through HTML code:
<div style="text-align:center"><img src ="image.png"/></div>
REFERENCES:
For references: Put all the bibTeX references in the file "references.bib"
in the current folder and cite the references as @key or [@key] in the text.
Uncomment the bibliography field in the above header and put a "References"
title wherever you want to display the reference list.
-->
<style type="text/css">
.main-container {
max-width: 1370px;
margin-left: auto;
margin-right: auto;
}
</style>
```{r general_options, include = FALSE}
knitr::knit_hooks$set(
margin = function(before, options, envir) {
if (before) par(mgp = c(1.5, .5, 0), bty = "n", plt = c(.11, .97, .135, 1))
else NULL
},
prompt = function(before, options, envir) {
options(prompt = if (options$engine %in% c("sh", "bash")) "$ " else "> ")
})
knitr::opts_chunk$set(margin = TRUE, prompt = TRUE, comment = "",
collapse = TRUE, cache = FALSE, autodep = TRUE,
dev.args = list(pointsize = 11), fig.height = 3.5,
fig.width = 4.24725, fig.retina = 2, fig.align = "center")
options(width = 137)
```
AMU / kg of animal
AMU / kg of human
We need
* AMU in human
* AMU in animals
* number of people
* weight of people
* number of animal heads
* weight of animal
Total human biomass:
$$
m_h = \sum_a n_{h_a} \times m_{h_a}
$$
Total biomass of animal $a$:
$$
m_c = \sum_a n_{c_a} \times m_{c_a}
$$
$$
AMU = DDD \times d \times p
$$
were
* $DDD$ = Defined Daily Dose (in g / kg / day)
* $d$ = duration of treatment (in days)
* $p$ = probability of treatment in an individual's lifetime (or number of
treaments divided by number of individuals)
## Skyline plot
```{r}
library(magrittr)
library(dplyr)
```
```{r}
vietnam <- readxl::read_excel("AMU_VN_Europe_2.xlsx")
#vietnam$Species %<>% sapply(sub, pattern = "Pigs", replacement = "Pig")
```
```{r}
#colors <- c('#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a','#ffff99')
colors <- c('#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#FFF933','#808080','#cab2d6','#6a3d9a','#ffff99')
skylineplot <- function(df) {
library(magrittr)
df %$%
structure(list(breaks = cumsum(c(0, `Bodymass (1000s tonnes)`)),
counts = `mg/Kg`,
equidist = TRUE),
class = "histogram") %>%
assign("tmp", ., 1) %>%
plot(col = colors, xlab = "cumulative biomass (1,000 tonnes) ", axes = FALSE,
ylab = "AMU (mg/kg)", main = NA, xlim = c(0, 20000), ylim = c(0, 500))
ats <- seq(0, 15000, 5000)
axis(1, ats, sub("000$", ",000", ats))
axis(2)
legend("topright", legend = df$Species, fill = colors, bty = "n")
mids <- tmp$breaks[-length(tmp$breaks)] + diff(tmp$breaks) / 2
arrows(mids, df$lower, mids, df$upper, .05, 90, 3)
}
```
```{r fig.width = 4.5, fig.height = 4, eval = FALSE}
vietnam %>%
mutate(amu = `Bodymass (1000s tonnes)` * `mg/Kg`) %>%
arrange(desc(amu)) %>%
skylineplot()
```
```{r}
new_data <- setNames(read.csv("new_data.txt"),
c("Species", "Bodymass (1000s tonnes)", "mg/Kg", "lower", "upper"))
```
```{r fig.width = 4.5, fig.height = 4}
new_data %>%
mutate(amu = `Bodymass (1000s tonnes)` * `mg/Kg`) %>%
arrange(desc(amu)) %>%
skylineplot()
```
```{r fig.width = 6, fig.height = 4}
new_data2 <- new_data
new_data2[, 1] <- as.character(new_data2[, 1])
new_data2[8, 2] <- new_data2[8, 2] + new_data2[10, 2]
new_data2 <- new_data2[-10, ]
new_data2[8, 1] <- "Goat and sheep"
new_data2[7, 2] <- new_data2[7, 2] + new_data2[9, 2]
new_data2[7, 1] <- "Other avian"
new_data2 <- new_data2[-9, ]
new_data2[2, 1] <- "Pig"
new_data2[4, 3] <- mean(unlist(new_data2[4, 4:5]))
new_data2[6, 3] <- mean(unlist(new_data2[6, 4:5]))
new_data2[8, 3] <- mean(unlist(new_data2[8, 4:5]))
new_data2 %>%
mutate(amu = `Bodymass (1000s tonnes)` * `mg/Kg`) %>%
arrange(desc(amu)) %>%
skylineplot()
```
## VN and EU summaries
```{r}
vn <- readxl::read_excel("AMU_VN_Europe.xlsx", "VN summary")
```
```{r}
eu <- readxl::read_excel("AMU_VN_Europe.xlsx", "Europe summary")
```
```{r}
vn %>%
mutate(amu = `mg/Kg (unadjusted)` * `Bodymass (1000s tonnes)`,
breaks = 100 * `Bodymass (1000s tonnes)` / sum(`Bodymass (1000s tonnes)`)) %>%
arrange(desc(amu)) %$%
structure(list(breaks = cumsum(c(0, breaks)),
counts = `mg/Kg (unadjusted)`,
equidist = TRUE),
class = "histogram") %>%
plot(col = colors, xlab = "proportion of total biomass", axes = T,
ylab = "AMU (mg/kg)", main = NA, ylim = c(0, 210))
```
```{r}
eu %>%
mutate(amu = `mg/Kg (unadjusted)` * `Bodymass (1000s tonnes)`,
breaks = 100 * `Bodymass (1000s tonnes)` / sum(`Bodymass (1000s tonnes)`)) %>%
arrange(desc(amu)) %$%
structure(list(breaks = cumsum(c(0, breaks)),
counts = `mg/Kg (unadjusted)`,
equidist = TRUE),
class = "histogram") %>%
plot(col = colors, xlab = "proportion of total biomass", axes = T,
ylab = "AMU (mg/kg)", main = NA, ylim = c(0, 210))
```
```{r}
comparison_plot <- function(x) {
x %>%
mutate(amu = `mg/Kg (unadjusted)` * `Bodymass (1000s tonnes)`,
breaks = 100 * `Bodymass (1000s tonnes)` / sum(`Bodymass (1000s tonnes)`)) %>%
arrange(desc(amu)) %$%
structure(list(breaks = cumsum(c(0, breaks)),
counts = `mg/Kg (unadjusted)`,
equidist = TRUE),
class = "histogram") %>%
plot(col = colors, xlab = "proportion of total biomass", axes = T,
ylab = "AMU (mg/kg)", main = NA, ylim = c(0, 300))
}
```
```{r fig.width = 8}
opar <- par(mfrow = c(1, 2))
comparison_plot(vn)
mtext("Vietnam", 3, -1)
text(36.33971, 100, "animals")
text(86.33971, 100, "humans", col = "white")
comparison_plot(eu)
mtext("European Union", 3, -1)
text(31.83558, 100, "animals")
text(81.83558, 100, "humans", col = "white")
par(opar)
```
```{r}
vn2 <- vn
vn2[1, 2] <- 262.8
vn2[2, 2] <- 245.6
vn2[2, 3] <- 11125.5
```
```{r fig.width = 8}
opar <- par(mfrow = c(1, 2), plt = c(.11, .97, .135, .98))
comparison_plot(vn2)
mtext("Vietnam", 3, -1)
text(36.33971, 100, "animals")
text(86.33971, 100, "humans", col = "white")
comparison_plot(eu)
mtext("European Union", 3, -1)
text(31.83558, 100, "animals")
text(81.83558, 100, "humans", col = "white")
par(opar)
```