-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbiodivExplorer_rocky.Rmd
259 lines (168 loc) · 6.37 KB
/
biodivExplorer_rocky.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
---
title: "P2P Rockyshore Biodiversity Explorer"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r setup, include=FALSE}
library(flexdashboard)
library(readr)
library(reshape2)
library(leaflet)
library(ggplot2)
library(vegan)
library(plotly)
library(lubridate)
library(dplyr)
library(RColorBrewer)
palette(brewer.pal(8, "Set2"))
```
```{r dataread}
## add here the names of the file to analyse, with the correct path
## add the file name here, with eh correct path
## rocky or beach
baseDataDir = "../data2"
baseEcosystem = "rocky"
fileName = "ARGENTINA_MARDELPLATA_dashboard_"
datafileName = file.path(baseDataDir, baseEcosystem, fileName)
siteDF = read_csv(file = file.path(baseDataDir, "DataAnalysisFiles", baseEcosystem, paste0(fileName, "siteDF.csv")))
Occurrence = read_csv(file = file.path(baseDataDir, "DataAnalysisFiles",baseEcosystem, paste0(fileName, "occurrence.csv")))
Occurrence$abundance = as.numeric(Occurrence$abundance)
Occurrence$Cover = as.numeric(Occurrence$Cover)
## reorder strata factor
Occurrence$strata = factor(Occurrence$strata, levels = c("LOWTIDE", "MIDTIDE", "HIGHTIDE"))
## remove spp without AphiaID
Occurrence = Occurrence[!is.na(Occurrence$AphiaID),]
```
General Information
======================================================================
Column
-----------------------------------------------------------------------
### Locality: `r siteDF$locality[1]`
```{r map}
## get lat lon
siteCoords = siteDF %>% dplyr::group_by(locality, site, strata) %>%
dplyr::summarise(lng = mean(decimalLongitude, na.rm=T),
lat = mean(decimalLatitude, na.rm=T))
## get total abund and cover
siteAbund = Occurrence %>% dplyr::filter(!is.na(AphiaID)) %>%
dplyr::group_by(locality, site, strata) %>%
dplyr::summarise(sumAbund = sum(abundance, na.rm=T),
sumCover = sum(Cover, na.rm=T),
richness = n())
## add abund and cover to coords
siteCoords = full_join(siteCoords, siteAbund)
## create a color palette
pal <- colorFactor(brewer.pal(3, "Set2"), domain = c("LOWTIDE", "MIDTIDE", "HIGHTIDE"))
## make leaflet map
leaflet(siteCoords) %>% addTiles() %>%
addCircleMarkers(label = ~paste0(site, "-", strata, " / N Taxa: ", richness),
radius = ~100 * richness/sum(richness) + 4,
color = ~pal(strata),
fillOpacity = 0.8,
stroke = F,
clusterOptions = markerClusterOptions()) %>%
addMiniMap(toggleDisplay = T)
```
### Number of taxa per site and stratum
```{r taxasite}
taxaquadrat = Occurrence %>% filter(scientificName!="Bare Rock", scientificName!="Without Substrate") %>%
group_by(site, strata, replicateID) %>%
summarise(taxa.n = n())
taxaquadrat$strata = factor(taxaquadrat$strata, levels = c("LOWTIDE", "MIDTIDE", "HIGHTIDE"))
pp = ggplot(taxaquadrat, aes(strata, taxa.n, fill=strata))
pp = pp + geom_boxplot() + ylab("Number of taxa per quadrat") +
facet_grid(~site) +
theme_bw(base_size = 9) + theme(legend.position = "none")
ggplotly(pp) %>% plotly::config(displayModeBar = F)
```
### Abundance of taxa per site and stratum
```{r taxaabund}
pp = ggplot(Occurrence, aes(strata, abundance, group=strata, fill=strata))
pp = pp + geom_boxplot() + ylab("Abundance of all taxa per quadrat") +
facet_grid(~site) +
theme_bw(base_size = 9) + theme(legend.position = "none")
ggplotly(pp) %>% plotly::config(displayModeBar = F)
```
### Average live cover per strata
```{r taxacover}
taxacover = Occurrence %>% dplyr::filter(!is.na(AphiaID)) %>%
dplyr::group_by(site, strata, replicateID) %>%
dplyr::summarise(sumcover = sum(Cover, na.rm=T))
pp = ggplot(taxacover, aes(strata, sumcover, fill=strata))
pp = pp + geom_boxplot() + ylab("% Cover of all taxa per quadrat") +
facet_grid(~site) +
theme_bw(base_size = 9) + theme(legend.position = "none")
ggplotly(pp) %>% plotly::config(displayModeBar = F)
```
Column
-----------------------------------------------------------------------
### taxonomic rank distribution
```{r taxonrank}
## library(worms)
## get taxonomy file
taxaDictFileName = file.path(baseDataDir, "taxalist",
baseEcosystem, "RS-taxonlistALL_nonduplicated_taxonomy.csv")
taxaDict = read_tsv(taxaDictFileName)
scNames = unique(Occurrence$AphiaID)
scNames = left_join(data.frame(AphiaID=scNames), taxaDict)
## get taxon rank from WoRMS
##scNames.rank = wormsbyid(x = scNames, verbose = F)
## summarise the results
taxranks = as.data.frame(table(scNames$rank))
## make a donut
p = taxranks %>% plot_ly(labels = ~Var1, values=~Freq) %>%
add_pie(hole=0.6) %>%
layout(title = ~paste0("Total number of Taxa: ", length(scNames)))
plotly::config(p,displayModeBar = F)
```
### Species frequency
```{r}
taxafreq = Occurrence %>% dplyr::filter(!is.na(AphiaID)) %>%
dplyr::group_by(site, strata, ScientificName_accepted) %>%
dplyr::summarise(sppfreq = n()) %>%
dplyr::arrange(sppfreq) %>%
dplyr::mutate(sppacum = cumsum(sppfreq))
pp = ggplot(taxafreq, aes(ScientificName_accepted, sppfreq, fill=strata))
pp = pp + geom_bar(stat="identity") + coord_flip() + facet_grid(~site) +
theme_bw(base_size = 9) + xlab("") + ylab("number of quadrats present")
ggplotly(pp) %>% plotly::config(displayModeBar = F)
```
### Taxa list: number of quadrats where found
```{r taxalist}
spRanks = scNames[,c("AphiaID", "rank")]
## add taxon rank to occurrence table
Occurrence = full_join(Occurrence, spRanks)
taxaTable = Occurrence %>%
dplyr::group_by(AphiaID) %>% dplyr::filter(!is.na(AphiaID)) %>%
dplyr::summarise(Taxon = unique(ScientificName_accepted),
rank = unique(rank),
lowtide = sum(strata=="LOWTIDE", na.rm=T),
midtide = sum(strata=="MIDTIDE", na.rm=T),
hightide = sum(strata=="HIGHTIDE", na.rm=T))
knitr::kable(taxaTable)
```
Indicators
=======================================================
Row
-------------------------------------------------------
### Number of species
```{r}
nspp = nrow(taxafreq)
valueBox(nspp)
```
### Number of Mollusc species
```{r}
nMolluscs = sum(scNames$Phylum=="Mollusca", na.rm=T)
valueBox(nMolluscs)
```
### Number of Algal species
```{r}
nPlants = sum(scNames$Kingdom=="Plantae", na.rm=T)
valueBox(nPlants)
```
Row
-------------------------------------------------------
### Number of Threatened species
### Number of Invasive Species
### Number of XXXX Species