Here I am going make a rapid model of the potential suitable habitats of a fish species Phago loricatus. Basically a demonstration of how predictor variables can help understand the distribution of a species.
In doing so, I used the following package versions:
knitr
version 1.37rmarkdown
version 2.11tidyverse
version 1.3.1sdm
version 1.1.8usdm
version 1.1.18raster
version 3.5.15dismo
version 1.3.5maptools
version 1.1.2I obtained occurrence records from the global biodiversity facility GBIF.
ext <- c(-7, 10, 4, 15)
phago_occ <- gbif('Phago', 'loricatus', ext = ext)
## 55 records found
## 0-55 records downloaded
There are 55 occurrence records of the species.
In this step, I select only records that were collected by humans or specimen records, presence records, with both longitude and latitude values, and not duplicated. Lastly, I mutate a column containing 1’s as species presence values.
phago_clean <- phago_occ |>
dplyr::select(lon, lat, occurrenceStatus, basisOfRecord) |>
filter(occurrenceStatus == 'PRESENT') |>
filter(basisOfRecord %in% c('HUMAN_OBSERVATION', 'PRESERVED_SPECIMEN')) |>
dplyr::select(lon, lat) |>
drop_na() |>
unique() |># Removes duplicates.
mutate(species = 1)
phago_spatial <- phago_clean
coordinates(phago_spatial) <- ~lon+lat
phago_clim <- raster::getData('worldclim', var = 'bio', res = 10)
phago_crop <- crop(phago_clim, ext)
points_extract <- raster::extract(phago_crop, phago_spatial)
v <- vifcor(points_extract)
## Warning in summary.lm(lm(as.formula(paste(colnames(y)[w[i]], "~.", sep = "")), :
## essentially perfect fit: summary may be unreliable
## Warning in summary.lm(lm(as.formula(paste(colnames(y)[w[i]], "~.", sep = "")), :
## essentially perfect fit: summary may be unreliable
phago_crop_used <- exclude(phago_crop, v)
phago_sdmdata <- sdmData(species~., train = phago_spatial, predictors = phago_crop_used,
bg = list(method = 'gRandom', n = 1000))
## Loading required package: gbm
## Loaded gbm 2.1.8
## Loading required package: tree
## Registered S3 method overwritten by 'tree':
## method from
## print.tree cli
## Loading required package: mda
## Loading required package: class
## Loaded mda 0.5-2
## Loading required package: mgcv
## Loading required package: nlme
##
## Attaching package: 'nlme'
## The following object is masked from 'package:usdm':
##
## Variogram
## The following object is masked from 'package:raster':
##
## getData
## The following object is masked from 'package:dplyr':
##
## collapse
## This is mgcv 1.8-38. For overview type 'help("mgcv-package")'.
## Loading required package: glmnet
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
## Loaded glmnet 4.1-3
## Loading required package: earth
## Loading required package: Formula
## Loading required package: plotmo
## Loading required package: plotrix
## Loading required package: TeachingDemos
## Loading required package: rJava
## Loading required package: RSNNS
## Loading required package: Rcpp
## Loading required package: ranger
## Loading required package: randomForest
## randomForest 4.7-1
## Type rfNews() to see new features/changes/bug fixes.
##
## Attaching package: 'randomForest'
## The following object is masked from 'package:ranger':
##
## importance
## The following object is masked from 'package:dplyr':
##
## combine
## The following object is masked from 'package:ggplot2':
##
## margin
## Loading required package: rpart
## Loading required package: kernlab
##
## Attaching package: 'kernlab'
## The following objects are masked from 'package:raster':
##
## buffer, rotated
## The following object is masked from 'package:purrr':
##
## cross
## The following object is masked from 'package:ggplot2':
##
## alpha
phago_sdm <- sdm(species~., data = phago_sdmdata, methods = c('rf', 'svm', 'fda'), replications = c('sub', 'boot'), n = 4)
## Loading required package: parallel
phago_ensemble <- ensemble(phago_sdm, newdata = phago_crop_used, setting = list(method = 'weighted', stat = 'TSS', opt = 2))
data("wrld_simpl")
plot(phago_ensemble, main = 'Potential Suitable Habitats of Phago loricatus')
plot(wrld_simpl, add = T)
points(phago_spatial, col = 'black')
With this rapid run through available occurrence and predictor data, there are some evidence that the species’ potential suitable habitats are confined along the coastal waters. Protection of such habitats transcends more than one country and may need collaborative effort for holistic conservation of Phago loricatus.
This is a work in progress and additional data like phylogenetic information could help boost the findings in future versions. As one would expect, water properties of the inland rivers would be quite important in such model, that has not been included in the present rapid model.