The package ‘LightSSDM’ is a computer platform implemented in R providing a range of methodological approaches and parameterization at each step of the SSDM building. This vignette presents a typical workflow in R command to use it. An additionnal vignette presents the same workflow using the graphic user interface with gui
function (see GUI vignette).
The workflow of the package ‘SSDM’ is based on three modelling levels:
{width=100%}
In addition to build species distribution models you will need environmental variables. Currently ‘SSDM’ uses all raster formats supported by the R package ‘rgdal’. The package ‘SSDM’ supports both continuous (e.g., climate maps, digital elevation models, bathymetric maps) and categorical environmental variables (e.g., land cover maps, soil type maps) as inputs. The package also allows normalizing environmental variables, which may be useful to improve the fit of certain algorithms (like artificial neural networks).
Rasters of environmental data need to have the same coordinate reference system while spatial extent and resolution of the environmental layers can differ. During processing, the package will deal with between-variables discrepancies in spatial extent and resolution by rescaling all environmental rasters to the smallest common spatial extent then upscaling them to the coarsest resolution.
‘SSDM’ include load_var
function to read raster files including your environmental variables. We will work with three 30 arcsec-resolution rasters covering the north part of the main island of New Caledonia ’Grande Terre’. Climatic variables (RAINFALL and TEMPERATURE) are from the WorldClim database, and the SUBSTRATE map is from the IRD Atlas of New Caledonia (2012) (see ?Env
).
library(LightSSDM) Env <- load_var(system.file('extdata', package = 'LightSSDM'), categorical = 'SUBSTRATE', verbose = FALSE, folder_tmp = "temporal_ENV") Env
Note that:
categorical
parameter. Norm
option.Species distribution models are built on natural history records.
‘SSDM’ include load_occ
function to read raw csv or txt files including your natural history records. We will work with natural history records from five Cryptocarya species native to New Caledonia (see ?Occurrences
).
Occ <- load_occ(path = system.file('extdata', package = 'LightSSDM'), Env, Xcol = 'LONGITUDE', Ycol = 'LATITUDE', file = 'Occurrences.csv', sep = ',', verbose = FALSE) head(Occ)
Note that:
GeoRes
option to thin occurences. Thinning removes unnecessary records, reducing the effect of sampling bias while retaining the greatest amount of information.read.csv
function used to open you raw data.*In the example below we build an elliptica distribution model with a subset the occurrences of the species and specifying a single algorithm, here generalized linear models. The package ‘SSDM’ includes the main algorithms used to model species distributions: general additive models (GAM), generalized linear models (GLM), multivariate adaptive regression splines (MARS), classification tree analysis (CTA), generalized boosted models (GBM), maximum entropy (Maxent), artificial neural networks (ANN), random forests (RF), and support vector machines (SVM). Default parameters of the dependent R package of each algorithm were conserved but most of them remain settable.
SDM <- modelling('GLM', subset(Occurrences, Occurrences$SPECIES == 'elliptica'), Env, Xcol = 'LONGITUDE', Ycol = 'LATITUDE', verbose = TRUE) plot(SDM@projection, main = 'SDM\nfor Cryptocarya elliptica\nwith GLM algorithm')
Note that: The package ‘SSDM’ encompass a large methodolgy offered by litterature. Have a look at all parameters for modelling
function with ?modelling
.
In this other example we build an ensemble elliptica distribution model combining CTA and MARS based SDMs of this species. Because uncertainty in distribution projections can skew policy making and planning, a recommendation is to fit a number of alternative model algorithms and to explore the range of projections across the different SDMs and then to find consensus in SDM projections. Two consensus methods are implemented in the package ‘SSDM’:
The package also provides an uncertainty map representing the between-algorithms variance. The degree of agreement between each pair of algorithms can be assessed through a correlation matrix giving the Pearson's coefficient.
ESDM <- ensemble_modelling(c('CTA', 'MARS'), subset(Occurrences, Occurrences$SPECIES == 'elliptica'), Env, rep = 1, Xcol = 'LONGITUDE', Ycol = 'LATITUDE', ensemble.thresh = c(0.6), verbose = TRUE) plot(ESDM@projection, main = 'ESDM\nfor Cryptocarya elliptica\nwith CTA and MARS algorithms')
Note that: the package ‘LightSSDM’ includes a large methodology offered by litterature. Have a look at all parameters for ensemble_modelling
function with ?ensemble_modelling
.
Finally, we build a stacked species distribution model using CTA and SVM algorihtms and multiple species. The outputs of the differnt species are aggregated in SSDM maps of local species richness and composition using summing continuous habitat suitability maps stacking method (pSSDM).
SSDM <- stack_modelling(c("ANN", "KSVM"), Occurrences, Env, rep = 1, Xcol = 'LONGITUDE', Ycol = 'LATITUDE', Spcol = 'SPECIES', method = "pSSDM", verbose = TRUE, tmp = F, cores = 3) plot(SSDM@diversity.map, main = 'SSDM\nfor Cryptocarya genus\nwith CTA and KSVM algorithms')
Five other stacking methods are available (see references in ?stack_modelling
for details):
A range of model evaluation metrics included in package ‘SDMTools’ have been integrated in the package ‘SSDM’. They include the area under the receiving operating characteristic (ROC) curve (AUC), the Cohen's Kappa coefficient, the omission rate, the sensitivity (true positive rate) and the specificity (true negative rate). These metrics are all based on the confusion matrix (also called ‘error matrix’, which represents the instances in a predicted class versus the instances in an actual class). The confusion matrix is computed converting the habitat suitability maps into binary presence/absence maps.
knitr::kable(ESDM@evaluation)
To assess the accuracy of an SSDM, the package provides the opportunity to compare modeled species assemblages with species pools from independent inventories observed in the field. Six evaluation metrics are computed: (1) the species richness error, i.e. the difference between the predicted and observed species richness; (2) assemblage prediction success, i.e. the proportion of correct predictions; (3) assemblage Cohen’s kappa, i.e. the proportion of specific agreement; (4) assemblage specificity, i.e. the proportion of true negatives (species that are both predicted and observed as being absent); (5) assemblage sensitivity, i.e. the proportion of true positives (species that are both predicted and observed as present); and (6) the Jaccard index, a widely used metric of community similarity.
knitr::kable(SSDM@evaluation)
The package ‘SSDM’ provides two methods to measure the relative contribution of environmental variables, which quantifies the relevance of an environmental variable to determine species distribution. The first method is based on a jack knife approach that evaluates the change in accuracy between a full model and the models where each environmental variable are omitted in turns. All metrics available in the package can serve to assess the change in accuracy. The second method is based on the Pearson's correlation coefficient between a full model and the models where each environmental variable are omitted in turns.
knitr::kable(SSDM@variable.importance)
In addition to species richness, endemism is an important feature for conservation as it refers to species being unique to the defined geographic location. Species endemism maps can be computed using two metrics:
plot(SSDM@endemism.map, main = 'Endemism map\nfor Cryptocarya genus\nwith CTA and SVM algorithms')
All results can be sumarized inside a shiny dashboard by calling plot
method directly on an SSDM object.
# plot(SSDM)
{width=100%}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.