Giter VIP home page Giter VIP logo

enmsdm's Introduction

enmSdm

Tools for modeling niches and distributions of species

Please note: enmSdm has been replaced by enmSdmX (available on CRAN).

I am no longer actively developing enmSdm because it relies heavily on the soon-to-be-defunct sp and (maybe) raster packages, which in turn rely on the soon-to-be-defunct PROJ4 geodetic/coordinate reference system libraries. Its replacement, enmSdmX works with the new terra and sf packages, and--most importantly--PROJ6!

This package is a complement to the popular dismo package for R by Robert Hijmans. Its contains a suite of efficiency functions for preparing data, training and evaluating species distribution models and ecological niche models, and comparing ecological niches.

You can install this package in R using these commands:

remotes::install_github('adamlilith/enmSdm', dependencies=TRUE)

Note: If for some reason these commands don't work, you can install the package(s) by downloading the latest zip/tar file from the zipTarFiles directory and installing the package(s) manually. If you do this, you will also have to install the legendary package, which is on GitHub under my account (adamlilith), as well as the omnibus and statisfactory packages on CRAN.

Data preparation

  • elimCellDups: Eliminate duplicate points in each cell of a raster
  • geoFold: Generate geographically distinct k-folds
  • geoThin and geoThinApprox: Geographically thin points

Model training

  • trainByCrossValid: Wrapper for implementing some trainXYZ function across cross-validation folds (see also summaryByCrossValid).
  • trainBrt: Boosted regression trees (BRTs)
  • trainCrf: Conditional regression trees (CRFs)
  • trainGam: Generalized additive models (GAMs)
  • trainGlm: Generalized linear models (GLMs)
  • trainGlmDredge: Generalized linear models (GLMs)
  • trainMaxEnt and trainMaxNet: Maxent models
  • trainNs: Natural splines (NSs)
  • trainRf: Random forests (RFs)

Model prediction

  • predictEnmSdm Predict most model types using default settings
  • predictMaxNet Predict MaxNet (MaxEnt) model

Model evaluation

  • aucWeighted: AUC (with/out site weights)
  • aucMultiWeighted: Multivariate version of AUC (with/out site weight)
  • contBoyce: Continuous Boyce Index (with/out site weights)
  • contBoyce2x: "2X coverage" version of the Continuous Boyce Index (with/out site weights)
  • fpb: Fpb measure of model discrimination capacity (with/out site weights)
  • thresholdWeighted: Thresholds to convert continuous predictions to binary predictions (with/out site weights)
  • thresholdStats: Model performance statistics based on thresholded predictions (with/out site weights)
  • tjursR2Weighted: Tjur's R2 (with/out site weights)
  • tssWeighted: True Skill Statistic (TSS) (with/out site weights)
  • modelSize: Number of response values in a model object

Niche overlap

  • compareNiches: Niche overlap metrics
  • compareResponse: Compare niche model responses to a single variable
  • mop: Calculate mobility-oriented parity, a measure of multivariate distance as per Saupe et al. 2012.
  • nicheOverlap: Calculate niche overlap as per Broennimann et al. Global Ecology and Biogeography 21:481-497
  • randPointsRespectingSelf: Randomize geographic points while approximately respecting observed spatial autocorrelation structure between points
  • randPointsRespectingSelfOther2: Randomize two sets of geographic points while approximately respecting observed spatial autocorrelation structure between and within sets
  • randPointsBatch: Call randPointsRespectingSelf or randPointsRespectingSelfOther2 multiple times
  • randPointsBatchExtract: Extract environment from a set of rasters for sets of randomized points generated using randPointsBatch
  • randPointsBatchSampled: Collate all sets of randomized points generated using randPointsBatch
  • randPointsBatchNicheOverlap: Calculate niche overlap between sets of randomized points that were generated using randPointsBatch

Spatial autocorrelation

  • spatialCorrForPoints: Calculate pairwise distance-based measure of global spatial autocorrelation between geographic points
  • spatialCorrForPointsSummary: Characteristic cluster size of spatial points (distance of global autocorrelation)
  • spatialCorrForPointsPlot: Plot observed and null distributions of pairwise distance-based measure of global spatial autocorrelation
  • spatialCorrForPointsWeight: Assign weights to points based on pairwise distance-based measure of global spatial autocorrelation

Functions for rasters

  • bioticVelocity: Velocity of movement across a series of rasters
  • getCores: Get number of processor cores
  • extractLarge: Like extract(), but for large-memory spatial objects
  • interpolateRasters: Interpolate a stack of rasters
  • longLatRasters: Generate rasters with values of longitude/latitude for cell values
  • rastWithSquareCells: Create a raster with square cells from an object with an extent
  • sampleRast and sampleRastStrat: Sample raster with/out replacement and possibly in a stratified manner
  • squareRastCells: Resample a raster so cells are square

Range area based on minimum convex polygons

  • mcpFromPolys: Minimum convex polygon from a set of polygons and points

Geographic utility functions

  • convertTropicosCoords: Convert coordinates from the TROPICOS database
  • coordPrecision: Calculate maximum possible coordinate precision
  • createPlotPoly: Create a SpatialPolygon the same size as a plot region
  • decimalToDms: Convert decimal coordinate to degrees-minutes-seconds
  • dmsToDecimal: Convert degrees-minutes-seconds coordinate to decimal
  • getCRS: Return a proj4string (coordinate reference system string) using a nickname
  • getEPSG: Return a EPSG code (coordinate reference system codeg) using a nickname
  • pointDist: Geographic distance between set(s) of points
  • svToSpatial: Convert SpatVector object to a Spatial* object
  • xToCoords: Extract geographic coordinates from a data frame, matrix, or SpatialPoints* object

Data

  • lemurs: Lemur occurrences
  • mad0: Madagascar spatial object

Citation

As of October 2020 there is no package-specific publication for enmSdm, but the package was first used and cited in:

Morelli*, T.L., Smith*, A.B., Mancini, A.N., Balko, E. A., Borgenson, C., Dolch, R., Farris, Z., Federman, S., Golden, C.D., Holmes, S., Irwin, M., Jacobs, R.L., Johnson, S., King, T., Lehman, S., Louis, E.E. Jr., Murphy, A., Randriahaingo, H.N.T., Lucien, Randriannarimanana, H.L.L., Ratsimbazafy, J., Razafindratsima, O.H., and Baden, A.L. 2020. The fate of Madagascar’s rainforest habitat. Nature Climate Change 10:89-96. * Equal contribution https://doi.org/10.1038/s41558-019-0647-x

Abstract. Madagascar has experienced extensive deforestation and overharvesting, and anthropogenic climate change will compound these pressures. Anticipating these threats to endangered species and their ecosystems requires considering both climate change and habitat loss effects. The genus Varecia (ruffed lemurs), which is composed of two Critically Endangered forest-obligate species, can serve as a status indicator of the biodiverse eastern rainforest of Madagascar. Here, we combined decades of research to show that the suitable habitat for ruffed lemurs could be reduced by 29–59% from deforestation, 14–75% from climate change (representative concentration pathway 8.5) or 38–93% from both by 2070. If current protected areas avoid further deforestation, climate change will still reduce the suitable habitat by 62% (range: 38–83%). If ongoing deforestation continues, the suitable habitat will decline by 81% (range: 66–93%). Maintaining and enhancing the integrity of protected areas, where rates of forest loss are lower, will be essential for ensuring persistence of the diversity of the rapidly diminishing Malagasy rainforests.

enmsdm's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enmsdm's Issues

enmSdm::trainMaxNet

Hi,
I'm using the package to tune maxnet:maxent as part of an analysis of 236 pan-eurpean tree species.
It's working really well, and it saved me considerable time writing a similar (but probably less efficient) code myself. Thanks for that!

Only a small and minor issue to report:
the 'Out' argument in the enmSdm::trainMaxNet function does not accept 'tuning' as a meaningful value. In the code, to return the table, 'Out' should be set to 'table'. It would be nice to change this in the help file.
Best regards,
Yoni Gavish,
School of Geography, University of Leeds.

contBoyce produces convex P/E curve

I am sure I must be doing something wrong here, but my Maxent model produces a convex instead of a concave P/E curve, see image.
I realise it is hard to say something without code, but does this look familiar?

Rplot

"object '.doSnowGlobals' not found" error

