Title: | Analysis of Niche Evolution using Niche and Distribution Models |
---|---|
Description: | Constructing niche models and analyzing patterns of niche evolution. Acts as an interface for many popular modeling algorithms, and allows users to conduct Monte Carlo tests to address basic questions in evolutionary ecology and biogeography. Warren, D.L., R.E. Glor, and M. Turelli (2008) <doi:10.1111/j.1558-5646.2008.00482.x> Glor, R.E., and D.L. Warren (2011) <doi:10.1111/j.1558-5646.2010.01177.x> Warren, D.L., R.E. Glor, and M. Turelli (2010) <doi:10.1111/j.1600-0587.2009.06142.x> Cardillo, M., and D.L. Warren (2016) <doi:10.1111/geb.12455> D.L. Warren, L.J. Beaumont, R. Dinnage, and J.B. Baumgartner (2019) <doi:10.1111/ecog.03900>. |
Authors: | Dan Warren [aut, cre] , Russell Dinnage [aut] |
Maintainer: | Dan Warren <[email protected]> |
License: | GPL-2 |
Version: | 1.1.3 |
Built: | 2024-11-10 06:04:18 UTC |
Source: | https://github.com/danlwarren/enmtools |
Takes an enmtools.species object and a set of environment layers, and adds the environmental predictor values to the occurrence data. Typically not called by the user directly. Code modified from Elith and Hijmans SDM with R tutorial
add.env(species, env, verbose = TRUE)
add.env(species, env, verbose = TRUE)
species |
An enmtools.species or enmtools.clade object |
env |
A raster stack of environmental variables |
verbose |
Controls printing of progress messages |
An enmtools.species object with environmental data attached to it.
Triggers an error if any of the extra packages required for an ENMTools function are not available.
assert.extras(funs = NULL)
assert.extras(funs = NULL)
funs |
character vector of ENMTools function names to install extra dependencies for. If 'NULL', extras for all ENMTools functions will be installed. |
None, this function is used for its side-effects
if(check.extras("enmtools.gam")) { assert.extras("enmtools.gam") }
if(check.extras("enmtools.gam")) { assert.extras("enmtools.gam") }
Takes a set of points, a buffer radius, a buffer type, and a mask and returns either a raster, a polygon, or background points representing the species background. Code modified from Elith and Hijmans SDM with R tutorial
background.buffer( points, buffer.width, buffer.type = "circles", mask = NA, return.type = "raster", n = 1000 )
background.buffer( points, buffer.width, buffer.type = "circles", mask = NA, return.type = "raster", n = 1000 )
points |
A two column data frame with X and Y coordinates |
buffer.width |
Radius for circular buffers to draw around points, for buffer.type = circular. If buffer.type = "convhull", denotes the amount to which the initial polygon should be buffered. It's worth noting that this argument may in some cases be treated as map units (e.g., lat and long), but in other caess may be treated as meters. If you're getting weird behavior, you might try changing the units you're using to specify buffer.width. |
buffer.type |
Which method to use for buffering species occurrence points. Currently accepts "circles" and "convhull". |
mask |
A raster to use as a mask for trimming the buffer if the return type is "raster" or "points" |
return.type |
What type of object to return. Can be "raster", "polygon", or "points". |
n |
Sample size for number of background points to return, for return.type = "points". |
Either a raster, a polygon, or a data frame of points representing the species background.
NOTE: This function has been replaced by background.buffer.
background.points.buffer(points, radius, n, mask)
background.points.buffer(points, radius, n, mask)
points |
A two column data frame with X and Y coordinates |
radius |
Radius for circular buffers to draw around points, in meters. |
n |
Sample size for number of background points to return |
mask |
A raster to use as a mask for drawing points |
A data frame of points drawn at random from circular buffers around the occurrence points.
NOTE: This function has been replaced by background.buffer.
background.raster.buffer(points, radius, mask)
background.raster.buffer(points, radius, mask)
points |
A two column data frame with X and Y coordinates |
radius |
Radius for circular buffers to draw around points, in meters. |
mask |
A raster to use as a mask |
A raster object with values of 1 in every grid cell falling within the buffer.
library(ENMTools) background.raster.buffer(iberolacerta.clade$species$cyreni$presence.points, 100000, euro.worldclim)
library(ENMTools) background.raster.buffer(iberolacerta.clade$species$cyreni$presence.points, 100000, euro.worldclim)
NOTE: This function has been replaced by background.buffer.
background.shape.buffer(points, radius)
background.shape.buffer(points, radius)
points |
A two column data frame with X and Y coordinates |
radius |
Radius for circular buffers to draw around points, in meters. |
A polygon shapefile.
background.test Conduct a background test (also called a similarity test), as described in Warren et al. 2008. This test can either be run as an asymmetric test (species.1 vs background of species.2) or as a symmetric test (background of species.1 vs background of species.2). For GLM, Bioclim, and Domain models the replicates will be constructed from the background points supplied for each species. For Maxent, the replicates will be constructed from the range rasters stored in the enmtools.species objects.
background.test( species.1, species.2, env, type, f = NULL, nreps = 99, test.type = "asymmetric", nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
background.test( species.1, species.2, env, type, f = NULL, nreps = 99, test.type = "asymmetric", nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
species.1 |
An emtools.species object from which presence points (asymmetric) or background (symmetric) will be sampled. |
species.2 |
An enmtools.species object from which background will be sampled. |
env |
A SpatRaster object containing environmental data |
type |
The type of model to construct, currently accepts "glm", "mx", "bc", "gam", or "dm" |
f |
A function to use for model fitting. Only required for GLM models at the moment. |
nreps |
Number of replicates to perform |
test.type |
Controls whether the background test will be "symmetric" or "asymmetric" |
nback |
Number of background points for models |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
low.memory |
When set to TRUE, replicate models are written to disc instead of being stored in the output object. Replicate models stored in the output object contain paths to the replicate models on disk instead of the rasters themselves. |
rep.dir |
Directory for storing replicate models when low.memory is set to TRUE. If not specified, the working directory will be used. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
Controls whether empirical and replicate models should be clamped to the environment space used for training. |
... |
Additional arguments to be passed to model fitting functions. |
results A list containing replicates, models for the empirical data, and summary statistics and plots.
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni$range <- background.raster.buffer(cyreni$presence.points, 100000, euro.worldclim) monticola$range <- background.raster.buffer(monticola$presence.points, 100000, euro.worldclim) background.test(cyreni, monticola, env = euro.worldclim, type = "glm", f = pres ~ bio1 + bio12, nreps = 10)
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni$range <- background.raster.buffer(cyreni$presence.points, 100000, euro.worldclim) monticola$range <- background.raster.buffer(monticola$presence.points, 100000, euro.worldclim) background.test(cyreni, monticola, env = euro.worldclim, type = "glm", f = pres ~ bio1 + bio12, nreps = 10)
calc.B1, Calculates standardized version of Levins (1968) B1 measure of niche breadth given a vector of suitabilities
calc.B1(x)
calc.B1(x)
x |
A numeric vector |
B1 A calculation of Levins (1968) B1 metric
calc.B1(c(1, .001, .001))
calc.B1(c(1, .001, .001))
calc.B2, Calculates standardized version of Levins (1968) B2 measure of niche breadth given a vector of suitabilities
calc.B2(x)
calc.B2(x)
x |
A numeric vector |
B2 A calculation of Levins (1968) B2 metric
calc.B2(c(1, .001, .001))
calc.B2(c(1, .001, .001))
Takes an emtools.species object and adds background points if they're missing. Looks for range raster first, then goes for environmental layers.
check.bg( species, env = NA, nback = 1000, bg.source = "default", verbose = FALSE, bias = NA )
check.bg( species, env = NA, nback = 1000, bg.source = "default", verbose = FALSE, bias = NA )
species |
An enmtools.species object |
env |
A SpatRaster containing environmental data. |
nback |
Number of background points to generate, if any |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
bias |
A SpatRaster representing estimated relative sampling bias. Used when bg.source is either "range" or "env". |
An enmtools.species object with background points.
Checking for complians of an enmtools.clade object
check.clade(this.clade)
check.clade(this.clade)
this.clade |
An enmtools.clade object |
An enmtools.clade object with appropriate formatting.
check.clade(iberolacerta.clade)
check.clade(iberolacerta.clade)
Automating some basic tasks for using a raster stack for modeling. Checks rasters for same extent and resolution, and sets values in each layer to NA if there is an NA in any other layer.
check.env(env, verbose = FALSE)
check.env(env, verbose = FALSE)
env |
A stack of environmental rasters |
verbose |
Controls printing of progress messages |
A raster stack.
check.env(euro.worldclim)
check.env(euro.worldclim)
Check that the extra packages needed for an ENMTools function are installed and available
check.extras(funs = NULL)
check.extras(funs = NULL)
funs |
character vector of ENMTools function names to install extra dependencies for. If 'NULL', extras for all ENMTools functions will be installed. |
Logical, 'TRUE' if all required extra packages are available, 'FALSE' otherwise
check.extras("enmtools.gam")
check.extras("enmtools.gam")
Checking compliance for an object of class enmtools.species.
check.species(this.species, env = NA, trim.dupes = FALSE)
check.species(this.species, env = NA, trim.dupes = FALSE)
this.species |
An enmtools.species object to be checked. |
env |
Environmental rasters that will be used for modeling. If provided to check.species, ENMTools will remove occurrence points that have NA values for any layer in env. |
trim.dupes |
Controls whether to trim duplicate occurrence points from the presence data. Defaults to FALSE, which leaves duplicates in place. Alternatives are "exact", which will remove points with the same lat/long as another point, or "grid", which will trim data so that there is at most one point per grid cell for the rasters in env, and centers those points in the cells. |
An enmtools.species object with appropriate formatting.
check.species(iberolacerta.clade$species$monticola)
check.species(iberolacerta.clade$species$monticola)
Takes an emtools.model object and a set of environment layers and clamps the environment layers so that no variable falls outside of the range available in the training data.
clamp.env(model, env)
clamp.env(model, env)
model |
An enmtools.model object. Alternatively the analysis.df component of an enmtools.model object. |
env |
A SpatRaster of environmental data. |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
monticola.gam <- enmtools.gam(iberolacerta.clade$species$monticola, euro.worldclim[[c(1,5,9,13)]]) euro.clamped <- clamp.env(monticola.gam, euro.worldclim) clamped.prediction <- predict(monticola.gam, euro.clamped) terra::plot(clamped.prediction$suitability - monticola.gam$suitability)
monticola.gam <- enmtools.gam(iberolacerta.clade$species$monticola, euro.worldclim[[c(1,5,9,13)]]) euro.clamped <- clamp.env(monticola.gam, euro.worldclim) clamped.prediction <- predict(monticola.gam, euro.clamped) terra::plot(clamped.prediction$suitability - monticola.gam$suitability)
Takes a list of enmtools.species objects and combines them into a single enmtools.species object
combine.species(species.list)
combine.species(species.list)
species.list |
List of enmtools.species objects that you want to combine together |
An enmtools.species object with the occurrence data, names, and range rasters for the species list combined into one.
combine.species(iberolacerta.clade$species)
combine.species(iberolacerta.clade$species)
Takes a an ENMTools clade object and a vector of species names. Drops the species from the tree and removes data from the clade object.
drop.species(clade, species)
drop.species(clade, species)
clade |
An ENMTools clade object |
species |
A name or vector of names of species within the enmtools.clade object. |
An enmtools.clade object with the provided species dropped both from the tree and from the set of enmtools.species objects.
if(requireNamespace("ape", quietly = TRUE)) { new.clade <- drop.species(iberolacerta.clade, c("cyreni", "monticola")) }
if(requireNamespace("ape", quietly = TRUE)) { new.clade <- drop.species(iberolacerta.clade, c("cyreni", "monticola")) }
Takes an overlap matrix and a tree and runs permutation tests to determine the statistical significance of the relationship between overlap and time
enmtools.aoc( clade, env = NULL, overlap.source, nreps = 100, f = NULL, overlap.matrix = NULL, metric = "D", ... )
enmtools.aoc( clade, env = NULL, overlap.source, nreps = 100, f = NULL, overlap.matrix = NULL, metric = "D", ... )
clade |
An enmtools.clade object containing species data and a phylogeny |
env |
Environmental layers for use when overlap is calculated using niche models. |
overlap.source |
The source of the overlaps to calculate. Choices are "bc", "dm", "gam", "glm", "mx", "range", and "point" |
nreps |
A number of reps to do |
f |
The model to be used for GLM and GAM comparisons |
overlap.matrix |
A matrix of overlaps to use, for option overlap.source = "matrix" |
metric |
The overlap metric to use. For ENM sources, this can be any combination of "D", "I", "cor", "env.D", "env.I", and "env.cor". for range and point overlap this argument is ignored. |
... |
Arguments to be passed to modeling functions for ENM-based overlaps. |
A list containing a data frame of coefficients from the empirical regression of overlap on time along with the coefficients from all Monte Carlo replicates, along with plots and p values for the accompanying statistical tests.
Takes an emtools.species object with presence and background points, and builds a Bioclim model
enmtools.bc( species, env = NA, test.prop = 0, report = NULL, overwrite = FALSE, nback = 1000, env.nback = 10000, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
enmtools.bc( species, env = NA, test.prop = 0, report = NULL, overwrite = FALSE, nback = 1000, env.nback = 10000, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
report |
Optional name of an html file for generating reports |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
nback |
Number of background points for models. In the case of bioclim models these are only used for evaluation. |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
... |
Arguments to be passed to bioclim() |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
enmtools.bc(iberolacerta.clade$species$monticola, env = euro.worldclim)
enmtools.bc(iberolacerta.clade$species$monticola, env = euro.worldclim)
Takes an emtools.model object, and reformats it to run through the CalibratR package, calculates Continuous Boyce Index, and runs a Hosmer-Lemeshow goodness-of-fit test. Can either do a full CalibratR run or just return ECE/MCE statistics and plots.
enmtools.calibrate( model, recalibrate = FALSE, cuts = 11, env = NA, n.background = 10000, recal.methods = c(1, 2, 3, 4), ... )
enmtools.calibrate( model, recalibrate = FALSE, cuts = 11, env = NA, n.background = 10000, recal.methods = c(1, 2, 3, 4), ... )
model |
An enmtools.model object |
recalibrate |
When TRUE, does a full CalibratR "calibrate" run to recalibrate the model. When FALSE, just returns metrics and plots measuring calibration of the model as is. |
cuts |
The number of bins to split suitability scores into for calculating calibration. |
env |
A set of environment layers to be used for optional env space metrics |
n.background |
Number of background points to be used for env space metrics |
recal.methods |
Numeric or vector specifying which methods the CalibratR package should use for recalibration. 1=hist_scaled, 2=hist_transformed, 3=BBQ_scaled, 4=BBQ_transformed. Option 5 is disabled by default due to errors. |
... |
Further arguments to be passed to CalibratR's "calibrate" function. |
An enmtools.calibrate object containing calibration and classificaction plots, metrics of model calibration, and (optionally) versions of the model that were recalibrated using various methods.
#install.extras(repos='http://cran.us.r-project.org') monticola.glm <- enmtools.glm(iberolacerta.clade$species$monticola, env = euro.worldclim, f = pres ~ bio1 + bio9, test.prop = 0.3) if(check.extras("enmtools.calibrate")) { enmtools.calibrate(monticola.glm) }
#install.extras(repos='http://cran.us.r-project.org') monticola.glm <- enmtools.glm(iberolacerta.clade$species$monticola, env = euro.worldclim, f = pres ~ bio1 + bio9, test.prop = 0.3) if(check.extras("enmtools.calibrate")) { enmtools.calibrate(monticola.glm) }
Defining a class for enmtools.clade. Each clade gets:
enmtools.clade(species = NA, tree = NA) save.enmtools.clade(x, ...) load.enmtools.clade(x, ...)
enmtools.clade(species = NA, tree = NA) save.enmtools.clade(x, ...) load.enmtools.clade(x, ...)
species |
A list of enmtools.species objects |
tree |
A tree showing the relationships between the species |
x |
Path to an enmtools.species file |
... |
Other arguments passed to R's load function |
An enmtools.clade object, either empty or containing a formatted version of the data that was passed into the function.
save.enmtools.clade()
: Save an ENMTools clade object
load.enmtools.clade()
: Load an ENMTools clade object
Takes an emtools.species object with presence and background points, and builds a Domain model
enmtools.dm( species, env = NA, test.prop = 0, report = NULL, nback = 1000, env.nback = 10000, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
enmtools.dm( species, env = NA, test.prop = 0, report = NULL, nback = 1000, env.nback = 10000, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
report |
Optional name of an html file for generating reports |
nback |
Number of background points for models. In the case of Domain, these are only used for evaluation. |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
... |
Arguments to be passed to domain() |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
enmtools.dm(iberolacerta.clade$species$monticola, env = euro.worldclim)
enmtools.dm(iberolacerta.clade$species$monticola, env = euro.worldclim)
enmtools.ecospat.bg, Runs an ecospat background/similarity test using enmtool.species objects.
enmtools.ecospat.bg( species.1, species.2, env, nreps = 99, layers = NULL, test.type = "symmetric", th.sp = 0, th.env = 0, R = 100, nback = 1000, bg.source = "default", verbose = FALSE, ... )
enmtools.ecospat.bg( species.1, species.2, env, nreps = 99, layers = NULL, test.type = "symmetric", th.sp = 0, th.env = 0, R = 100, nback = 1000, bg.source = "default", verbose = FALSE, ... )
species.1 |
An enmtools.species object |
species.2 |
An enmtools.species object |
env |
A set of environmental layers |
nreps |
The number of pseudoreplicates to perform |
layers |
A vector of length 2 containing the names of the layers to be used. If no layer names are provided and there are more than two layers in env, enmtools will perform a pca and use the top two layers from that. |
test.type |
Symmetric or asymmetric test. An asymmetric test is bguivalent to the "one.sided" option in the ecospat documentation, while a symmetric one would be two-sided. |
th.sp |
Quantile of species densities used as a threshold to exclude low species density values. See documentation for ecospat.grid.clim.dyn. |
th.env |
Quantile of environmental densities across study sites used as threshold to exclude low environmental density values. See documentation for ecospat.grid.clim.dyn. |
R |
Resolution of the grid. See documentation for ecospat.grid.clim.dyn. |
nback |
Number of background points to use for density calculations. |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
... |
Further arguments to be passed to check.bg |
A list containing the ecospat output kernel density estimates for each species and their background, as well as the results of hypothesis tests and their accompanying plots.
#install.extras(repos='http://cran.us.r-project.org') monticola <- iberolacerta.clade$species$monticola cyreni <- iberolacerta.clade$species$cyreni if(check.extras("enmtools.ecospat.bg")) { enmtools.ecospat.bg(monticola, cyreni, euro.worldclim[[1:2]], nback = 500) }
#install.extras(repos='http://cran.us.r-project.org') monticola <- iberolacerta.clade$species$monticola cyreni <- iberolacerta.clade$species$cyreni if(check.extras("enmtools.ecospat.bg")) { enmtools.ecospat.bg(monticola, cyreni, euro.worldclim[[1:2]], nback = 500) }
enmtools.ecospat.id, Runs an ecospat identity test using enmtool.species objects.
enmtools.ecospat.id( species.1, species.2, env, nreps = 99, layers = NULL, th.sp = 0, th.env = 0, R = 100, nback = 1000, bg.source = "default", verbose = FALSE )
enmtools.ecospat.id( species.1, species.2, env, nreps = 99, layers = NULL, th.sp = 0, th.env = 0, R = 100, nback = 1000, bg.source = "default", verbose = FALSE )
species.1 |
An enmtools.species object |
species.2 |
An enmtools.species object |
env |
A set of environmental layers |
nreps |
The number of pseudoreplicates to perform |
layers |
A vector of length 2 containing the names of the layers to be used. If no layer names are provided and there are more than two layers in env, enmtools will perform a pca and use the top two layers from that. |
th.sp |
Quantile of species densities used as a threshold to exclude low species density values. See documentation for ecospat.grid.clim.dyn. |
th.env |
Quantile of environmental densities across study sites used as threshold to exclude low environmental density values. See documentation for ecospat.grid.clim.dyn. |
R |
Resolution of the grid. See documentation for ecospat.grid.clim.dyn. |
nback |
Number of background points to use for density calculations. |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
A list containing the ecospat output kernel density estimates for each species and their background, as well as the results of hypothesis tests and their accompanying plots.
#install.extras(repos='http://cran.us.r-project.org') monticola <- iberolacerta.clade$species$monticola cyreni <- iberolacerta.clade$species$cyreni if(check.extras("enmtools.ecospat.id")) { enmtools.ecospat.id(monticola, cyreni, euro.worldclim[[1:2]], nback = 500) }
#install.extras(repos='http://cran.us.r-project.org') monticola <- iberolacerta.clade$species$monticola cyreni <- iberolacerta.clade$species$cyreni if(check.extras("enmtools.ecospat.id")) { enmtools.ecospat.id(monticola, cyreni, euro.worldclim[[1:2]], nback = 500) }
Takes an emtools.species object with presence and background points, and builds a gam
enmtools.gam( species, env, f = NULL, test.prop = 0, k = 4, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, weights = "equal", gam.method = "REML", gam.select = TRUE, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
enmtools.gam( species, env, f = NULL, test.prop = 0, k = 4, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, weights = "equal", gam.method = "REML", gam.select = TRUE, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
f |
Standard gam formula |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
k |
Dimension of the basis used to represent the smooth term. See documentation for s() for details. |
nback |
Number of background points to draw from range or env, if background points aren't provided |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
report |
Optional name of an html file for generating reports |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
weights |
If this is set to "equal", presences and background data will be assigned weights so that the sum of all presence points weights equals the sum of all background point weights. Otherwise, weights are not provided to the model. |
gam.method |
Defaults to restricted maximum likelihood to facilitate predictor selection, but if you want to use another method you can pass anything here that gam's "method" argument understands. |
gam.select |
Controls whether gam algorithm attempts to optimize smoothness and reduce model complexity. See help("gam.selection") for details. |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
... |
Arguments to be passed to gam() |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
if(requireNamespace("mgcv", quietly = TRUE)) { enmtools.gam(iberolacerta.clade$species$monticola, env = euro.worldclim, f = pres ~ bio1 + bio9) }
if(requireNamespace("mgcv", quietly = TRUE)) { enmtools.gam(iberolacerta.clade$species$monticola, env = euro.worldclim, f = pres ~ bio1 + bio9) }
Takes an enmtools.species object with presence and background points, and builds a GLM
enmtools.glm( species, env, f = NULL, test.prop = 0, eval = TRUE, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, weights = "equal", bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, step = FALSE, ... )
enmtools.glm( species, env, f = NULL, test.prop = 0, eval = TRUE, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, weights = "equal", bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, step = FALSE, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
f |
Standard GLM formula |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
eval |
Determines whether model evaluation should be done. Turned on by default, but moses turns it off to speed things up. |
nback |
Number of background points to draw from range or env, if background points aren't provided |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
report |
Optional name of an html file for generating reports |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
weights |
If this is set to "equal", presences and background data will be assigned weights so that the sum of all presence points weights equals the sum of all background point weights. Otherwise, weights are not provided to the model. |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
step |
Logical determining whether to do stepwise model selection or not |
... |
Arguments to be passed to glm() |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
enmtools.glm(iberolacerta.clade$species$monticola, env = euro.worldclim, f = pres ~ bio1 + bio9)
enmtools.glm(iberolacerta.clade$species$monticola, env = euro.worldclim, f = pres ~ bio1 + bio9)
THIS FUNCTION IS CURRENTLY DISABLED. Takes an emtools.species object and environmental layers, and constructs a hypervolume using the R package hypervolume
enmtools.hypervolume( species, env, samples.per.point = 10, reduction.factor = 0.1, method = "gaussian", verbose = FALSE, clamp = TRUE, ... )
enmtools.hypervolume( species, env, samples.per.point = 10, reduction.factor = 0.1, method = "gaussian", verbose = FALSE, clamp = TRUE, ... )
species |
An enmtools.species object |
env |
A stack of environmental rasters |
samples.per.point |
To be passed to hypervolume_gaussian |
reduction.factor |
To be passed to hypervolume_project |
method |
Method for constructing hypervolumes, defaults to "gaussian" |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
... |
Extra parameters to be passed to hypervolume_gaussian |
An enmtools hypvervolume object containing a hypervolume object, a raster of suitability scores, the species name, and the occurrence data frame.
#install.extras(repos='http://cran.us.r-project.org') env <- euro.worldclim[[c(1,8,12,17)]] if(requireNamespace("hypervolume", quietly = TRUE)) { monticola.hv <- enmtools.hypervolume(iberolacerta.clade$species$monticola, env = env) }
#install.extras(repos='http://cran.us.r-project.org') env <- euro.worldclim[[c(1,8,12,17)]] if(requireNamespace("hypervolume", quietly = TRUE)) { monticola.hv <- enmtools.hypervolume(iberolacerta.clade$species$monticola, env = env) }
Takes an emtools.species object with presence and background points, and builds a maxent model
enmtools.maxent( species, env, test.prop = 0, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
enmtools.maxent( species, env, test.prop = 0, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
nback |
Number of background points to draw from range or env, if background points aren't provided |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
report |
Optional name of an html file for generating reports |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
... |
Arguments to be passed to maxent() |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
if(check.extras("enmtools.maxent")) { ## maxent is not working on some platforms so use try() try(enmtools.maxent(iberolacerta.clade$species$monticola, env = euro.worldclim)) }
if(check.extras("enmtools.maxent")) { ## maxent is not working on some platforms so use try() try(enmtools.maxent(iberolacerta.clade$species$monticola, env = euro.worldclim)) }
Takes an emtools.species object with presence and background points, and builds a random forest model
enmtools.rf( species, env, f = NULL, test.prop = 0, eval = TRUE, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
enmtools.rf( species, env, f = NULL, test.prop = 0, eval = TRUE, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
f |
A formula for fitting the model |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
eval |
Determines whether model evaluation should be done. Turned on by default, but moses turns it off to speed things up. |
nback |
Number of background points to draw from range or env, if background points aren't provided |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
report |
Optional name of an html file for generating reports |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
... |
Arguments to be passed to rf() |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
enmtools.rf(iberolacerta.clade$species$monticola, env = euro.worldclim, nback = 500)
enmtools.rf(iberolacerta.clade$species$monticola, env = euro.worldclim, nback = 500)
Takes an emtools.species object with presence and background points, and builds a random forest model using the 'probability mode' in package 'ranger'
enmtools.rf.ranger( species, env, f = NULL, test.prop = 0, eval = TRUE, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
enmtools.rf.ranger( species, env, f = NULL, test.prop = 0, eval = TRUE, nback = 1000, env.nback = 10000, report = NULL, overwrite = FALSE, rts.reps = 0, bg.source = "default", verbose = FALSE, clamp = TRUE, corner = NA, bias = NA, ... )
species |
An enmtools.species object |
env |
A SpatRaster of environmental data. |
f |
A formula for fitting the model |
test.prop |
Proportion of data to withhold randomly for model evaluation, or "block" for spatially structured evaluation. |
eval |
Determines whether model evaluation should be done. Turned on by default, but moses turns it off to speed things up. |
nback |
Number of background points to draw from range or env, if background points aren't provided |
env.nback |
Number of points to draw from environment space for environment space discrimination metrics. |
report |
Optional name of an html file for generating reports |
overwrite |
TRUE/FALSE whether to overwrite a report file if it already exists |
rts.reps |
The number of replicates to do for a Raes and ter Steege-style test of significance |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
When set to TRUE, clamps the environmental layers so that predictions made outside the min/max of the training data for each predictor are set to the value for the min/max for that predictor. Prevents the model from extrapolating beyond the min/max bounds of the predictor space the model was trained in, although there could still be projections outside the multivariate training space if predictors are strongly correlated. |
corner |
An integer from 1 to 4. Selects which corner to use for "block" test data. By default the corner is selected randomly. |
bias |
An optional raster estimating relative sampling effort per grid cell. Will be used for drawing background data. |
... |
Arguments to be passed to |
An enmtools model object containing species name, model formula (if any), model object, suitability raster, marginal response plots, and any evaluation objects that were created.
enmtools.rf.ranger(iberolacerta.clade$species$monticola, env = euro.worldclim, nback = 500)
enmtools.rf.ranger(iberolacerta.clade$species$monticola, env = euro.worldclim, nback = 500)
Each species gets:
enmtools.species( range = NA, presence.points = NA, background.points = NA, species.name = NA, models = NA ) save.enmtools.species(x, ...) load.enmtools.species(x, ...)
enmtools.species( range = NA, presence.points = NA, background.points = NA, species.name = NA, models = NA ) save.enmtools.species(x, ...) load.enmtools.species(x, ...)
range |
A raster or SpatialPolygon with the actual range they occur in |
presence.points |
A data frame with sampled localities |
background.points |
A data frame with absence/pseudoabsence/background localities |
species.name |
A character vector with the species name |
models |
A list of models that are made for the species, which will be stuffed in there as we go along to pass the check. This is used by internal enmtools functions to make sure the necessary data is present before processing anything. |
x |
Path to an enmtools.species file |
... |
Other arguments passed to R's load function |
Returns an enmtools.species object, either empty or populated with the parameter values that were passed into the function.
save.enmtools.species()
: Save an ENMTools species object
load.enmtools.species()
: Load an ENMTools species object
Takes an enmtools.model object, and performs variable importance analyses on it using methods from the vip package
enmtools.vip( model, metric = "roc_auc", nsim = 10, method = "permute", verbose = FALSE, ... )
enmtools.vip( model, metric = "roc_auc", nsim = 10, method = "permute", verbose = FALSE, ... )
model |
An enmtools.model object |
metric |
The metric to use for measuring how variables affect model predictions |
nsim |
The number of simulations to be run for method "permute" |
method |
A character string or vector containing any combination of "model", "permute", "shap", or "firm". For details on what these mean, see the vip package help. |
verbose |
Controls printing of messages |
... |
Further arguments to be passed to vip's "vi" functions. |
An enmtools.vip object
#install.extras(repos='http://cran.us.r-project.org') monticola.glm <- enmtools.glm(iberolacerta.clade$species$monticola, env = euro.worldclim, test.prop = 0.3) if(check.extras("enmtools.vip")) { enmtools.vip(monticola.glm) }
#install.extras(repos='http://cran.us.r-project.org') monticola.glm <- enmtools.glm(iberolacerta.clade$species$monticola, env = euro.worldclim, test.prop = 0.3) if(check.extras("enmtools.vip")) { enmtools.vip(monticola.glm) }
Calculates breadth of a model in environment space using latin hypercube sampling
env.breadth(model, env, tolerance = 1e-04, max.reps = 10, chunk.size = 1e+05)
env.breadth(model, env, tolerance = 1e-04, max.reps = 10, chunk.size = 1e+05)
model |
An enmtools.model object or a model object that can be projected using the predict() function |
env |
A raster, raster stack of environmental data, or a list of minima and maxima for the environmental space to evaluate models over. |
tolerance |
How close do successive overlap metrics have to be before we decide we're close enough to the final answer |
max.reps |
Maximum number of attempts that will be made to find suitable starting conditions |
chunk.size |
How many combinations of environmental variables to try at a time. If your niche breadth in environment space is small, increasing this value may help you get a result. |
A list containing the environmental space version of the B2 metric and a plot of B2 estimates as a function of sample size, used as a convergence diagnostic.
cyreni <- iberolacerta.clade$species$cyreni cyreni.glm <- enmtools.glm(cyreni, euro.worldclim, test.prop = 0.2, f = pres ~ bio1 + bio12, nback = 500) env.breadth(cyreni.glm, euro.worldclim)
cyreni <- iberolacerta.clade$species$cyreni cyreni.glm <- enmtools.glm(cyreni, euro.worldclim, test.prop = 0.2, f = pres ~ bio1 + bio12, nback = 500) env.breadth(cyreni.glm, euro.worldclim)
Calculates evaluation metrics (AUC, etc.) using latin hypercube sampling in environment space
env.evaluate( species, model, env, bg.source = "background", n.background = 10000, test.eval = FALSE, verbose = FALSE, ... )
env.evaluate( species, model, env, bg.source = "background", n.background = 10000, test.eval = FALSE, verbose = FALSE, ... )
species |
An enmtools.species object |
model |
An enmtools.model object or a model that can be projected using the predict() function of dismo |
env |
A SpatRaster of environmental data. |
bg.source |
Determines whether minima and maxima of the environment space should be picked using the environment layers or the background points. |
n.background |
The number of background points to sample from the environment space. |
test.eval |
When set to "true", env.evaluate evaluates the test data stored in the model object instead of the training data. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
... |
Arguments to be passed to othfer functions |
A dismo evaluate object measuring the performance of model predictions in environment space.
cyreni <- iberolacerta.clade$species$cyreni cyreni.glm <- enmtools.glm(cyreni, euro.worldclim, test.prop = 0.2, f = pres ~ bio1 + bio12, nback = 500) env.evaluate(cyreni, cyreni.glm, euro.worldclim)
cyreni <- iberolacerta.clade$species$cyreni cyreni.glm <- enmtools.glm(cyreni, euro.worldclim, test.prop = 0.2, f = pres ~ bio1 + bio12, nback = 500) env.evaluate(cyreni, cyreni.glm, euro.worldclim)
Calculates overlap between models in environment space using latin hypercube sampling
env.overlap( model.1, model.2, env, tolerance = 0.001, max.reps = 10, cor.method = "spearman", chunk.size = 1e+05, recal.model.1 = NA, recal.model.2 = NA, verbose = FALSE )
env.overlap( model.1, model.2, env, tolerance = 0.001, max.reps = 10, cor.method = "spearman", chunk.size = 1e+05, recal.model.1 = NA, recal.model.2 = NA, verbose = FALSE )
model.1 |
An enmtools.model object model object that can be projected using the predict() function |
model.2 |
Another enmtools.model object or other model object that can be projected using the predict() function |
env |
A raster, raster stack of environmental data, or a list of minima and maxima for the environmental space to evaluate models over |
tolerance |
How close do successive overlap metrics have to be before we decide we're close enough to the final answer |
max.reps |
Maximum number of attempts that will be made to find suitable starting conditions |
cor.method |
Which method to use for calculating correlations between models |
chunk.size |
How many combinations of environmental variables to try at a time. If your niche breadth in environment space is small, increasing this value may help you get a result. |
recal.model.1 |
Optional. The output of enmtools.recalibrate for model 1, which needs to have been run with "recalibrate = TRUE". |
recal.model.2 |
Optional. The output of enmtools.recalibrate for model 2, which needs to have been run with "recalibrate = TRUE". |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
A list of values measuring the overlap between models in environment space, as well as some plots depicting change of the estimates as a function of how many samples were used, which are included as a sort of convergence diagnostic.
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni.glm <- enmtools.glm(cyreni, euro.worldclim, f = pres ~ bio1 + bio12, nback = 500) monticola.glm <- enmtools.glm(monticola, euro.worldclim, f = pres ~ bio1 + bio12, nback = 500) env.overlap(cyreni.glm, monticola.glm, euro.worldclim)
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni.glm <- enmtools.glm(cyreni, euro.worldclim, f = pres ~ bio1 + bio12, nback = 500) monticola.glm <- enmtools.glm(monticola, euro.worldclim, f = pres ~ bio1 + bio12, nback = 500) env.overlap(cyreni.glm, monticola.glm, euro.worldclim)
This is a fairly low-resolution set of Worldclim layers for Europe to be used in demonstrating ENMTools functions.
euro.worldclim
euro.worldclim
A SpatRaster object with 19 worldclim layers.
Find the extra packages needed for an ENMTools function
find.extras(funs = NULL)
find.extras(funs = NULL)
funs |
character vector of ENMTools function names to install extra dependencies for. If 'NULL', extras for all ENMTools functions will be installed. |
A character vector with the names of extra packages required by 'funs'
find.extras("enmtools.calibrate")
find.extras("enmtools.calibrate")
Find the extra packages needed for an ENMTools function that are currently missing (not available)
find.extras.missing(funs = NULL)
find.extras.missing(funs = NULL)
funs |
character vector of ENMTools function names to install extra dependencies for. If 'NULL', extras for all ENMTools functions will be installed. |
A character vector with the names of extra packages required by 'funs' that are currently not available
find.extras.missing("enmtools.calibrate")
find.extras.missing("enmtools.calibrate")
Takes two emtools.species objects with range rasters, calculates overlap between them as in Fitzpatrick and Turelli 2006. This metric divides the area of overlap between two species ranges by the smaller of the two areas of the species' individual ranges. It therefore ranges from 0 (no overlap) to 1 (ranges are the same or the smaller species' range is contained entirely within the larger).
geog.range.overlap(x, y)
geog.range.overlap(x, y)
x |
An enmtools.species object containing a range raster |
y |
An enmtools.species object containing a range raster |
A numeric value measuring range overlap.
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni$range <- background.raster.buffer(cyreni$presence.points, 100000, euro.worldclim) monticola$range <- background.raster.buffer(monticola$presence.points, 100000, euro.worldclim) geog.range.overlap(cyreni, monticola)
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni$range <- background.raster.buffer(cyreni$presence.points, 100000, euro.worldclim) monticola$range <- background.raster.buffer(monticola$presence.points, 100000, euro.worldclim) geog.range.overlap(cyreni, monticola)
Takes an emtools.species object and environmental layers, and constructs a hypervolume using the R package hypervolume
hypervolume.overlap( species.1, species.2, env = NA, reduction.factor = 0.1, ... )
hypervolume.overlap( species.1, species.2, env = NA, reduction.factor = 0.1, ... )
species.1 |
An enmtools.species or enmtools.hypervolume object |
species.2 |
An enmtools.species or enmtools.hypervolume object |
env |
A stack of environmental rasters, required when enmtools.species objects are passed |
reduction.factor |
Passed to hypervolume functions |
... |
Extra parameters to be passed to enmtools.hypervolume |
A list containing a set of hypervolume objects and the overlap that was measured between them.
#install.extras(repos='http://cran.us.r-project.org') mont <- iberolacerta.clade$species$monticola cyr <- iberolacerta.clade$species$cyreni env <- euro.worldclim[[c(1,8,12,17)]] if(requireNamespace("hypervolume", quietly = TRUE)) { hypervolume.overlap(mont, cyr, env = env) }
#install.extras(repos='http://cran.us.r-project.org') mont <- iberolacerta.clade$species$monticola cyr <- iberolacerta.clade$species$cyreni env <- euro.worldclim[[c(1,8,12,17)]] if(requireNamespace("hypervolume", quietly = TRUE)) { hypervolume.overlap(mont, cyr, env = env) }
This is some sample data downloaded from GBIF for the purposes of demonstrating ENMTools functionality.
iberolacerta.clade
iberolacerta.clade
An enmtools.clade object with seven species and a phylogeny.
identity.test Conduct a niche identity/equivalency test as described in Warren et al. 2008.
identity.test( species.1, species.2, env, type, f = NULL, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
identity.test( species.1, species.2, env, type, f = NULL, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
species.1 |
An emtools.species object |
species.2 |
An enmtools.species object |
env |
A SpatRaster object containing environmental data |
type |
The type of model to construct, currently accepts "glm", "mx", "bc", "gam", "rf", or "dm" |
f |
A function to use for model fitting. Only required for GLM models at the moment. |
nreps |
Number of replicates to perform |
nback |
Number of background points for models |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
low.memory |
When set to TRUE, replicate models are written to disc instead of being stored in the output object. Replicate models stored in the output object contain paths to the replicate models on disk instead of the rasters themselves. |
rep.dir |
Directory for storing replicate models when low.memory is set to TRUE. If not specified, the working directory will be used. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
Controls whether empirical and replicate models should be clamped to the environment space used for training. |
... |
Additional arguments to be passed to model fitting functions. |
results A list containing the replicates, models for the empirical data, and summary statistics and plots.
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni$range <- background.raster.buffer(cyreni$presence.points, 100000, euro.worldclim) monticola$range <- background.raster.buffer(monticola$presence.points, 100000, euro.worldclim) identity.test(cyreni, monticola, env = euro.worldclim, type = "glm", f = pres ~ bio1 + bio12, nreps = 10)
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola cyreni$range <- background.raster.buffer(cyreni$presence.points, 100000, euro.worldclim) monticola$range <- background.raster.buffer(monticola$presence.points, 100000, euro.worldclim) identity.test(cyreni, monticola, env = euro.worldclim, type = "glm", f = pres ~ bio1 + bio12, nreps = 10)
Convenience function that installs all extra packages used in ENMTools. ENMTools uses functions from a lot of external packages, and due to CRAN best practices it doesn't install those packages by default. The function install.extras() calls install.packages with a list of all of the extra packages that are not already available. Use [check.extras()] to find out which packages are needed for a list of functions.
install.extras(funs = NULL, install = TRUE, ...)
install.extras(funs = NULL, install = TRUE, ...)
funs |
character vector of ENMTools function names to install extra dependencies for. If 'NULL', extras for all ENMTools functions will be installed. |
install |
Should the packages be installed? |
... |
Other parameters to be passed to |
The list of missing packages is return invisibly.
install.extras(install = FALSE)
install.extras(install = FALSE)
Function that takes an enmtools.model
or enmtools.species
object and
calls the class-appropriate interactive.plot.xx
function for it.
These functions use leaflet
for mapping
and will only function properly if you have an active internet connection.
interactive.plot(x, ...)
interactive.plot(x, ...)
x |
entools.model or species object to plot |
... |
other arguments passed to interactive.plot.enmtools.model or interactive.plot.enmtools.species |
An interactive leaflet plot depicting the predictions and data from the enmtools.model object.
Function that take an enmtools.model
object and plots an
interactive map of the presence points, background points (if applicable), and
species suitability map. This function uses leaflet
for mapping
and will only function properly if you have an active internet connection.
## S3 method for class 'enmtools.model' interactive.plot( x, map.provider = "Esri.WorldPhysical", cluster.points = FALSE, raster.opacity = 1, max.bytes = 4194304, ... )
## S3 method for class 'enmtools.model' interactive.plot( x, map.provider = "Esri.WorldPhysical", cluster.points = FALSE, raster.opacity = 1, max.bytes = 4194304, ... )
x |
entools.model object to plot |
map.provider |
Name of a map provider for the underlying interactive base map. Default is "Esri.WorldPhysical", and attractive topographic map with no place labels. A preview of all map provider options can be viewed at http://leaflet-extras.github.io/leaflet-providers/preview/ |
cluster.points |
Should points be clustered? If TRUE, points close together will be grouped into clusters that can be interactively expanded by clicking on them. |
raster.opacity |
Specifies the opacity level of the suitability raster. |
max.bytes |
Maximum size of raster image to plot. Defaults to 4MB (4194304 bytes) but can be overridden if you have a large raster. Be aware that the image will be knitted into an output file if you're working in R Markdown, causing your output file to be huge if the raster is huge. |
... |
other arguments (not used currently) |
An interactive leaflet plot depicting the predictions and data from the enmtools.model object.
Function that take an enmtools.species
object and plots an
interactive map of the presence points, background points (if applicable), and
species range raster (if applicable). This function uses leaflet
for mapping
and will only function properly if you have an active internet connection.
## S3 method for class 'enmtools.species' interactive.plot( x, map.provider = "Esri.WorldPhysical", cluster.points = FALSE, max.bytes = 4194304, ... )
## S3 method for class 'enmtools.species' interactive.plot( x, map.provider = "Esri.WorldPhysical", cluster.points = FALSE, max.bytes = 4194304, ... )
x |
entools.species object to plot |
map.provider |
Name of a map provider for the underlying interactive base map. Default is "Esri.WorldPhysical", and attractive topographic map with no place labels. A preview of all map provider options can be viewed at http://leaflet-extras.github.io/leaflet-providers/preview/ |
cluster.points |
Should points be clustered? If TRUE, points close together will be grouped into clusters that can be interactively expanded by clicking on them. |
max.bytes |
Maximum size of range raster image to plot. Defaults to 4MB (4194304 bytes) but can be overridden if you have a large range raster. Be aware that the image will be knitted into an output file if you're working in R Markdown, causing your output file to be huge if the raster is huge. |
... |
other arguments (not used currently) |
An interactive leaflet plot visualizing the data present in the species object.
marginal.plots Plots the marginal response of a model to an environmental variable with all other variables held at their mean in env
marginal.plots(model, env, layer, standardize = TRUE, verbose = FALSE)
marginal.plots(model, env, layer, standardize = TRUE, verbose = FALSE)
model |
An enmtools model object |
env |
A SpatRaster object containing environmental data |
layer |
The name of the layer to plot |
standardize |
Whether to set the maximum of the response function to 1, or to instead use the raw values. |
verbose |
Controls printing of messages |
results A plot of the marginal response of the model to the environmental variable.
cyreni.glm <- enmtools.glm(iberolacerta.clade$species$cyreni, f = pres ~ bio1 + bio12, euro.worldclim) marginal.plots(cyreni.glm, euro.worldclim, "bio1")
cyreni.glm <- enmtools.glm(iberolacerta.clade$species$cyreni, f = pres ~ bio1 + bio12, euro.worldclim) marginal.plots(cyreni.glm, euro.worldclim, "bio1")
Takes a list of enmtools.species objects and uses model selection to ask whether they're better treated jointly or separately
moses.list( species.list, env, f = NULL, eval = FALSE, nback = 1000, bg.source = "default", verbose = FALSE, step = FALSE, ... )
moses.list( species.list, env, f = NULL, eval = FALSE, nback = 1000, bg.source = "default", verbose = FALSE, step = FALSE, ... )
species.list |
A list of enmtools.species objects, or an enmtools.clade object. |
env |
A SpatRaster of environmental data. |
f |
A GLM-style function for model fitting |
eval |
Boolean indicating whether or not GLMs should be evaluated using AUC/TSS/etc. |
nback |
Number of background points to generate, if any |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
step |
Logical determining whether to do stepwise model selection or not |
... |
further arguments to be passed to enmtools.glm |
A list containing GLMs for the groups separately and together, as well as AIC values for those models.
multistack.pca, simultaneous PCA on more than one stack of environmental rasters
multistack.pca(..., n = 2)
multistack.pca(..., n = 2)
... |
Any number of environmental raster stacks or bricks |
n |
The number of PCA layers to return |
A list containing a stack or brick of rasters for each input set representing the top n pca axes of the initial environmental variables, as well as the pca object from the analysis that produced them and some useful plots showing the distribution of each PC in the different stacks.
test1 <- terra::crop(euro.worldclim, terra::ext(-10, -5, 40, 43)) test2 <- terra::crop(euro.worldclim, terra::ext(-5, 5, 40, 48)) test3 <- terra::crop(euro.worldclim, terra::ext(5, 15, 44, 48)) multistack.pca(test1, test2, test3)
test1 <- terra::crop(euro.worldclim, terra::ext(-10, -5, 40, 43)) test2 <- terra::crop(euro.worldclim, terra::ext(-5, 5, 40, 48)) test3 <- terra::crop(euro.worldclim, terra::ext(5, 15, 44, 48)) multistack.pca(test1, test2, test3)
Takes an overlap matrix and a tree and returns average overlap at nodes using Fitzpatrick & Turelli averaging method. Typicall called via enmtools.aoc rather than used directly.
node.overlap(overlap, tree)
node.overlap(overlap, tree)
overlap |
An overlap matrix |
tree |
A tree |
A data frame of node ages and overlaps
Takes two emtools.species objects with range rasters, calculates overlap between them as in Cardillo and Warren 2016
point.overlap(x, y)
point.overlap(x, y)
x |
An enmtools.species object containing presence points |
y |
An enmtools.species object containing presence points |
A numeric value measuring the overlap between point distributions.
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola point.overlap(cyreni, monticola)
cyreni <- iberolacerta.clade$species$cyreni monticola <- iberolacerta.clade$species$monticola point.overlap(cyreni, monticola)
rangebreak.blob Conduct a blob rangebreak test as described in Glor and Warren 2011.
rangebreak.blob( species.1, species.2, env, type, f = NULL, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
rangebreak.blob( species.1, species.2, env, type, f = NULL, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
species.1 |
An emtools.species object |
species.2 |
An enmtools.species object |
env |
A SpatRaster object containing environmental data |
type |
The type of model to construct, currently accepts "glm", "mx", "bc", "gam", or "dm" |
f |
A function to use for model fitting. Only required for GLM models at the moment. |
nreps |
Number of replicates to perform |
nback |
Number of background points for models |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
low.memory |
When set to TRUE, replicate models are written to disc instead of being stored in the output object. Replicate models stored in the output object contain paths to the replicate models on disk instead of the rasters themselves. |
rep.dir |
Directory for storing replicate models when low.memory is set to TRUE. If not specified, the working directory will be used. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
Controls whether empirical and replicate models should be clamped to the environment space used for training. |
... |
Additional arguments to be passed to model fitting functions. |
results A list containing the replicates, models for the empirical data, and summary statistics and plots.
cyreni <- iberolacerta.clade$species$cyreni aranica <- iberolacerta.clade$species$aranica
cyreni <- iberolacerta.clade$species$cyreni aranica <- iberolacerta.clade$species$aranica
rangebreak.linear Conduct a linear rangebreak test as described in Glor and Warren 2011.
rangebreak.linear( species.1, species.2, env, type, f = NULL, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
rangebreak.linear( species.1, species.2, env, type, f = NULL, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
species.1 |
An emtools.species object |
species.2 |
An enmtools.species object |
env |
A SpatRaster object containing environmental data |
type |
The type of model to construct, currently accepts "glm", "mx", "bc", "gam", or "dm" |
f |
A function to use for model fitting. Only required for GLM models at the moment. |
nreps |
Number of replicates to perform |
nback |
Number of background points for models |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
low.memory |
When set to TRUE, replicate models are written to disc instead of being stored in the output object. Replicate models stored in the output object contain paths to the replicate models on disk instead of the rasters themselves. |
rep.dir |
Directory for storing replicate models when low.memory is set to TRUE. If not specified, the working directory will be used. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
Controls whether empirical and replicate models should be clamped to the environment space used for training. |
... |
Additional arguments to be passed to model fitting functions. |
results A list containing the replicates, models for the empirical data, and summary statistics and plots.
cyreni <- iberolacerta.clade$species$cyreni aranica <- iberolacerta.clade$species$aranica rangebreak.linear(cyreni, aranica, env = euro.worldclim, type = "glm", f= pres ~ bio1 + bio12, nreps = 10)
cyreni <- iberolacerta.clade$species$cyreni aranica <- iberolacerta.clade$species$aranica rangebreak.linear(cyreni, aranica, env = euro.worldclim, type = "glm", f= pres ~ bio1 + bio12, nreps = 10)
rangebreak.ribbon Conduct a ribbon rangebreak test as described in Glor and Warren 2011.
rangebreak.ribbon( species.1, species.2, ribbon, env, type, f = NULL, width = 1, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
rangebreak.ribbon( species.1, species.2, ribbon, env, type, f = NULL, width = 1, nreps = 99, nback = 1000, bg.source = "default", low.memory = FALSE, rep.dir = NA, verbose = FALSE, clamp = TRUE, ... )
species.1 |
An emtools.species object |
species.2 |
An enmtools.species object |
ribbon |
An enmtools.species object representing the region of marginal habtiat in the overlap between the species' ranges |
env |
A SpatRaster object containing environmental data |
type |
The type of model to construct, currently accepts "glm", "mx", "bc", or "dm" |
f |
A function to use for model fitting. Only required for GLM models at the moment. |
width |
Width of the ribbon, in the same units as the occurrence points (e.g, decimal degrees) |
nreps |
Number of replicates to perform |
nback |
Number of background points for models |
bg.source |
Source for drawing background points. If "points", it just uses the background points that are already in the species object. If "range", it uses the range raster. If "env", it draws points at randome from the entire study area outlined by the first environmental layer. |
low.memory |
When set to TRUE, replicate models are written to disc instead of being stored in the output object. Replicate models stored in the output object contain paths to the replicate models on disk instead of the rasters themselves. |
rep.dir |
Directory for storing replicate models when low.memory is set to TRUE. If not specified, the working directory will be used. |
verbose |
Controls printing of various messages progress reports. Defaults to FALSE. |
clamp |
Controls whether empirical and replicate models should be clamped to the environment space used for training. |
... |
Additional arguments to be passed to model fitting functions. |
results A list containing models for the replicates, models for the empirical data, and summary statistics and plots.
cyreni <- iberolacerta.clade$species$cyreni aranica <- iberolacerta.clade$species$aranica # We're just going to fudge together occurrence data from a ribbon here # from random points between the two species' ranges p <- data.frame(x = runif(50, -4, -2), y = runif(50, 40, 43)) p <- terra::vect(p, geom = c("x", "y"), crs = terra::crs(cyreni$presence.points)) bg <- background.buffer(p, 100000, mask = euro.worldclim[[1]], n = 100, return.type = "points") ribbon <- enmtools.species(species.name = "ribbon", presence.points = p, background.points = bg) rangebreak.ribbon(cyreni, aranica, ribbon = ribbon, env = euro.worldclim, type = "glm", f= pres ~ bio1 + bio12, nreps = 10)
cyreni <- iberolacerta.clade$species$cyreni aranica <- iberolacerta.clade$species$aranica # We're just going to fudge together occurrence data from a ribbon here # from random points between the two species' ranges p <- data.frame(x = runif(50, -4, -2), y = runif(50, 40, 43)) p <- terra::vect(p, geom = c("x", "y"), crs = terra::crs(cyreni$presence.points)) bg <- background.buffer(p, 100000, mask = euro.worldclim[[1]], n = 100, return.type = "points") ribbon <- enmtools.species(species.name = "ribbon", presence.points = p, background.points = bg) rangebreak.ribbon(cyreni, aranica, ribbon = ribbon, env = euro.worldclim, type = "glm", f= pres ~ bio1 + bio12, nreps = 10)
This function measures the spatial heterogeneity of the distribution of suitability scores from an ENM. It returns Levins' (1968) two metrics of niche breadth.
raster.breadth(x, verbose = FALSE)
raster.breadth(x, verbose = FALSE)
x |
An object of class raster or RasterLayer, or an ENMTools model object containing a suitability raster. |
verbose |
Controls printing of diagnostic messages |
Levins, R. 1968. Evolution in changing environments: some theoretical explorations. Princeton University Press.
results A vector containing the two metrics B1 and B2 for niche breadth.
aurelioi.glm <- enmtools.glm(iberolacerta.clade$species$aurelioi, euro.worldclim, f = pres ~ bio1 + bio12) raster.breadth(aurelioi.glm)
aurelioi.glm <- enmtools.glm(iberolacerta.clade$species$aurelioi, euro.worldclim, f = pres ~ bio1 + bio12) raster.breadth(aurelioi.glm)
Calculates the correlation coefficient between two rasters.
raster.cor(x, y, method = "spearman")
raster.cor(x, y, method = "spearman")
x |
Either a raster or an ENMTools model object with a suitability raster. |
y |
Either a raster or an ENMTools model object with a suitability raster. |
method |
The method to be used for calculating correlations. Defaults to spearman, but can take "kendall" or "pearson" as well. |
A numeric correlation coefficient.
data(euro.worldclim) raster.cor(euro.worldclim[[1]], euro.worldclim[[2]])
data(euro.worldclim) raster.cor(euro.worldclim[[1]], euro.worldclim[[2]])
Takes a raster stack and returns a data frame containing Pearson correlation coefficients between the included rasters
raster.cor.matrix(env, method = "pearson")
raster.cor.matrix(env, method = "pearson")
env |
A SpatRaster object containing two or more rasters |
method |
Type of correlation to measure. Can do "pearson", "kendall", or "spearman" |
A data frame of correlation coefficients for a set of rasters.
data(euro.worldclim) raster.cor.matrix(euro.worldclim)
data(euro.worldclim) raster.cor.matrix(euro.worldclim)
Takes a raster stack and returns a data frame containing Pearson correlation coefficients between the included rasters
raster.cor.plot(env, method = "pearson")
raster.cor.plot(env, method = "pearson")
env |
A SpatRaster object containing two or more rasters |
method |
Type of correlation to measure. Can do "pearson", "kendall", or "spearman" |
A list of two plots. The first maps the correlations between rasters into an MDS space, so that predictors that fall close together in that space are more correlated. The second plot is a heatmap depicting the correlations between pairs of layers.
data(euro.worldclim) raster.cor.plot(euro.worldclim)
data(euro.worldclim) raster.cor.plot(euro.worldclim)
This function measures similarity in the geographic distribution of suitability scores from two ENMs. It returns two metrics, I and D. These metrics are described in Warren et al. 2008.
raster.overlap(x, y, verbose = FALSE)
raster.overlap(x, y, verbose = FALSE)
x |
A raster or RasterLayer object, or ENMTools model object containing a suitability raster. |
y |
Another raster or RasterLayer object, or ENMTools model object containing a suitability raster. |
verbose |
Controls printing of diagnostic messages |
results A vector containing the three metrics (I, D, and Spearman rank correlation)
aurelioi.glm <- enmtools.glm(iberolacerta.clade$species$aurelioi, euro.worldclim, f = pres ~ bio1 + bio12) aranica.glm <- enmtools.glm(iberolacerta.clade$species$aranica, euro.worldclim, f = pres ~ bio1 + bio12) raster.overlap(aurelioi.glm, aranica.glm)
aurelioi.glm <- enmtools.glm(iberolacerta.clade$species$aurelioi, euro.worldclim, f = pres ~ bio1 + bio12) aranica.glm <- enmtools.glm(iberolacerta.clade$species$aranica, euro.worldclim, f = pres ~ bio1 + bio12) raster.overlap(aurelioi.glm, aranica.glm)
raster.pca, PCA on a set of environmental rasters
raster.pca(env, n)
raster.pca(env, n)
env |
A set of environmental layers |
n |
The number of PCA layers to return |
A list containing a stack of rasters representing the top n pca axes of the initial environmental variables, as well as the pca object from the analysis that produced them.
env.pca <- raster.pca(euro.worldclim, 2)
env.pca <- raster.pca(euro.worldclim, 2)
This function builds a linear model for the relationship between two rasters, and returns the linear model and a spatial raster of the residuals from that model.
raster.resid(x, y)
raster.resid(x, y)
x |
A raster or RasterLayer object, or ENMTools model object containing a suitability raster. |
y |
Another raster or RasterLayer object, or ENMTools model object containing a suitability raster. |
results A list containing a raster of residuals from a linear regression between the two supplied rasters and the linear model itself.
data(euro.worldclim) raster.resid(euro.worldclim[[1]], euro.worldclim[[2]])
data(euro.worldclim) raster.resid(euro.worldclim[[1]], euro.worldclim[[2]])
This function is used by a lot of the metrics calculated by ENMTools, in order to standardize suitability scores so they sum to 1 over a geographic space.
raster.standardize(x, verbose = FALSE)
raster.standardize(x, verbose = FALSE)
x |
A raster or RasterLayer object, or an ENMTools model object containing a suitability raster. |
verbose |
Controls printing of diagnostic messages |
A new raster object, standardized so that values sum to 1
raster.standardize(euro.worldclim[[1]])
raster.standardize(euro.worldclim[[1]])
get terra to produce same output as raster::rasterToPoints
rasterToPoints2(rast)
rasterToPoints2(rast)
rast |
A raster to convert to points |
Function that takes an enmtools.model
object and simulates points
from it using a point process.
sim.points( object, n.points = 1000, seed = NA, sample.type = "ppp", replace = FALSE, threshold = NA, ... )
sim.points( object, n.points = 1000, seed = NA, sample.type = "ppp", replace = FALSE, threshold = NA, ... )
object |
entools.model object to simulate from |
n.points |
approximate number of points to simulate. You may get small number fewer or greater. If you need an exact number of points, generate too many, then drop the extra ones. |
seed |
optional seed for the random number generator |
sample.type |
method for sampling occurrence points. Default is "ppp", which is a poisson point process. Also accepts "binomial" for treating suitabilities as binomial trials, "thresh.pa" for sampling with equal probability every grid cell above a certain threshold value, and "thresh.con" for sampling in proportion to suitability above a certain threshold value. |
replace |
whether to sample with replacement. |
threshold |
a threshold suitability below which probability of sampling drops to zero. Used for "thresh.pa" and "thresh.con" sampling. |
... |
additional parameters, not currently used but included for S3 compatability |
A data frame of simulated points from the enmtools.model object
Takes a csv file and uses it to construct one or more enmtools.species objects. It constructs one object per unique value in the "species.col" column.
species.from.file(filename, species.col = "species")
species.from.file(filename, species.col = "species")
filename |
Name of a .csv file |
species.col |
Name of the column from the csv file to use for species names. Default is "species". |
A list containing species objects, one for each unique value in species.col.
threespace.plot, A plot that compares the environmental distribution of presence points, background points, and the set of supplied environmental layers.
threespace.plot(model, env, maxpts = NA)
threespace.plot(model, env, maxpts = NA)
model |
An enmtools.model object |
env |
A set of environment layers |
maxpts |
Maximum number of points to plot from env layers |
A ggplot2 object that plots the distribution of environments in the climate layers to the distribution of environments at background and presence localities.
my.model<- enmtools.gam(iberolacerta.clade$species$monticola, euro.worldclim) threespace.plot(my.model, euro.worldclim)
my.model<- enmtools.gam(iberolacerta.clade$species$monticola, euro.worldclim) threespace.plot(my.model, euro.worldclim)
Takes a set of points and a raster mask and returns a data frame trimmed so that only one point is returned per grid cell in the mask raster.
trimdupes.by.raster(points, mask)
trimdupes.by.raster(points, mask)
points |
A two column data frame with X and Y coordinates |
mask |
A raster to use as a mask for drawing points |
A new data frame with one point per grid cell.
pts <- iberolacerta.clade$species$monticola$presence.points trimdupes.by.raster(pts, euro.worldclim)
pts <- iberolacerta.clade$species$monticola$presence.points trimdupes.by.raster(pts, euro.worldclim)
export
unwrap_list(l)
unwrap_list(l)
l |
A list containing species objects that need to be converted |
visualize.enm, Makes a heatmap of suitability of habitat in environment space according to a given model
visualize.enm( model, env, nbins = 100, layers = colnames(model$analysis.df)[1:2], plot.test.data = FALSE, plot.points = TRUE, minmax = "env" )
visualize.enm( model, env, nbins = 100, layers = colnames(model$analysis.df)[1:2], plot.test.data = FALSE, plot.points = TRUE, minmax = "env" )
model |
An enmtools.model object |
env |
A set of environmental layers |
nbins |
The number of bins per layer to use for drawing environment space |
layers |
A vector of layer names to use for drawing environment space |
plot.test.data |
Logical determining whether test data should be plotted, if present. If test data is plotted, it will appear as translucent green triangles. |
plot.points |
Logical determining whether presence points should be plotted on suitability plot |
minmax |
Either "env", to set the minima and maxima using the environment layers, "points" to set the minima and maxima using the presence and background data, or a named list of minima and maxima for each layer. |
suit.plot A list containing two dimensional plot of an ENM in environment space and a plot of the available environments.
aurelioi.glm <- enmtools.glm(iberolacerta.clade$species$aurelioi, euro.worldclim, f = pres ~ poly(bio1, 4) + poly(bio12, 4)) visualize.enm(aurelioi.glm, euro.worldclim, layers = c("bio1", "bio12"))
aurelioi.glm <- enmtools.glm(iberolacerta.clade$species$aurelioi, euro.worldclim, f = pres ~ poly(bio1, 4) + poly(bio12, 4)) visualize.enm(aurelioi.glm, euro.worldclim, layers = c("bio1", "bio12"))
visualize.overlap, Makes a contour map of suitability of habitat in environment space for two models
visualize.overlap( model.1, model.2, env, nbins = 100, layers, plot.points = TRUE )
visualize.overlap( model.1, model.2, env, nbins = 100, layers, plot.points = TRUE )
model.1 |
An enmtools.model object |
model.2 |
An enmtools.model object |
env |
A set of environmental layers |
nbins |
The number of bins per layer to use for drawing environment space |
layers |
A vector of layer names to use for drawing environment space |
plot.points |
Logical determining whether presence points should be plotted on suitability plot |
overlap.plot A two dimensional plot of an ENM
ar <- iberolacerta.clade$species$aranica au <- iberolacerta.clade$species$aurelioi aranica.dm <- enmtools.dm(ar, euro.worldclim) aurelioi.dm <- enmtools.dm(au, euro.worldclim) visualize.overlap(aranica.dm, aurelioi.dm, euro.worldclim, layers = c("bio1", "bio9"))
ar <- iberolacerta.clade$species$aranica au <- iberolacerta.clade$species$aurelioi aranica.dm <- enmtools.dm(ar, euro.worldclim) aurelioi.dm <- enmtools.dm(au, euro.worldclim) visualize.overlap(aranica.dm, aurelioi.dm, euro.worldclim, layers = c("bio1", "bio9"))
export
wrap_list(l)
wrap_list(l)
l |
A list containing species objects that need to be converted |