-
Notifications
You must be signed in to change notification settings - Fork 0
/
selecting_species.Rmd
439 lines (399 loc) · 22.9 KB
/
selecting_species.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
---
title: "2. Selecting and filtering species"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{2. Selecting and filtering species}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE,
warning = FALSE
)
```
### Selecting a list of species
Selecting a list of target species is a common task in macroecological and conservation studies. For example, a researcher may seek to model the distribution of exclusively endemic trees within a designated Biome, a particular State, or a specific vegetation type.
By applying different filters to the database, anyone can obtain a verified taxonomic list of Brazilian species of algae, fungi, and plants for any Brazilian state, region, biome, and vegetation type. Additionally, the filter can be applied by family, genus, life form, habitat, endemism level, origin, nomenclatural status, and taxonomic status.
In this vignette, users will learn how to use *florabr* package to select a list of species based on these features.
## Loading data
Before you begin, use the `load_florabr` function to load the data. For more detailed information on obtaining and loading the data, please refer to [Getting started with florabr] - how to reference vignette???
```{r}
library(florabr)
#Folder where you stored the data with the function get_florabr()
#Load data
bf <- load_florabr(data_dir = my_dir,
data_version = "Latest_available",
type = "short") #short version
#> Loading version 393.401
```
## Selecting a list of species
One of the primary objectives of this package is to assist in selecting a species list based on taxonomic classification (Kingdom, Group, Family, and Genus), characteristics (life form, habitat), and distribution (federal states, biomes, vegetation types, and endemism). Specifically, you can filter by:
* kingdom, group, subgroup, family and genus;
* lifeForm and habitat;
* biome, state and vegetation with confirmed occurrences;
* endemism (endemic or non-endemic to Brazil);
* origin (Native, Cultivated or Naturalized in Brazil);
* taxonomicStatus and nomenclaturalStatus of the species.
To explore all available options for each filter, use the `get_attributes()` function with the desired attribute. This function will provide a data.frame with the available options to use in the `select_species()` function.
```{r}
#Get available options to filter by lifeForm
get_attributes(data = bf,
attribute = "lifeForm",
kingdom = "Plantae")
#> lifeForm
#> 1 Aquatic-Benthos
#> 2 Aquatic-Neuston
#> 3 Aquatic-Plankton
#> 4 Shrub
#> 5 Tree
#> 6 Bamboo
#> 7 Cushion
#> 8 Dendroid
#> 9 Unknown
#> 10 Dracaenoid
#> 13 Herb
#> 14 Flabellate
#> 15 Foliose
#> 16 Liana/scandent/vine
#> 19 Palm_tree
#> 21 Pendent
#> 23 Subshrub
#> 24 Succulent
#> 25 Thallose
#> 26 Mat
#> 27 Weft
#> 28 Tuft
#Get available options to filter by Biome
get_attributes(data = bf,
attribute = "Biome",
kingdom = "Plantae")
#> biome
#> 1 Amazon
#> 2 Atlantic_Forest
#> 3 Caatinga
#> 4 Cerrado
#> 5 Pampa
#> 6 Pantanal
#> 7 Not_found_in_brazil
#Get available options to filter by vegetation
get_attributes(data = bf,
attribute = "vegetationType",
kingdom = "Plantae")
#> vegetation
#> 1 Anthropic_Area
#> 2 Caatinga
#> 3 Amazonian_Campinarana
#> 4 High_Altitude_Grassland
#> 5 Flooded_Field
#> 6 Grassland
#> 7 Highland_Rocky_Field
#> 8 Carrasco
#> 9 Cerrado
#> 10 Gallery_Forest
#> 11 Inundated_Forest_Igapo
#> 12 Terra_Firme_Forest
#> 13 Inundated_Forest
#> 14 Seasonallly_Deciduous_Forest
#> 15 Seasonal_Evergreen_Forest
#> 16 Seasonally_Semideciduous_Forest
#> 17 Rainforest
#> 18 Mixed_Ombrophyllous_Forest
#> 19 Mangrove
#> 20 Palm_Grove
#> 21 Restinga
#> 22 Amazonian_Savanna
#> 23 Aquatic_vegetation
#> 24 Rock_outcrop_vegetation
#> 25 Not_found_in_Brazil
```
As an illustration, let's consider the scenario where we aim to retrieve a list of all native and endemic trees with confirmed occurrences in the Atlantic Forest:
```{r}
af_spp <- select_species(data = bf,
include_subspecies = FALSE, include_variety = FALSE,
kingdom = "Plantae", group = "All", subgroup = "All",
family = "All", genus = "All",
lifeForm = "Tree", #Specify tree species
filter_lifeForm = "in",
habitat = "All", filter_habitat = "in",
biome = "Atlantic_Forest", #Occuring in the At. Forest
filter_biome = "in", #In Atlantic Forest
state = "All", filter_state = "in",
vegetation = "All", filter_vegetation = "in",
endemism = "Endemic", #Only endemics to Brazil
origin = "Native", #Only natives
taxonomicStatus = "Accepted",
nomenclaturalStatus = "All")
nrow(af_spp)
#> [1] 2372
```
The filter returned 2372 species that meet the specified criteria. It's important to note that these selections include species with confirmed occurrences in the Atlantic Forest, and some of them may also have confirmed occurrences in other biomes.
```{r}
#First 7 unique values of biomes in the filtered dataset
unique(af_spp$Biome)[1:7]
#> [1] "Atlantic_Forest"
#> [2] "Atlantic_Forest;Cerrado"
#> [3] "Atlantic_Forest;Caatinga"
#> [4] "Amazon;Atlantic_Forest;Caatinga;Cerrado"
#> [5] "Amazon;Atlantic_Forest;Cerrado"
#> [6] "Atlantic_Forest;Caatinga;Cerrado"
#> [7] "Amazon;Atlantic_Forest"
```
If you wish to exclusively select species with confirmed occurrences in the Atlantic Forest, modify the *filter_biome* parameter to "only":
```{r}
only_af_spp <- select_species(data = bf,
include_subspecies = FALSE, include_variety = FALSE,
kingdom = "Plantae", group = "All", subgroup = "All",
family = "All", genus = "All",
lifeForm = "Tree", #Specify tree species
filter_lifeForm = "in",
habitat = "All", filter_habitat = "in",
biome = "Atlantic_Forest", #Occuring in the At. Forest
filter_biome = "only", #ONLY in Atlantic Forest
state = "All", filter_state = "in",
vegetation = "All", filter_vegetation = "in",
endemism = "Endemic", #Only endemics to Brazil
origin = "Native", #Only natives
taxonomicStatus = "Accepted",
nomenclaturalStatus = "All")
nrow(only_af_spp)
#> [1] 1858
unique(only_af_spp$biome)
#> [1] "Atlantic_Forest"
```
Now, the filter has resulted in 1858 species, all exclusively confined to the Atlantic Forest biome.
Furthermore, the package offers the flexibility to apply various filtering options (please consult `?select_species` for comprehensive details). For instance, consider the scenario where we aim to compile a list of native and endemic trees with confirmed occurrences limited solely to the Atlantic Forest biome and with confirmed occurrences in the states of Paraná (PR), Santa Catarina (SC), and Rio Grande do Sul (RS):
```{r}
south_af_spp <- select_species(data = bf,
include_subspecies = FALSE, include_variety = FALSE,
kingdom = "Plantae", group = "All", subgroup = "All",
family = "All", genus = "All",
lifeForm = "Tree", #Specify tree species
filter_lifeForm = "in",
habitat = "All", filter_habitat = "in",
biome = "Atlantic_Forest", #Occuring in the At. Forest
filter_biome = "only", #Only in Atlantic Forest
state = c("PR", "SC", "RS"), #states - Use the acronynms
filter_state = "in", #IN at least one of these states
vegetation = "All", filter_vegetation = "in",
endemism = "Endemic", #Only endemics to Brazil
origin = "Native", #Only natives
taxonomicStatus = "Accepted",
nomenclaturalStatus = "All")
nrow(south_af_spp)
#> [1] 372
#First 10 unique values of states in the filtered dataset
unique(south_af_spp$states)[1:10]
#> [1] "BA;ES;PR;RJ;SC;SP" "AL;BA;CE;ES;MA;MG;PB;PE;PR;RJ;SE;SP"
#> [3] "PR;RS;SC" "BA;CE;ES;MA;MG;PE;PR;RJ;SP"
#> [5] "MG;PR;RJ;SC;SP" "MG;PR;RJ;RS;SC;SP"
#> [7] "BA;ES;MG;PR;RJ;SC;SP" "MG;PR;RS;SC;SP"
#> [9] "PR;RJ;RS;SC;SP" "ES;MG;PR;RJ;RS;SC;SP"
```
By utilizing *filter_state = "in"*, our selection encompassed species occurring in all three states, as well as those appearing in only two or even one of them. To impose a more rigorous criterion, selecting solely those species with confirmed occurrences in all three states, we can use *filter_state = "and"*:
```{r}
south_af_spp2 <- select_species(data = bf,
include_subspecies = FALSE, include_variety = FALSE,
kingdom = "Plantae", group = "All", subgroup = "All",
family = "All", genus = "All",
lifeForm = "Tree", #Specify tree species
filter_lifeForm = "in",
habitat = "All", filter_habitat = "in",
biome = "Atlantic_Forest", #Occurring in the At. Forest
filter_biome = "only", #Only in Atlantic Forest
state = c("PR", "SC", "RS"), #states - Use the acronynms
filter_state = "and", #PR and SC and RS
vegetation = "All", filter_vegetation = "in",
endemism = "Endemic", #Only endemics to Brazil
origin = "Native", #Only natives
taxonomicStatus = "Accepted",
nomenclaturalStatus = "All")
nrow(south_af_spp2)
#> [1] 29
#All unique states in the filtered dataset
unique(south_af_spp2$states)
#> [1] "PR;RS;SC" "MG;PR;RS;SC;SP" "PR;RS;SC;SP" "ES;PR;RS;SC;SP"
#> [5] "MG;PR;RS;SC"
```
Now, our selection consists solely of species with confirmed occurrences in all of the specified states. However, by utilizing the "and" argument, we permit the filter to include species with occurrences in additional states. To confine the filter exclusively to species with confirmed occurrences in all three states, without any occurrences elsewhere, we can use *filter_state = "only"*:
```{r}
south_af_spp3 <- select_species(data = bf,
include_subspecies = FALSE, include_variety = FALSE,
kingdom = "Plantae", group = "All", subgroup = "All",
family = "All", genus = "All",
lifeForm = "Tree", #Specify tree species
filter_lifeForm = "in",
habitat = "All", filter_habitat = "in",
biome = "Atlantic_Forest", #Occuring in the At. Forest
filter_biome = "only", #Only in Atlantic Forest
state = c("PR", "SC", "RS"), #states - Use the acronynms
filter_state = "only", #PR and SC and RS, no other else
vegetation = "All", filter_vegetation = "in",
endemism = "Endemic", #Only endemics to Brazil
origin = "Native", #Only natives
taxonomicStatus = "Accepted",
nomenclaturalStatus = "All")
nrow(south_af_spp3)
#> [1] 13
#The unique state in the filtered dataset
unique(south_af_spp3$states)
#> [1] "PR;RS;SC"
```
Now, the filter return only 13 species, all of them occurring in PR, SC and RS; with no recorded occurrences in any other states.
## Checking names and subsetting species
### Extracting binomial name
In addition to selecting a species list based on their characteristics, the package also includes a function for subsetting species by name. Please note that this function exclusively operates with binomial names (Genus + specificEpithet), such as *Araucaria angustifolia*, and does not support complete scientific names (including Author or infraspecificEpithet), such as *Araucaria angustifolia (Bertol.) Kuntze* or *Araucaria angustifolia var. stricta Reitz*.
If you have species with complete scientific names, you can extract the binomial names using the function `get_binomial()`. Don't worry about excessive spaces between words; the function will remove any extra spaces from the names.
```{r}
complete_names <- c("Araucaria brasiliana var. ridolfiana (Pi.Savi) Gordon",
" Solanum restingae S.Knapp",
"Butia cattarinensis Noblick & Lorenzi ",
"Homo sapiens")
#Human specie was used just as an example that will be used to illustrate the
#next function
binomial_names <- get_binomial(species_names = complete_names)
binomial_names
#> [1] "Araucaria brasiliana" "Solanum restingae" "Butia cattarinensis"
#> [4] "Homo sapiens"
```
### Checking the species names
Additionally, you can verify the spelling, nomenclatural status, and taxonomic status of species names using the check_names() function. If the function is unable to locate the name of a species in the database (due to a typo, for example), it can suggest potential names based on similarities to other entries in the database.
To see how the function works, let's utilize the previously created binomial_names dataset:
```{r}
#Create example
checked_names <- check_names(data = bf,
species = binomial_names,
max_distance = 0.1,
kingdom = "Plantae")
checked_names
# input_name Spelling Suggested_name Distance taxonomicStatus nomenclaturalStatus acceptedName family
# 1 Araucaria brasiliana Correct Araucaria brasiliana 0 Synonym <NA> Araucaria angustifolia Araucariaceae
# 2 Araucaria brasiliana Correct Araucaria brasiliana 0 Synonym Illegitimate Araucaria angustifolia Araucariaceae
# 3 Solanum restingae Correct Solanum restingae 0 Accepted Correct Solanum restingae Solanaceae
# 4 Butia cattarinensis Probably_incorrect Butia catarinensis 1 Accepted <NA> Butia catarinensis Arecaceae
# 5 Homo sapiens Not_found <NA> NA <NA> <NA> <NA> <NA>
```
We can see that *Araucaria brasiliana* is spelling correctly, but it is a synonym of *Araucaria angustifolia*.
*Solanum restingae* is spelling correctly and it is an accepted name.
In the case of *Butia cattarinensis*, the spelling appears to be potentially incorrect (as the name wasn't found in the database); however, a similar name, *Butia catarinensis*, is suggested by the function. The 'Distance' column indicates the Levenshtein edit distance between the input and the suggested name.
The spelling of *Homo sapiens* was flagged as Not_found (as expected, given that *Homo sapiens* is not a plant!). Consequently, the name was not located in the database, and there were no comparable names available.
### Subsetting species
To retrieve species information from the Flora e Funga do Brasil database, employ the `subset_species()` function. For optimal performance, we highly recommend utilizing the `get_binomial()` and `check_names()` functions beforehand. This ensures that you're exclusively working with species present in the Flora e Funga do Brasil database.
To see how the function works, let's use the accepted names in *checked_names* created previously:
```{r}
#Get only accepted names
accepted_names <- unique(checked_names$acceptedName)
accepted_names <- na.omit(accepted_names) #Remove NA
#Subset species
my_sp <- subset_species(data = bf, species = accepted_names,
include_subspecies = FALSE,
include_variety = FALSE,
kingdom = "Plantae")
my_sp
#> species scientificName
#> 11785 Solanum restingae Solanum restingae S.Knapp
#> 26790 Araucaria angustifolia Araucaria angustifolia (Bertol.) Kuntze
#> 99881 Butia catarinensis Butia catarinensis Noblick & Lorenzi
#> acceptedName kingdom Group Subgroup family genus
#> 11785 <NA> Plantae Angiosperms <NA> Solanaceae Solanum
#> 26790 <NA> Plantae Gymnosperms <NA> Araucariaceae Araucaria
#> 99881 <NA> Plantae Angiosperms <NA> Arecaceae Butia
#> lifeForm habitat Biome States
#> 11785 Shrub Terrestrial Atlantic_Forest BA
#> 26790 Tree Terrestrial Atlantic_Forest;Pampa MG;PR;RJ;RS;SC;SP
#> 99881 Palm_tree Terrestrial Atlantic_Forest;Pampa RS;SC
#> vegetationType
#> 11785 Restinga
#> 26790 High_Altitude_Grassland;Mixed_Ombrophyllous_Forest;
#> Seasonally_Semideciduous_Forest
#> 99881 Restinga
#> origin endemism taxonomicStatus nomenclaturalStatus
#> 11785 Native Endemic Accepted Correct
#> 26790 Native Non-endemic Accepted Correct
#> 99881 Native Endemic Accepted <NA>
#> vernacularName
#> 11785 <NA>
#> 26790 araucaria, pinheiro-do-parana, curi, pinheiro-brasileiro,
#> pinho-do-parana
#> 99881 <NA>
#> taxonRank
#> 11785 Species
#> 26790 Species
#> 99881 Species
```
We can also include subspecies and/or varieties:
```{r}
my_sp2 <- subset_species(data = bf, species = accepted_names,
include_subspecies = TRUE,
include_variety = TRUE,
kingdom = "Plantae")
my_sp2[1:5,]
#> species scientificName
#> 11785 Solanum restingae Solanum restingae S.Knapp
#> 26790 Araucaria angustifolia Araucaria angustifolia (Bertol.) Kuntze
#> 35204 Araucaria angustifolia Araucaria angustifolia var. alba Reitz
#> 35205 Araucaria angustifolia Araucaria angustifolia var. caiova Reitz
#> 35206 Araucaria angustifolia Araucaria angustifolia var. caiuva Mattos
#> acceptedName kingdom Group Subgroup family
#> 11785 <NA> Plantae Angiosperms <NA> Solanaceae
#> 26790 <NA> Plantae Gymnosperms <NA> Araucariaceae
#> 35204 Araucaria angustifolia Plantae Gymnosperms <NA> Araucariaceae
#> 35205 Araucaria angustifolia Plantae Gymnosperms <NA> Araucariaceae
#> 35206 Araucaria angustifolia Plantae Gymnosperms <NA> Araucariaceae
#> genus lifeForm habitat Biome States
#> 11785 Solanum Shrub Terrestrial Atlantic_Forest BA
#> 26790 Araucaria Tree Terrestrial Atlantic_Forest;Pampa MG;PR;RJ;RS;SC;SP
#> 35204 Araucaria
#> 35205 Araucaria
#> 35206 Araucaria
#> vegetationType
#> 11785 Restinga
#> 26790 High_Altitude_Grassland;Mixed_Ombrophyllous_Forest;
#> Seasonally_Semideciduous_Forest
#> 35204
#> 35205
#> 35206
#> origin endemism taxonomicStatus nomenclaturalStatus
#> 11785 Native Endemic Accepted Correct
#> 26790 Native Non-endemic Accepted Correct
#> 35204 <NA> <NA> Synonym <NA>
#> 35205 <NA> <NA> Synonym <NA>
#> 35206 <NA> <NA> Synonym <NA>
#> vernacularName
#> 11785 <NA>
#> 26790 araucaria, pinheiro-do-parana, curi, pinheiro-brasileiro,
#> pinho-do-parana
#> 35204 <NA>
#> 35205 <NA>
#> 35206 <NA>
#> taxonRank
#> 11785 Species
#> 26790 Species
#> 35204 Variety
#> 35205 Variety
#> 35206 Variety
```
### Retrieving synonyms
We can retrieve all synonyms of a species list. This can be particularly useful, for example, when searching for records of a species and all its synonyms (as listed in the Flora e Funga do Brasil) in online databases like GBIF. To accomplish this, utilize the function get_synonym. To understand how the function works, let's search for the synonyms of two species:
```{r}
spp <- c("Araucaria angustifolia", "Adesmia paranensis")
spp_syn <- get_synonym(data = bf, species = spp)
spp_syn
#> synonym acceptedName taxonomicStatus nomenclaturalStatus
#> 35323 Araucaria brasiliana Araucaria angustifolia Synonym <NA>
#> 35325 Araucaria brasiliensis Araucaria angustifolia Synonym <NA>
#> 35327 Araucaria dioica Araucaria angustifolia Synonym <NA>
#> 35328 Araucaria elegans Araucaria angustifolia Synonym <NA>
#> 35329 Araucaria ridolfiana Araucaria angustifolia Synonym <NA>
#> 35330 Araucaria saviana Araucaria angustifolia Synonym <NA>
#> 35332 Columbea angustifolia Araucaria angustifolia Synonym Legitimate_but_incorrect
#> 35333 Columbea brasiliana Araucaria angustifolia Synonym Legitimate_but_incorrect
#> 60644 Pinus dioica Araucaria angustifolia Synonym <NA>
#> 141020 Araucaria bibbiani Araucaria angustifolia Synonym <NA>
#> 141021 Araucaria lindleyana Araucaria angustifolia Synonym <NA>
#> 141041 Araucaria brasiliana Araucaria angustifolia Synonym Illegitimate
#> 85308 Adesmia psoraleoides Adesmia paranensis Synonym Legitimate_but_incorrect
```
We can see that *Araucaria angustifolia* has 12 synonyms in Flora e Funga do Brasil, while *Adesmia paranensis* has one synonym.