This is largely a resolved issue, but I'm posting it here because it occasionally sometimes crops up when using functions that can do multicoring, like trainMaxEnt and bioticVelocity. When you try using >1 core, sometimes on some machines you can get the error

object '.doSnowGlobals' not found

I have, for example, received this error on a machine that uses the exact same set of libraries as another, and yet it worked on the second. This StackExchange post explains the issue, or so it seems, but in my case none of the fixes fixed it, and if you're not interested in looking inside the function, it wouldn't help anyway.

What has worked for me:

  • An aggressive virus checker can disable access to cores. This was probably my issue, but I don't have admin access to change the antivirus settings.
  • However, uninstalling R, then reinstalling (even the same version) seemed to work.

Yes, it was that "simple", and it may not work for you, but it's a solution which I did not find documented on numerous help boards.

Best,
Adam

Malformed DESCRIPTION file

Hello,

Thanks for this great package. The line "=======" raises an error during installation of the package. Removing the line solves the problem.

pointDist - Error in p[, 2] : subscript out of bounds

Hi,
First at all, thanks for this amazing tool!

I'm using the pointDist function to calculate distances between points. My command is like that:
pointDist(i_subset, distFunct = distVincentyEllipsoid, longLat = c('longitude', 'latitude'))
i_subset is a df with columns for points ID, some points attributes and separate columns for long and lat. When I run it I receive the following error: Error in p[, 2] : subscript out of bounds

I believe it might be an issue that emerged with some package update because some months ago I was able to calculate distances with this line of code.

Any thoughts?

Thanks!

trainByCrossValid fails for maxnet hinge feature classes

Hi,

I am trying to run trainByCrossValid for maxnet training. When hinge features are included in the classes, the function fails saying that it could not find the function 'hingeval'. The function works as long as hinge features are not included or if I manually load the 'hingeval' function from the maxnet package into the environment.

mx = trainByCrossValid(data = pts, resp = 'presab', preds = 3:7, folds = pts$block, trainFx = 'trainMaxNet', regMult = seq(0.5,8,0.5), classes = 'lpqh', out = 'tuning')
Modeling k = 1 on Mon Apr 25 09:51:25 2022... Error in hingeval(hmean, 78.3085768563407, 91.973876953125) : could not find function "hingeval"

Thanks,
Lydia

InternetOpenUrl error

Hello, R found error that cannot download data from ucdavis website.

worldClim <- getData('worldclim', var='bio', res=5)
试开URL’https://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/bio_5m_bil.zip'
Error in utils::download.file(url = aurl, destfile = fn, method = "auto", :
无法打开URL'https://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/bio_5m_bil.zip'
此外: Warning message:
In utils::download.file(url = aurl, destfile = fn, method = "auto", :
InternetOpenUrl失败:’不能连接到吊销服务器,或者未能获得最终响应。'

Example for spatialCorrForPoints has an error?

I have copied/pasted the example for spatialCorrForPoints.
There is an error at sacDist <- spatialCorrForPointsSummary(obsAndNullDistrib), the previously created object obsAndNullDistrib has a lot of NaN values.

Error message:

 Obtaining: Observed distances | random points | randomized distances
  |================================================================| 100%
Error in quantile.default(newX[, i], ...) : 
  missing values and NaN's not allowed if 'na.rm' is FALSE

sessionInfo:

R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=nl_NL.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=nl_NL.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] raster_3.0-12  sp_1.3-2       enmSdm_0.3.9.2

loaded via a namespace (and not attached):
 [1] omnibus_0.3.3.0     compiler_3.6.2      rgdal_1.4-8         tools_3.6.2         geosphere_1.5-10    Rcpp_1.0.3          codetools_0.2-16   
 [8] grid_3.6.2          dismo_1.1-4         statisfactory_0.3.0 lattice_0.20-38 

geofold renamed to pointGoeFold, but namespace not updated

I was trying to install holoSimCell which depends on enmSdm and I'm getting an error:
Error: package or namespace load failed for ‘enmSdm’ in namespaceExport(ns, exports):
undefined exports: geoFold

After looking at the code, I'm pretty sure that all that needs to happen is to run devtools::document() to update the NAMESPACE file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.