-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCO_Turtles_Exploratory.Rmd
253 lines (189 loc) · 7.67 KB
/
CO_Turtles_Exploratory.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
---
title: "CO Turtles Exploratory Analyses"
explanation: "Exploratory analysis of spatial-capture-recapture data recorded summer 2018"
author: "Natalie Haydt"
output:
pdf_document: default
html_notebook: default
---
```{r, checking working directory}
# getwd()
library(lme4)
library(ggplot2)
```
```{r, read in scr data}
scr.data <- read.csv(file = "Data/canalscr_9_1_18.csv", stringsAsFactors = FALSE)
head(scr.data)
```
```{r, data summary}
summary(scr.data)
```
```{r, histograms}
# need to separate by site?
par(mfrow = c(1,2))
sizes <- hist(scr.data$carapace, main = "Carapace Size Distribution", xlab = "Carapace Size Per Turtle (mm)")
leeches <- hist(scr.data$leeches, main = "Leech Count Distribution", xlab = "Number of Leeches Per Turtle" )
par(mfrow = c(1,1))
```
```{r}
scr.mf <- scr.data[which(scr.data$sex != "U" & !is.na(scr.data$sex)), ]
ggplot(data = scr.mf, aes(carapace)) + geom_histogram(aes(fill = species)) + facet_wrap(~sex) +
ggtitle("Frequency of Turtles Caught by Size, Sex, and Species") +
theme(plot.title = element_text(hjust = 0.5, size = 16),
axis.title.x = element_text(size=14),
axis.title.y = element_text(size=14))
# scale_color_manual(values=c("lightgodlenrod4", "#darkorange3", "rosybrown3", "wheat2", "bisque2", "grey50"))+
# scale_fill_manual(values=c("lightgodlenrod4", "#darkorange3", "rosybrown3", "wheat2", "bisque2", "grey50"))
ggplot(data = scr.mf, aes(carapace)) + geom_histogram(aes(fill = sex)) + facet_wrap(~species)
```
```{r, recap rate histogram}
recaps <- read.csv(file = "Data/recaprates_9_1_18.csv")
hist(recaps$prop_recap, breaks = 10, xlab = "Proportion of Recaps", main = "Proportion of Recaptures Across C&O Sites", col = "darkorange3")
p <- ggplot(recaps, aes(x=prop_recap)) +
geom_histogram(binwidth = 0.05, color="darkorange3", fill = "darkorange3", position = position_dodge())
print(p)
p + labs(x ="Proportion of Recaps", y = "Frequency")+
theme_classic() +
scale_fill_manual(values=c('#999999','#E69F00')) +
ggtitle("Proportion of Recaptures Across C&O Sites") +
theme(plot.title = element_text(hjust = 0.5, size = 16),
axis.title.x = element_text(size=14),
axis.title.y = element_text(size=14)
)
```
```{r, subsetting by species}
scr_cpic <- subset(scr.data, species == "CPIC")
scr_sodo <- subset(scr.data, species == "SODO")
scr_cser <- subset(scr.data, species == "CSER")
scr_prub <- subset(scr.data, species == "PRUB")
scr_gins <- subset(scr.data, species == "GINS")
scr_tscr <- subset(scr.data, species == "TSCR")
```
```{r, species summaries}
summary(scr_cpic)
summary(scr_sodo)
summary(scr_cser)
summary(scr_prub)
summary(scr_gins)
## only 1 tscr caught, so did not create summary
```
```{r, histograms per species}
hist(scr_cpic$carapace)
hist(scr_sodo$carapace)
hist(scr_cser$carapace)
hist(scr_prub$carapace)
hist(scr_cpic$leeches)
hist(scr_sodo$leeches)
hist(scr_cser$leeches)
hist(scr_prub$leeches)
```
```{r, size by site per species, ## add in overall}
cpic_size_site <- aov(data = scr_cpic, carapace ~ site)
cpic_size_summary <- summary(cpic_size_site)
cpic_size_summary
cpic_posthoc <- TukeyHSD(cpic_size_site, 'site', conf.level = 0.95)
cpic_posthoc
sodo_size_site <- aov(data = scr_sodo, carapace ~ site)
sodo_size_summary <- summary(sodo_size_site)
sodo_size_summary
sodo_posthoc <- TukeyHSD(sodo_size_site, 'site', conf.level = 0.95)
sodo_posthoc
cser_size_site <- aov(data = scr_cser, carapace ~ site)
cser_size_summary <- summary(cser_size_site)
cser_size_summary
cser_posthoc <- TukeyHSD(cser_size_site, 'site', conf.level = 0.95)
cser_posthoc
prub_size_site <- aov(data = scr_prub, carapace ~ site)
prub_size_summary <- summary(prub_size_site)
prub_size_summary
prub_posthoc <- TukeyHSD(prub_size_site, 'site', conf.level = 0.95)
prub_posthoc
all_size_site <- aov(data = scr.data, carapace ~ site)
all_size_summary <- summary(all_size_site)
all_size_summary
all_size_posthoc <- TukeyHSD(all_size_site, 'site', conf.level = 0.95)
all_size_posthoc
```
## Exploration of leech data
```{r, leeches and site; per species and ##overall}
cpic_leeches_site <- aov(data = scr_cpic, leeches ~ site)
cpic_leeches_summary <- summary(cpic_leeches_site)
cpic_leeches_summary
cpic_leeches_posthoc <- TukeyHSD(cpic_leeches_site, 'site', conf.level = 0.95)
cpic_leeches_posthoc
sodo_leeches_site <- aov(data = scr_sodo, leeches ~ site)
sodo_leeches_summary <- summary(sodo_leeches_site)
sodo_leeches_summary
sodo_leeches_posthoc <- TukeyHSD(sodo_leeches_site, 'site', conf.level = 0.95)
sodo_leeches_posthoc
cser_leeches_site <- aov(data = scr_cser, leeches ~ site)
cser_leeches_summary <- summary(cser_leeches_site)
cser_leeches_summary
cser_leeches_posthoc <- TukeyHSD(cser_leeches_site, 'site', conf.level = 0.95)
cser_leeches_posthoc
prub_leeches_site <- aov(data = scr_prub, leeches ~ site)
prub_leeches_summary <- summary(prub_leeches_site)
prub_leeches_summary
prub_leeches_posthoc <- TukeyHSD(prub_leeches_site, 'site', conf.level = 0.95)
prub_leeches_posthoc
all_leeches_site <- aov(data = scr.data, leeches ~ site)
all_leeches_summary <- summary(all_leeches_site)
all_leeches_summary
all_leeches_posthoc <- TukeyHSD(all_leeches_site, 'site', conf.level = 0.95)
all_leeches_posthoc
```
### Regression of number of leeches as a function of the species
Q: do different species have different numbers of leeches
H0: There no diff in the number of leeches among species
HA: Musk turtles (SODO) will have more leeches than basking turtles
*Will eventually want to consider leeches per unit area since the turtle species are different sizes or adding size as a covariate interacting with species*
```{r, leeches and species}
#add in site as random effect
leeches_species <- aov(data = scr.data, leeches ~ species)
leeches_species_summary <- summary(leeches_species)
leeches_species_summary
##leeches_species_posthoc <- TukeyHSD(leeches_species, 'leeches', conf.level = 0.95)
##NaNs produced (need to use NA.omit?)
##leeches_species_posthoc
glmer1 <- glmer(leeches ~ species + (1|site), data = scr.data, family = poisson)
summary(glmer1)
hist(rnorm(10000, exp(0.31932), sd = 0.4694))
library(dplyr)
scr.scaled <- scr.data %>%
filter(species != "GINS",
species != "TSCR") %>%
mutate(mass.s = (mass - mean(mass)) / sd(mass))
summary(scr.scaled)
glmer2 <- glmer(leeches ~ species + mass.s + (1|site), data = scr.scaled, family = poisson)
summary(glmer2)
```
```{r, leeches and size - regression}
#add in site as random effect
leeches_size <- aov(data = scr.data, leeches ~ carapace)
leeches_size_summary <- summary(leeches_size)
leeches_size_summary
cpic_leeches_size <- aov(data = scr_cpic, leeches ~ carapace)
cpic_leeches_size_summary <- summary(cpic_leeches_size)
cpic_leeches_size_summary
##cpic_leeches_size_posthoc <- TukeyHSD(cpic_leeches_size, 'carapace', conf.level = 0.95)
##cpic_leeches_size_posthoc
##sodo_leeches_size <- aov(data = scr_sodo, leeches ~ carapace)
##sodo_leeches_size_summary <- summary(sodo_leeches_size)
##sodo_leeches_size_summary
##sodo_leeches_size_posthoc <- TukeyHSD(sodo_leeches_size, 'carapace', conf.level = 0.95)
##sodo_leeches_size_posthoc
##cser_leeches_size <- aov(data = scr_cser, leeches ~ carapace)
##cser_leeches_size_summary <- summary(cser_leeches_size)
##cser_leeches_size_summary
##cser_leeches_size_posthoc <- TukeyHSD(cser_leeches_size, 'carapace', conf.level = 0.95)
##cser_leeches_size_posthoc
##prub_leeches_size <- aov(data = scr_prub, leeches ~ carapace)
##prub_leeches_size_summary <- summary(prub_leeches_size)
##prub_leeches_size_summary
##prub_leeches_size_posthoc <- TukeyHSD(prub_leeches_size, 'carapace', conf.level = 0.95)
##prub_leeches_size_posthoc
```
```{r, total caugt vs filled status}
```
Analyses Based off of Raabe et al. 2014:
Analyses Based off of Kornilev et al. 2010: