-
Notifications
You must be signed in to change notification settings - Fork 0
/
salps.qmd
124 lines (99 loc) · 3.2 KB
/
salps.qmd
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
---
title: "Salpsae"
format:
html:
code-fold: true
---
```{r setup, echo = FALSE}
source("setup.R")
groups = names(default_groups())
coast = read_coast()
```
```{r read_ecomon, message=FALSE}
#| code-fold: false
thisgroup = "Salps"
x = read_ecomon_spp(form = 'sf', groups = thisgroup, agg = FALSE) |>
ecomon_to_long() |>
dplyr::mutate(year = format(date, "%Y") ,
month = factor(format(date, "%b"), levels = month.abb))
nonz = dplyr::filter(x, value > 0)
zero = dplyr::filter(x, value <= 0)
n = nrow(x)
nz = zero |> nrow()
coast = sf::st_crop(coast, x)
```
There are `r n` records for `salps` of which `r nz` are zeroes (about `r sprintf("%0.2f%%", nz/n*100)`) leaving `r n-nz` non-zero salp abundance records.
# Non-zero abundances
Here's an abudnance scaled plot of the non-zero abundances.
```{r}
plot(nonz['value'],
pch = ".",
logz = TRUE,
main = glue::glue("Non-zero abundance of {thisgroup}"),
axes = TRUE,
reset = FALSE)
plot(coast, add = TRUE, col = "black")
```
```{r, warning=FALSE}
ggplot(data = dplyr::group_by(nonz, year),
mapping = aes(x = year)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(y = "Record count", title = glue::glue("Non-zero abundance {thisgroup} Records by Year"))
ggplot(data = dplyr::group_by(nonz, month),
mapping = aes(x = month)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(y = "Record count", title = glue::glue("Non-zero abundance {thisgroup} Records by Month"))
```
# Zero Abundance (*i.e.* absences)
The distribution of zero abundance records is much more extensive.
```{r}
plot(zero['value'] |>
dplyr::filter(value <= 0) |>
sf::st_geometry(),
pch = ".",
main = glue::glue("Zero abundance presences {thisgroup}"),
axes = TRUE,
reset = FALSE)
plot(coast, add = TRUE, col = "black")
```
```{r, warning=FALSE}
ggplot(data = dplyr::group_by(zero, year),
mapping = aes(x = year)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(y = "Record count", title = glue::glue("Zero abundance {thisgroup} Records by Year"))
ggplot(data = dplyr::group_by(zero, month),
mapping = aes(x = month)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
labs(y = "Record count", title = glue::glue("Zero abudnance {thisgroup} Records by Month"))
```
# A closer look at non-zero abundances
We can bin the data into abundance quantiles.
```{r}
#| code-fold: false
quants = seq(from = 0, to = 0.95, by = 0.05)
qs = quantile(nonz$value, quants)
ix = findInterval(nonz$value, qs)
nonz = dplyr::mutate(nonz,
quantile = quants[ix],
percentile = factor(names(qs)[ix], levels = names(qs)))
```
```{r}
ggplot(data = nonz) +
geom_sf(alpha = 0.1, size = 0.3) +
geom_sf(data = coast,
color = "orange") +
facet_wrap(~percentile)
```
# A closer look at the top 5% abundances
```{r}
top5 = dplyr::filter(nonz, quantile >= 0.95)
ggplot(data = top5) +
geom_sf(alpha = 0.1, size = 0.4) +
geom_sf(data = coast,
color = "orange") +
facet_wrap(~month, drop = FALSE)
```