-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
101 lines (71 loc) · 6.26 KB
/
README.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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "figures/"
)
```
# <img src="figures/logo.jpg" align="right" width="240" /> Species Distribution Modeling of reef building coral species of the Western Atlantic
## Introduction
This project assessed how climate change will impact the distribution of three important reef builders of the Western Atlantic. This was done using SDM tools in an ensemble framework. For more details, reader is referred to the publication ["Predicted shifts in the distributions of Atlantic reef-building corals in the face of climate change"](https://www.frontiersin.org/articles/10.3389/fmars.2021.673086/full). All codes and data used in the study are available in this folder, except original climatic layers, which are available online.
## Interactive results
An interactive version of the results of this work is availabe at http://silasprincipe.github.io/reefbuilders
## Files included
**data**: all data used in the study
-- **env**: environmental data
--- **bath_layers**: bathymetry layers
--- **change_factor**: change factor applied to obtain future climatic layers
--- **crop_layers**: Bio-ORACLE layers cropped to the extent of the study
--- **proj_layers**: future scenarios layers
--- Other files used in processing environmental data (auxiliary).
-- **muhi**: _Mussismilia hispida_ data
-- **moca**: _Montastraea cavernosa_ data
-- **side**: _Siderastrea_ data
-- **thinning**: files produced in the thinning procedure (presence data)
**codes**: all codes used in the study
-- **graphs**: codes used in the production of the maps
-- **climate**: codes used for producing the future climate layers using CDO (external) and R
**functions**: all functions that were used either directly or as support in the study
**data_cleaning**: codes used in the data cleaning procces, including download of data from databases
**gis**: this folder includes shapefiles used to create maps and as support
**boot**: this folder stores bootstrap results
**Folders with species acronyms**: stores BIOMOD2 results for each species
**figures**: contains the logo of the page. Stores maps when code is executed.
**auxiliary_codes**: other codes used to obtain certain data (auxiliary).
### Reproducible paper
A reproducible version of the results section (that is, all the analysis) of the article is available here as an Rmd file (results.Rmd).
### Codes
All codes are supplied as individual files, so it's possible to run each one separately. However, note that for some codes to work they need to be executed in the same order as stated here.
1. download of species data (these codes for species data are in the data_cleaning folder).
*IMPORTANT: this part of the code involve steps of data cleaning. As global datasets are in continuous change, if you run this code now, you will probably end with different data than ours (new points may have been added). Thus, these codes are supplied here just for the sake of transparency of how data was obtained and cleaned. Final datasets used in our study are provided with the codes.*
**species name_gbif_cleaning.R**: this file is used to retrieve and clean GBIF data on species occurrence.
**species name_obis_cleaning.R**: this file is used to retrieve and clean OBIS data on species occurrence.
__species name_data_preparation.R__: this file is used to merge data from GBIF, OBIS and bibliographic sources, and to prepare for use with other codes.
**tocell_species name.R**: convert to 1 point per cell.
2. Environmental layers preparing
**bath_layer_prep.R**: used to prepare bathymetry layer, based on GEBCO.
**variables_prep_current.R**: this file is used to prepare the environmental layers from BIO-Oracle to be used in the modeling proccess.
**wind_layer_prep.R**: used to prepare the wind speed layer, from Copernicus.
**change_factor_apply.R**: used to prepare future layers applying the change factor obtained from CMIP5 files (note that change factor was obtained using the Climate Data Operators program. See note on the file for more information).
3. Pseudo-absence generation
**kernel_density.R** and **occ_thinning**: used to thin presence data. Note that to ``occ_thinning`` to work you need to first download OccurrenceThinner v.1.04 from https://github.com/hverbruggen/OccurrenceThinner. Also, note that OccThinning need to be run in an "american format" language (due to differences in the decimal signal).
**pseudoabGen.R** _(function)_: this file is used to generate pseudo-absences, required by the modeling procedure. Pseudo absences are generated based on Mahalonobis distance and a buffer.
**blockGen.R** _(function)_: used to create cross validation blocks for the modeling, based on the blockCV package.
4. Modelling
**biomodModelling.R** _(function)_: code to run the ecological niche modelling of reef building species.
**cv_bootstrap.R**: this code performs a bootstrap procedure for obtaining coefficent of variations for the niche maps.
NOTE: the code file **modeling_steps.R** is provided just to organize the pseudo absence generation, the blockCV procedure and the final modeling with BIOMOD, which are provided as individual functions.
6. Graphs and other analysis
__plot_maps_mapname.R__: generate maps using ggplot2.
**areaChange.R** and **getDiff.R**: get area differences between current and future layers.
**metricsTable.R** and **varimpTable.R**: get tables of metrics and variable importance.
__Varload.R__: load variables for use in each step of the modeling.
7. Other codes (these are provided in the _climate folder_ inside _codes_): if you want to execute this, you will first need to download CMIP5 files and the CDO program. See note on the _change_factor_apply.R_ code.
**log_cdo.txt**: code steps used in the CDO program. Note that this is not executable. You need to write each line once on the program.
**interpolation.R**: interpolation of CMIP5 layers to obtain the change factor to be applied to current layers.
---
Please, contact us if you have any questions on how to use the codes.