-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path03-Data.Rmd
executable file
·445 lines (401 loc) · 18.1 KB
/
03-Data.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
```{r setupinds, include=FALSE}
rm(list = ls()) ; invisible(gc()) ; set.seed(42)
library(knitr)
library(tidyverse)
library(V.PhyloMaker)
library(ggfortify)
library(ggtree)
library(sf)
library(leaflet)
library(readxl)
theme_set(bayesplot::theme_default())
opts_chunk$set(
echo = F, message = F, warning = F, fig.height = 6, fig.width = 8,
cache = T, cache.lazy = F)
crs <- '+proj=longlat +datum=WGS84' # leaflet CRS
```
# Field data
This chapter define sampled species and individuals.
Specifically, this chapter details:
* Collected species
* Individuals from the METRADICA project
* Candidates with varying DBH and TWI
* Field maps
## Species
We selected 10 species (Tab. \@ref(tab:speciesTab)) common with the METRADICA project representative of the tree phylogeny in Paracou (Fig. \@ref(fig:speciesPhylo)).
```{r speciesTab}
species <- data.frame(taxon = c(
"Casearia_javitensis",
"Chrysophyllum_prieurii",
"Conceveiba_guianensis",
"Gustavia_hexapetala",
"Jacaranda_copaia subsp. copaia",
"Laetia_procera",
"Protium_stevensonii",
"Tachigali_melinonii",
"Virola_michelii",
"Virola_surinamensis"
)) %>%
separate(taxon, c("Genus", "Species"), sep = "_", remove = F)
kable(select(species, Genus, Species), caption = "Studied species.")
```
```{r speciesPhylo, fig.cap="Selected species phylogeny."}
paracou <- read_csv2("data/Paracou_P16_2020.csv") %>%
dplyr::select(Family, Genus, Species) %>%
unique() %>%
full_join(species) %>%
mutate(species = paste(Genus, Species), genus = Genus, family = Family) %>%
dplyr::select(species, genus, family, taxon) %>%
mutate(taxon = as.character(taxon))
# tree <- phylo.maker(sp.list = paracou, tree = GBOTB.extended, nodes = nodes.info.1, scenarios = "S3")
# save(tree, file = "save/phylogeny.Rdata")
load("save/phylogeny.Rdata")
fortify(tree$scenario.3) %>%
mutate(species = gsub("_", " ", label)) %>%
left_join(paracou) %>%
mutate(species = ifelse(is.na(taxon), NA, species)) %>%
separate(species, c("genus", "species")) %>%
mutate(species = ifelse(is.na(taxon), NA, paste0(substr(genus, 1, 1), ". ", species))) %>%
ggtree(aes(col = species), layout="circular") +
geom_tiplab2(aes(label = species), size = 3) +
theme_tree(legend.position='right', legend.text = element_text(face = "italic")) +
scale_color_discrete(guide = "none") +
xlim(0, 175)
```
## METRADICA
This subparagraph details collected or wrong individuals in METRADICA (Tab. \@ref(tab:indMD)) and Marion's candidates (Tab. \@ref(tab:indMD), & Fig. \@ref(fig:indMDP16)),
but candidates of the project will be focused on P16 independently from her candidates and adjusted in the field.
```{r indMD}
collected <- readxl::read_excel("data/202012_SelectionIndividus_V5.4.xlsx", sheet = "IndAMesurer") %>%
filter(TaxonActu %in% species$taxon) %>%
mutate(Statut = recode(Statut,
"AMesurerMD" = "Candidate",
"AMesurerMDPrioDK" = "Candidate",
"MesuréDK" = "Measured",
"MesuréDrought" = "Measured",
"MesuréMD" = "Measured",
"MesuréMD (MauvaiseSp)" = "Wrong",
"MesuréMD+Drought" = "Measured",
"MortMD" = "Wrong",
"MortParacou20" = "Wrong",
"MortParacou20PrioDK" = "Wrong",
"PasFaisable" = "Wrong",
))
collected %>%
group_by(TaxonActu, Statut) %>%
summarise(N = n()) %>%
reshape2::dcast(TaxonActu ~ Statut, value.var = "N") %>%
mutate(TaxonActu = gsub("_", " ", TaxonActu)) %>%
kable(caption = "Sumary of individuals (from 202012_SelectionIndividus_V5.4.xlsx)")
```
```{r indMB}
tocollect <- readxl::read_excel("data/FTH2021_SelectionIndividus_V5.5.xlsx", sheet = "IndAMesurer") %>%
filter(TaxonActu %in% species$taxon) %>%
st_as_sf(coords = c("Xutm", "Yutm"),
crs = '+proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0') %>%
mutate(DBH = Circ/pi)
tocollect %>%
group_by(TaxonActu, Plot) %>%
summarise(N = n()) %>%
reshape2::dcast(TaxonActu ~ Plot, value.var = "N") %>%
mutate_all(funs(ifelse(is.na(.), " ", .))) %>%
kable(caption = "Sumary of candidates (from FTH2021_SelectionIndividus_V5.5.xlsx)")
```
```{r indMDP16, fig.cap="Marion's candidates in P16."}
palSp <- colorFactor("viridis", tocollect$TaxonActu)
limits <- st_read("data/OverallPlots/OverallPlots.shp", quiet = T)
leaflet(data = st_transform(tocollect, crs = crs)) %>%
addTiles() %>%
addPolylines(data = st_transform(limits, crs = crs), col = "grey") %>%
addCircles(color = ~palSp(TaxonActu), opacity = 1,
label = ~ TaxonActu, radius = ~ DBH/5) %>%
addLegend(pal = palSp, values = ~ TaxonActu)
```
## Candidates
We selected 15 individuals per species in P16 (10 + 5 extras) minimizing DBH variation while maximizing TWI variation (Fig. \@ref(fig:candFig), Tab. \@ref(tab:candTab), Fig. \@ref(fig:candMap)). We are lacking individuals for *Casearia javitensis*, *Protium stevensonii*, and *Virola surinamensis*.
```{r candidates}
candidates <- read_csv2("data/Paracou_P16_2020.csv") %>%
left_join(species) %>%
filter(!is.na(taxon)) %>%
mutate(DBH = CircCorr/pi) %>%
st_as_sf(coords = c("Xutm", "Yutm"),
crs = '+proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0')
candidates$TWI <- raster::extract(raster::raster("data/TWI_1m.tif"), candidates)
candidates <- candidates %>%
group_by(taxon) %>%
mutate(N = n()) %>%
mutate(cand0 = ifelse(N <= 17, 1, 0)) %>%
mutate(m = median(DBH), l = quantile(DBH, 0.3), u = quantile(DBH, 0.6)) %>%
mutate(cand0 = ifelse(cand0 == 0 & DBH >= l & DBH <= u, 1, cand0))
cand <- as.data.frame(candidates) %>%
group_by(taxon) %>%
filter(cand0 == 1, N > 15) %>%
sample_n(15) %>%
unique()
candidates <- candidates %>%
mutate(candidate = ifelse(idTree %in% cand$idTree, 1, 0)) %>%
mutate(candidate = ifelse(N <= 15, 1, candidate)) %>%
mutate(candidate = as.factor(candidate)) %>%
select(-cand0)
```
```{r candFig, fig.cap="DBH and TWI of candidates in P16."}
ggplot(candidates, aes(DBH, TWI, col = candidate, alpha = candidate)) +
geom_point() +
facet_wrap(~ taxon, scales = "free_x") +
scale_color_manual("Candidate", values = c("red", "grey")) +
scale_alpha_manual("Candidate", values = c(1, 0.5)) +
theme(legend.position = c(0.8, 0.1)) +
xlab("Diameter at breast height (DBH, cm)") +
ylab("Topographic wetness index (TWI)")
```
```{r candTab}
as.data.frame(candidates) %>%
filter(candidate == 1) %>%
group_by(taxon, N) %>%
summarise(Nsel = n()) %>%
select(taxon, Nsel, N) %>%
kable(caption = "Candidates in P16.")
```
```{r candMap, fig.cap="Candidates in P16."}
palSp <- colorFactor("viridis", candidates$taxon)
leaflet(data = st_transform(filter(candidates, candidate == 1),
crs = crs)) %>%
addTiles() %>%
addPolylines(data = st_transform(filter(limits, Plot == 16),
crs = crs), col = "grey") %>%
addCircles(color = ~palSp(taxon), opacity = 1,
label = ~ taxon, radius = ~ DBH/5) %>%
addLegend(pal = palSp, values = ~ taxon)
```
## Maps
Maps were automatically built using `sf` and `ggplot2` and save in the folder `maps`:
```{r mapsFun, echo=T}
contour <- st_read("data/ContourLinesPlots/ContourLinePlots.shp", quiet = T)
crs_rot = "+proj=omerc +lat_0=36.934 +lonc=-90.849 +alpha=0 +k_0=.7 +datum=WGS84 +units=m +no_defs +gamma=20"
make_map <- function(file, title, subplots){
sublimits <- filter(limits, Plot == 16, Subplot %in% subplots) %>%
st_transform(crs = crs_rot)
subcontour <- st_transform(contour, crs = crs_rot) %>% st_crop(sublimits)
subcandidates <- filter(candidates, candidate == 1, SubPlot %in% subplots) %>%
st_transform(crs = crs_rot) %>%
mutate(label = paste0("P", Plot, "-", SubPlot, "-", TreeFieldNum, "_", substr(Genus, 1, 3), substr(Species, 1, 3), "_", round(DBH)))
g <- ggplot() +
geom_sf(data = subcontour, fill = NA, col = "lightgrey") +
geom_sf(data = sublimits, fill = NA, col = "darkgrey", aes(text = subplots)) +
geom_sf_text(data = sublimits, aes(label = Subplot), colour = "darkgrey") +
geom_sf(data = subcandidates, col = "black") +
ggrepel::geom_text_repel(
data = subcandidates,
aes(label = label, geometry = geometry),
stat = "sf_coordinates",
min.segment.length = 0
) +
theme(axis.title = element_blank(), axis.text = element_blank(),
axis.ticks = element_blank(), axis.line = element_blank()) +
scale_color_discrete(guide = "none") +
ggtitle(title)
ggsave(g, file = file, path = 'maps', width = 297, height = 420, unit = 'mm', dpi = 300)
}
```
```{r maps, eval=F}
make_map("P16NW.png", "Plot 16 North-West", c(1:3, 6:8, 11:13))
make_map("P16NE.png", "Plot 16 North-East", c(3:5, 8:10, 13:15))
make_map("P16SW.png", "P16 South-West", c(11:13, 16:18, 21:23))
make_map("P16SE.png", "P16 South-East", c(13:15, 18:20, 23:25))
```
## Extra FTH
Candidate individuals from the P16 were not enough for the FTH field campaign.
We added individuals from the P6:
```{r, eval=F}
missings <- data.frame(
spcode = c("Casjav", "Congui", "Jaccop", "Proste", "Tacmel", "Virmic", "Virsur"),
inds = c(5, 1, 4, 4, 4, 1, 4),
Genus = c("Casearia", "Conceveiba", "Jacaranda", "Tetragastris", "Tachigali", "Virola", "Virola"),
Species = c("javitensis", "guianensis", "copaia", "panamensis", "melinonii", "michelii", "surinamensis")
)
p6 <- src_sqlite(file.path("/home/sylvain//Documents/BIOGECO/PhD/data/Paracou/",
"trees", "Paracou.sqlite")) %>%
tbl("Paracou") %>%
filter(CodeAlive == 1) %>%
filter(Plot == 6) %>%
filter(CensusYear == 2017) %>%
collect() %>%
mutate(DBH = CircCorr/pi)
metradica <- read_excel("data/fth/MetradicaP6_dejafait.xlsx") %>%
rename(TreeFieldNum = FieldNr, SubPlot = Subplot) %>%
select(Plot, SubPlot, TreeFieldNum) %>%
mutate(metradica = 1)
candidates <- p6 %>%
left_join(metradica) %>%
filter(is.na(metradica)) %>%
mutate(spcode = paste0(substr(Genus, 1, 3), substr(Species, 1, 3))) %>%
mutate(spcode = recode(spcode, "Tetpan" = "Proste")) %>%
left_join(missings %>%
select(spcode) %>%
mutate(tocollect = 1)) %>%
filter(tocollect == 1) %>%
filter(DBH > 10, DBH < 60) %>%
st_as_sf(coords = c("Xutm", "Yutm"),
crs = '+proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0')
```
```{r}
contour <- st_read("data/ContourLinesPlots/ContourLinePlots.shp", quiet = T)
crs_rot = "+proj=omerc +lat_0=36.934 +lonc=-90.849 +alpha=0 +k_0=.7 +datum=WGS84 +units=m +no_defs +gamma=20"
limits <- st_read("data/OverallPlots/OverallPlots.shp", quiet = T)
sublimits <- filter(limits, Plot == 6, Subplot %in% 1:4) %>%
st_transform(crs = crs_rot)
subcontour <- st_transform(contour, crs = crs_rot) %>%
st_crop(sublimits)
subcandidates <- candidates %>%
st_transform(crs = crs_rot) %>%
mutate(label = paste0("P", Plot, "-", SubPlot, "-", TreeFieldNum, "_", substr(Genus, 1, 3), substr(Species, 1, 3), "_", round(DBH)))
g <- ggplot() +
geom_sf(data = subcontour, fill = NA, col = "lightgrey") +
geom_sf(data = sublimits, fill = NA, col = "darkgrey", aes(text = Subplot)) +
geom_sf_text(data = sublimits, aes(label = Subplot), colour = "darkgrey") +
geom_sf(data = subcandidates, col = "black") +
ggrepel::geom_text_repel(
data = subcandidates,
aes(label = label, geometry = geometry),
stat = "sf_coordinates",
min.segment.length = 0
) +
theme(axis.title = element_blank(), axis.text = element_blank(),
axis.ticks = element_blank(), axis.line = element_blank()) +
scale_color_discrete(guide = "none")
ggsave(g, file = "P6.png", path = 'maps', width = 297, height = 420, unit = 'mm', dpi = 300, bg = "white")
```
```{r extrafthmap, fig.height=10, fig.width=10}
g
```
## Extra Post - FTH
Individuals were still missing after the FTH field campaign.
We added individuals from the P16:
```{r}
inds <- googlesheets4::read_sheet("https://docs.google.com/spreadsheets/d/1-INnZ563VkNBH8rnSwfWieuGwPo9x9GRSV6jXNzatmM/edit?usp=sharing",
"individuals") %>%
rename(Individual = FieldCode) %>%
dplyr::select(Genus, Species, Plot, SubPlot, TreeFieldNum) %>%
unique()
missings_hydroitv <- data.frame(
spcode = c("Casjav", "Proste", "Tacmel"),
Nhydroitv = c(6, 6, 1),
Genus = c("Casearia", "Protium", "Tachigali"),
Species = c("javitensis", "stevensonii", "melinonii")
)
missings_metradica <- data.frame(
spcode = c("Casjav", "Chrpri", "Proste", "Proste", "Virmic", "Virsur"),
Nmetradica = c(1, 1, 7, 3, 4, 4),
Genus = c("Casearia", "Chrysophyllum", "Protium", "Protium", "Virola", "Virola"),
Species = c("javitensis", "prieurii", "stevensonii", "stevensonii", "michelii", "surinamensis"),
habitat = c("TF", "BF", "BF", "TF", "BF", "BF")
)
missings <- full_join(missings_hydroitv, missings_metradica) %>%
mutate(Nhydroitv = ifelse(is.na(Nhydroitv), 0, Nhydroitv)) %>%
mutate(N = Nmetradica) %>%
rowwise() %>%
mutate(N = ifelse(spcode == "Casjav", 6, N))
candidates <- read_csv2("data/Paracou_P16_2020.csv") %>%
left_join(species) %>%
filter(!is.na(taxon)) %>%
mutate(DBH = CircCorr/pi) %>%
left_join(inds %>%
dplyr::select(Plot, SubPlot, TreeFieldNum) %>%
mutate(done = 1)) %>%
mutate(done = ifelse(is.na(done), 0, done)) %>%
left_join(dplyr::select(missings, Genus, Species) %>%
mutate(missing = 1)) %>%
filter(missing == 1) %>%
st_as_sf(coords = c("Xutm", "Yutm"),
crs = '+proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0') %>%
st_intersection(st_read("data/TopographicLevels/TopographicLevels.shp", quiet = T)) %>%
mutate(topo = recode(TypeTopo, "BasFond" = "BF", "Plateau" = "TF", "Pente" = "P")) %>%
group_by(Genus, Species) %>%
mutate(m = median(DBH), l = quantile(DBH, 0.25), u = quantile(DBH, 0.75)) %>%
mutate(l = ifelse(Genus == "Casearia", 0, l)) %>%
filter(DBH >= l, DBH <= u)
# candidates %>%
# group_by(Species, Genus) %>%
# summarise(N = n()) %>%
# left_join(select(missings, Genus, Species, Nhydroitv, Nmetradica))
```
```{r}
contour <- st_read("data/ContourLinesPlots/ContourLinePlots.shp", quiet = T)
crs_rot = "+proj=omerc +lat_0=36.934 +lonc=-90.849 +alpha=0 +k_0=.7 +datum=WGS84 +units=m +no_defs +gamma=20"
limits <- st_read("data/OverallPlots/OverallPlots.shp", quiet = T)
sublimits <- filter(limits, Plot == 16, Subplot %in% 1:25) %>%
st_transform(crs = crs_rot)
subcontour <- st_transform(contour, crs = crs_rot) %>%
st_crop(sublimits)
subcandidates <- candidates %>%
st_transform(crs = crs_rot) %>%
mutate(label = paste0("P", Plot, "-", SubPlot, "-", TreeFieldNum, "_", substr(Genus, 1, 3), substr(Species, 1, 3), "_", round(DBH), "_", topo))
g <- ggplot() +
geom_sf(data = subcontour, fill = NA, col = "lightgrey") +
geom_sf(data = sublimits, fill = NA, col = "darkgrey", aes(text = Subplot)) +
geom_sf_text(data = sublimits, aes(label = Subplot), colour = "darkgrey") +
geom_sf(data = subcandidates, col = "black") +
ggrepel::geom_text_repel(
data = subcandidates,
aes(label = label, geometry = geometry),
stat = "sf_coordinates",
min.segment.length = 0,
size = 3
) +
theme(axis.title = element_blank(), axis.text = element_blank(),
axis.ticks = element_blank(), axis.line = element_blank()) +
scale_color_discrete(guide = "none")
ggsave(g, file = "P16extra.png", path = 'maps', width = 297, height = 420, unit = 'mm', dpi = 300, bg = "white")
```
```{r postfthmap, fig.height=10, fig.width=10}
g
```
## Leaf variation
For the leaf variation within individual we sampled across the 27 *Virola michelii* from the P16 that followed our requirements (DBH between 30th and 60th quantiles):
```{r samplingleafvar, fig.cap="Candidates in P16."}
# data
candidates <- read_csv2("data/Paracou_P16_2020.csv") %>%
filter(Genus == "Virola", Species == "michelii") %>%
mutate(DBH = CircCorr/pi) %>%
filter(DBH >= quantile(DBH, 0.3), DBH <= quantile(DBH, 0.6)) %>%
st_as_sf(coords = c("Xutm", "Yutm"),
crs = '+proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0') %>%
mutate(Ind = paste0("P", Plot, "_", SubPlot, "_", TreeFieldNum))
# html map
limits <- st_read("data/OverallPlots/OverallPlots.shp", quiet = T)
leaflet(data = st_transform(candidates, crs = crs)) %>%
addTiles() %>%
addPolylines(data = st_transform(filter(limits, Plot == 16),
crs = crs), col = "grey") %>%
addCircles(opacity = 1, label = ~ Ind, radius = ~ DBH/2)
# paper map
contour <- st_read("data/ContourLinesPlots/ContourLinePlots.shp", quiet = T)
crs_rot = "+proj=omerc +lat_0=36.934 +lonc=-90.849 +alpha=0 +k_0=.7 +datum=WGS84 +units=m +no_defs +gamma=20"
sublimits <- filter(limits, Plot == 16) %>%
st_transform(crs = crs_rot)
subcontour <- st_transform(contour, crs = crs_rot) %>%
st_crop(sublimits)
subcandidates <- st_transform(candidates, crs = crs_rot) %>%
mutate(label = paste0("P", Plot, "-", SubPlot, "-", TreeFieldNum, "_", substr(Genus, 1, 3), substr(Species, 1, 3), "_", round(DBH)))
g <- ggplot() +
geom_sf(data = subcontour, fill = NA, col = "lightgrey") +
geom_sf(data = sublimits, fill = NA, col = "darkgrey") +
geom_sf_text(data = sublimits, aes(label = Subplot), colour = "darkgrey") +
geom_sf(data = subcandidates, col = "black") +
ggrepel::geom_text_repel(
data = subcandidates,
aes(label = label, geometry = geometry),
stat = "sf_coordinates",
min.segment.length = 0
) +
theme(axis.title = element_blank(), axis.text = element_blank(),
axis.ticks = element_blank(), axis.line = element_blank()) +
scale_color_discrete(guide = "none") +
ggtitle("Plot 16 - Virola michelii")
ggsave(g, file = "P16_virmic.png", path = 'maps', width = 297, height = 420, unit = 'mm', dpi = 300, bg = "white")
# gps
# candidates %>%
# mutate(name = paste0("P", Plot, "-", SubPlot, "-", TreeFieldNum, "_", substr(Genus, 1, 3), substr(Species, 1, 3), "_", round(DBH))) %>%
# dplyr::select(name, geometry) %>%
# st_write(dsn = "maps/P16_virmic.gpx", delete_dsn = T, driver = "GPX", layer = "waypoints")
```