-
Notifications
You must be signed in to change notification settings - Fork 0
/
transect.Rmd
313 lines (240 loc) · 12.7 KB
/
transect.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
---
title: "Transect Report"
author: ''
date: ''
output:
word_document: default
pdf_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, messages= FALSE, warning= FALSE, comment = NA, fig.width = 7, fig.height=7)
#knitr::opts_knit$set(root.dir=normalizePath('../'),fig.align="center")
#devtools::install_github("haozhu233/kableExtra")
options(scipen=999, digits=2)
library("lubridate")
library("ggplot2")
library("dplyr")
library("viridis")
library("tidyverse")
library("scales")
library("waterData")
library("gridExtra")
library("cowplot")
library('ggpubr')
library("reshape2")
#sourcing the function
source("script/oyster_functions.R")
```
```{r organize, include= FALSE}
data <- read.csv("data/oys_transect/transect_data.csv", header= TRUE)
org_data <- organizeData(data)
cal_den<- calculateCountsDensity(data,org_data)
### days sampled for all time
total_days <- length(unique(org_data$date))
total_days_22 <- length(unique(org_data$date[org_data$date > "2020-08-01"]))
```
# Overview
This report provides summary statistics and figures for ongoing transect sampling. The first section of the report focuses on the current sampling (Winter 2020-2021) and how the collected data compare to last year's sampling (Winter 2019-2020). So far `r total_days_22` days have been sampled this season. The second half of the report gives summaries of all of the data that have been collected since the beginning of the project (`r head(org_data$date, 1)`). In total, `r total_days` days have been sampled over this entire project.
## Definition of Localities
\begingroup\Large
| LOCALITY | LOCATION |
|:---------|----------------:|
| BT | Big Trout |
| CK | Cedar Key |
| CR | Corrigan's Reef |
| HB | Horseshoe Beach |
| LC | Lone Cabbage |
| LT | Little Trout |
| NN | No Name |
\endgroup
## Definition of Strata
\begingroup\Large
| STRATA | DEFINITION |
|:--------|------------------------:|
| Y_N | Yes Harvest, No Rock |
| Y_Y | Yes Harvest, Yes Rock |
| N_N | No Harvest, No Rock |
| N_Y | No Harvest, Yes Rock |
| N_PILOT| No Harvest, Pilot Rocks |
\endgroup
# Current Sampling
Here, we provide a progress bar showing how much of the sampling has been completed for this season, plus summary tables and plots comparing live counts and density of oysters between this current season and last year. **The current sampling period is period 22, and last year's sampling period is period 20.**
```{r progress_bar, echo=FALSE,comment=NA, fig.width = 7, fig.height = 6}
progress(org_data)
```
```{r, include= FALSE}
s <- subset(org_data, org_data$period == 22)
s2 <- aggregate(tran_length ~ station + strata + transect, data = s, FUN = max)
s3 <- aggregate(tran_length ~ strata, data = s2, FUN = 'sum')
Y_NA <- 424
N_NA <- 543
N_YA <- 1183
Y_YA <- 1149
Total<- 3299
Y_N_sub_total<- min(Y_NA, s3$tran_length[s3$strata == "Y_N"])
N_N_sub_total<- min(N_NA, s3$tran_length[s3$strata == "N_N"])
Y_Y_sub_total<- min(Y_YA, s3$tran_length[s3$strata == "Y_Y"])
N_Y_sub_total<- min(N_YA, s3$tran_length[s3$strata == "N_Y"])
```
| STRATA | Meters Completed |
|:--------|------------------------:|
| Y_N | `r Y_N_sub_total` |
| Y_Y | `r Y_Y_sub_total` |
| N_N | `r N_N_sub_total` |
| N_Y |`r N_Y_sub_total` |
Table - Displaying the total meters surveyed during period 22 per strata.
## Summary Plots for Periods 18, 20 and 22
```{r 2022_local, echo=FALSE,comment=NA}
# Colors for periods
#18- CC79A7 (pink)
#20-E69F00 (orange)
#22-56B4E9 (blue)
current_plot<- cal_den
current_plot$period <- factor(current_plot$period, levels = c("18", "20", "22"))
current_plot %>%
filter(period== 18 | period== 20 | period==22) %>%
ggplot( aes(y= density, fill=as.factor(period))) +
geom_boxplot()+
ylab("Oyster density per m^2")+
labs(title= "Live Oyster Density by Locality for Periods 18, 20, and 22", fill= "Period") +
scale_fill_manual(values=c("#CC79A7", "#E69F00", "#56B4E9"))+
theme(legend.position="right",panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid"))+
facet_wrap(~locality)
```
Figure- Calculated live oyster density by locality for periods 18 (Winter 2018-2019), 20 (Winter 2019-2020) and 22 (Winter 2020-2021) with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r,echo=FALSE,comment=NA}
current_plot<- cal_den
current_plot$period <- factor(current_plot$period, levels = c("18", "20", "22"))
current_plot %>%
filter(period== 18 | period== 20 | period==22) %>%
ggplot( aes( y= density_dead, fill=as.factor(period))) +
geom_boxplot() +
ylab("Oyster density per m^2")+
labs(title= "Dead Oyster Density by Locality for Periods 18, 20, and 22", fill= "Period") +
scale_fill_manual(values=c("#CC79A7", "#E69F00", "#56B4E9"))+
theme(legend.position="right",panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid")) +
facet_wrap(~locality)
```
Figure- Calculated dead oyster density by locality for periods 18 (Winter 2018-2019), 20 (Winter 2019-2020) and 22 (Winter 2020-2021) with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r 2022_strata,echo=FALSE,comment=NA }
current_plot<- cal_den
current_plot$period <- factor(current_plot$period, levels = c("18", "20", "22"))
current_plot$strata <- factor(current_plot$strata, levels = c("Y_Y", "Y_N", "N_Y", "N_N", "N_PILOT"))
current_plot %>%
filter(period== 18 | period== 20 | period==22) %>%
ggplot( aes(y= density, fill=as.factor(period))) +
geom_boxplot() +
ylab("Oyster density per m^2")+
labs(title= "Live Oyster Density by Strata for Periods 18, 20 and 22", fill= "Period") +
scale_fill_manual(values=c("#CC79A7", "#E69F00", "#56B4E9"))+
theme(legend.position="right",panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid")) +
facet_wrap(~strata, ncol= 2)
```
Figure- Calculated live oyster density by strata for periods 18 (Winter 2018-2019), 20 (Winter 2019-2020) and 22 (Winter 2020-2021) with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r,echo=FALSE,comment=NA}
current_plot<- cal_den
current_plot$period <- factor(current_plot$period, levels = c("18", "20", "22"))
current_plot$strata <- factor(current_plot$strata, levels = c("Y_Y", "Y_N", "N_Y", "N_N", "N_PILOT"))
current_plot %>%
filter(period== 18 | period== 20 | period==22) %>%
ggplot( aes(y= density_dead, fill=as.factor(period))) +
geom_boxplot()+
ylab("Oyster density per m^2")+
labs(title= "Dead Oyster Density by Strata for Periods 18, 20 and 22", fill= "Period") +
scale_fill_manual(values=c("#CC79A7", "#E69F00", "#56B4E9"))+
theme(legend.position="right",panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid")) +
facet_wrap(~strata, ncol= 2)
```
Figure- Calculated dead oyster density by strata for periods 18 (Winter 2018-2019), 20 (Winter 2019-2020) and 22 (Winter 2020-2021) with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
The following summary plot is calculated in R using the `geom_density` (https://ggplot2.tidyverse.org/reference/geom_density.html) statistical function in `ggplot`. The `geom_density` function computes and draws kernel density estimates, which is then represented as a smoothed version of a histogram.
```{r, echo=FALSE, comment=NA, error= FALSE}
cal_den %>%
filter(period== 18 | period==20) %>%
ggplot(aes(x=density, fill = as.factor(period))) +
geom_density(size = 1.5, alpha = 0.5)+
xlab("Oyster density per m^2")+
ylab("Probability Density Function")+
labs(title = "Live Oyster Density by Period (18 and 20)", fill = "Period")+
scale_fill_manual(values=c("#CC79A7", "#E69F00"))+
theme(panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid"))
```
Figure- Calculated live oyster density by periods 18 (Winter 2018-2019) and 20 (Winter 2019-2020) using a probability density function with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r, echo=FALSE, comment=NA, error= FALSE}
cal_den %>%
filter(period== 18 | period==20) %>%
ggplot(aes(x=density_dead, fill = as.factor(period))) +
geom_density(size = 1.5, alpha = 0.5)+
xlab("Oyster density per m^2")+
ylab("Probability Density Function")+
labs(title = "Dead Oyster Density by Period (18 and 20)", fill = "Period")+
scale_fill_manual(values=c("#CC79A7", "#E69F00"))+
theme(panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid"))
```
Figure- Calculated dead oyster density by periods 18 (Winter 2018-2019) and 20 (Winter 2019-2020) using a probability density function with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r den_plot, echo=FALSE, comment=NA, error= FALSE}
cal_den %>%
filter(period== 20 | period==22) %>%
ggplot(aes(x=density, fill = as.factor(period))) +
geom_density(size = 1.5, alpha = 0.5)+
xlab("Oyster density per m^2")+
ylab("Probability Density Function")+
labs(title = "Live Oyster Density by Period (20 and 22)", fill = "Period")+
scale_fill_manual(values=c("#E69F00", "#56B4E9"))+
theme(panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid"))
```
Figure- Calculated live oyster density by periods 20 (Winter 2019-2020) and 22 (Winter 2020-2021) using a probability density function with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r, echo=FALSE, comment=NA, error= FALSE}
cal_den %>%
filter(period== 20 | period==22) %>%
ggplot(aes(x=density_dead, fill = as.factor(period))) +
geom_density(size = 1.5, alpha = 0.5)+
xlab("Oyster density per m^2")+
ylab("Probability Density Function")+
labs(title = "Dead Oyster Density by Period (20 and 22)", fill = "Period")+
scale_fill_manual(values=c("#E69F00", "#56B4E9"))+
theme(panel.grid = element_blank(), panel.background = element_blank(), panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid"))
```
Figure- Calculated dead oyster density by periods 20 (Winter 2019-2020) and 22 (Winter 2020-2021) using a probability density function with the last sample date of period 22 as `r tail(org_data$date, 1)`.
\newpage
```{r, echo=FALSE, comment=NA, error= FALSE}
data1<- cal_den
data1$period <- factor(data1$period, levels = c("18", "20", "22"))
data1$strata <- factor(data1$strata, levels = c("Y_Y", "Y_N", "N_Y", "N_N", "N_PILOT"))
data1 %>%
filter(period== 18 | period== 20 | period==22) %>%
ggplot(aes( x= count_live, y= count_dead, color= as.factor(period))) +
geom_point(size=4) +
ylab("Dead Oyster Counts") +
xlab("Live Oyster Counts") +
labs(title= "Live and Dead Oyster Count Comparison for Periods 18, 20 and 22", color= "Period") +
scale_color_manual(values=c("#CC79A7", "#E69F00", "#56B4E9"))+
theme(legend.position="right",panel.grid = element_blank(),
panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid"))+
facet_wrap(~strata, ncol= 2)
```
Figure- Live and dead oyster count comparison by periods 18 (Winter 2018- 2019), 20 (Winter 2019-2020) and 22 (Winter 2020-2021), last sample date of period 22 as `r tail(org_data$date, 1)`.
```{r, echo=FALSE, fig.height = 8, fig.height = 8}
require(viridis)
data1<- cal_den
data1$strata <- factor(data1$strata, levels = c("Y_Y", "Y_N", "N_Y","N_N","N_PILOT"))
ggplot( data= data1, aes( x= count_live, y= count_dead)) +
geom_point(size=4) +
ylab("Dead Oyster Counts") +
xlab("Live Oyster Counts") +
labs(title= "Live and Dead Count Comparison For All Periods", color= "Period") +
#scale_color_viridis(option="heat",discrete=TRUE) +
theme(legend.position="right",panel.grid = element_blank(),
panel.background = element_blank(),
panel.border = element_rect(colour = "black", fill=NA,size=1, linetype="solid")) +
facet_wrap(~strata, ncol= 2 )
```
Figure- Live and dead oyster comparison for all periods, last sample date of period 22 is `r tail(org_data$date, 1)`.
\newpage