Skip to content

Commit 8d0b2b4

Browse files
committed
Prepare for CRAN v1.0.0 release
* Fixed bug in `lrren()` to properly extract predicted RR values for cross validation when using `terra::extract()` * Fixed NOTE in CRAN checks to provide package anchors for Rd \link{} targets not in the package itself and the base packages within 'envi-package.Rd', 'lrren.Rd', and 'perlrren.Rd' * Fixed NOTE in Windows check to remove detritus files after testing * Renamed 'package.R' to 'envi-package.R' after Roxygen (7.3.0) update * Updated CITATION with [peer-review publication](https://doi.org/10.1016/j.sste.2024.100696)
1 parent d8462e3 commit 8d0b2b4

18 files changed

+203
-148
lines changed

DESCRIPTION

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: envi
22
Type: Package
33
Title: Environmental Interpolation using Spatial Kernel Density Estimation
4-
Version: 0.1.19
5-
Date: 2024-01-23
4+
Version: 1.0.0
5+
Date: 2024-11-06
66
Authors@R:
77
c(person(given = "Ian D.",
88
family = "Buller",
@@ -28,7 +28,7 @@ Description: Estimates an ecological niche using occurrence data, covariates, an
2828
License: Apache License (>= 2.0)
2929
Encoding: UTF-8
3030
Roxygen: list(markdown = TRUE)
31-
RoxygenNote: 7.2.3
31+
RoxygenNote: 7.3.2
3232
Depends:
3333
R (>= 3.5.0)
3434
Imports:

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ accepting any such warranty or additional liability.
169169

170170
_END OF TERMS AND CONDITIONS_
171171

172-
Copyright 2020 Ian D. Buller; Emory University
172+
Copyright 2024 Ian D. Buller; Emory University
173173

174174
Licensed under the Apache License, Version 2.0 (the "License");
175175
you may not use this file except in compliance with the License.

NEWS.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# envi (development version)
22

3+
## envi v1.0.0
4+
* Fixed bug in `lrren()` to properly extract predicted RR values for cross validation after update using `terra::extract()`
5+
* Fixed NOTE in CRAN checks to provide package anchors for Rd \link{} targets not in the package itself and the base packages within 'envi-package.Rd', 'lrren.Rd', and 'perlrren.Rd'
6+
* Fixed NOTE in Windows check to remove detritus files after testing
7+
* Renamed 'package.R' to 'envi-package.R' after Roxygen (>=7.3.0) update
8+
* Updated CITATION with [peer-review publication](https://doi.org/10.1016/j.sste.2024.100696)
9+
310
## envi v0.1.19
411
* Fixed 'Moved Permanently' content by replacing the old URL with the new URL
512

R/package.R R/envi-package.R

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' Estimates an ecological niche model using occurrence data, covariates, and kernel density-based estimation methods.
44
#'
5-
#' @details For a single species with presence and absence data, the 'envi' package uses the spatial relative risk function estimated using the \code{\link{sparr}} package. Details about the \code{\link{sparr}} package methods can be found in the tutorial: Davies et al. (2018) \doi{10.1002/sim.7577}. Details about kernel density estimation can be found in J. F. Bithell (1990) \doi{10.1002/sim.4780090616}. More information about relative risk functions using kernel density estimation (KDE) can be found in J. F. Bithell (1991) \doi{10.1002/sim.4780101112}.
5+
#' @details For a single species with presence and absence data, the 'envi' package uses the spatial relative risk function estimated using the \code{\link[sparr]{sparr}} package. Details about the \code{\link[sparr]{sparr}} package methods can be found in the tutorial: Davies et al. (2018) \doi{10.1002/sim.7577}. Details about kernel density estimation can be found in J. F. Bithell (1990) \doi{10.1002/sim.4780090616}. More information about relative risk functions using kernel density estimation (KDE) can be found in J. F. Bithell (1991) \doi{10.1002/sim.4780101112}.
66
#'
77
#' This package provides a function to estimate the ecological niche for a single species with presence and absence data. The 'envi' package also provides some sensitivity and visualization tools for the estimated ecological niche, its predicted spatial distribution, and prediction diagnostics. Various options for the correction of multiple testing are available.
88
#'
@@ -28,16 +28,15 @@
2828
#'
2929
#' @name envi-package
3030
#' @aliases envi-package envi
31-
#' @docType package
3231
#'
33-
#' @section Dependencies: The 'envi' package relies heavily upon \code{\link{sparr}}, \code{\link{spatstat.geom}}, \code{\link{sf}}, and \code{\link{terra}}. For a single species (presence/absence data), the spatial relative risk function uses the \code{\link[sparr]{risk}} function. Cross-validation is can be performed in parallel using the \code{\link{future}}, \code{\link{doFuture}}, \code{\link{doRNG}}, and \code{\link{foreach}} packages. Spatial perturbation is performed using the \code{\link[spatstat.geom]{rjitter}} function. Basic visualizations rely on the \code{\link[spatstat.geom]{plot.ppp}} and \code{\link[fields]{image.plot}} functions.
32+
#' @section Dependencies: The 'envi' package relies heavily upon \code{\link[sparr]{sparr}}, \code{\link[spatstat.geom]{spatstat.geom}}, \code{\link[sf]{sf}}, and \code{\link[terra]{terra}}. For a single species (presence/absence data), the spatial relative risk function uses the \code{\link[sparr]{risk}} function. Cross-validation is can be performed in parallel using the \code{\link[future]{future}}, \code{\link[doFuture]{doFuture}}, \code{\link[doRNG]{doRNG}}, and \code{\link[foreach]{foreach}} packages. Spatial perturbation is performed using the \code{\link[spatstat.geom]{rjitter}} function. Basic visualizations rely on the \code{\link[spatstat.geom]{plot.ppp}} and \code{\link[fields]{image.plot}} functions.
3433
#'
35-
#' @author Ian D. Buller\cr \emph{Social & Scientific Systems, Inc., a division of DLH Corporation, Silver Spring, Maryland, USA (current); Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland, USA (former); Environmental Health Sciences, James T. Laney School of Graduate Studies, Emory University, Atlanta, Georgia, USA (original)}\cr
34+
#' @author Ian D. Buller\cr \emph{DLH, LLC (formerly known as Social & Scientific Systems, Inc.) Bethesda, Maryland, USA (current); Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland, USA (former); Environmental Health Sciences, James T. Laney School of Graduate Studies, Emory University, Atlanta, Georgia, USA (original)}\cr
3635
#'
3736
#' Maintainer: I.D.B. \email{ian.buller@@alumni.emory.edu}
3837
#'
3938
#' @keywords package
40-
NULL
39+
"_PACKAGE"
4140

4241
#' @importFrom concaveman concaveman
4342
#' @importFrom cvAUC ci.cvAUC cvAUC

R/globals.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
globalVariables("k")
2-
globalVariables("kk")
2+
globalVariables("kk")

R/lrren.R

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#'
2525
#' If \code{predict = TRUE}, this function will predict ecological niche at every location specified with \code{predict_locs} with best performance if \code{predict_locs} are gridded locations in the same study area as the observations in \code{obs_locs} - a version of environmental interpolation. The predicted spatial distribution of the estimated ecological niche can be visualized using the \code{\link{plot_predict}} function.
2626
#'
27-
#' If \code{cv = TRUE}, this function will prepare k-fold cross-validation data sets for prediction diagnostics. The sample size of each fold depends on the number of folds set with \code{kfold}. If \code{balance = TRUE}, the sample size of each fold will be the frequency of presence locations divided by the number of folds times two. If \code{balance = FALSE}, the sample size of each fold will be the frequency of all observed locations divided by the number of folds. The cross-validation can be performed in parallel if \code{parallel = TRUE} using the \code{\link{future}}, \code{\link{doFuture}}, \code{\link{doRNG}}, and \code{\link{foreach}} packages. Two diagnostics (area under the receiver operating characteristic curve and precision-recall curve) can be visualized using the \code{plot_cv} function.
27+
#' If \code{cv = TRUE}, this function will prepare k-fold cross-validation data sets for prediction diagnostics. The sample size of each fold depends on the number of folds set with \code{kfold}. If \code{balance = TRUE}, the sample size of each fold will be the frequency of presence locations divided by the number of folds times two. If \code{balance = FALSE}, the sample size of each fold will be the frequency of all observed locations divided by the number of folds. The cross-validation can be performed in parallel if \code{parallel = TRUE} using the \code{\link[future]{future}}, \code{\link[doFuture]{doFuture}}, \code{\link[doRNG]{doRNG}}, and \code{\link[foreach]{foreach}} packages. Two diagnostics (area under the receiver operating characteristic curve and precision-recall curve) can be visualized using the \code{plot_cv} function.
2828
#'
2929
#' The \code{obs_window} argument may be useful to specify a 'known' window for the ecological niche (e.g., a convex hull around observed locations).
3030
#'
@@ -324,8 +324,7 @@ lrren <- function(obs_locs,
324324
rand_lrr <- sparr::risk(f = ppp_presence_training,
325325
g = ppp_absence_training,
326326
tolerate = TRUE,
327-
verbose = FALSE,
328-
...)
327+
verbose = FALSE)
329328

330329
##### Convert to semi-continuous SpatRaster
331330
rr_raster <- terra::rast(rand_lrr$rr)
@@ -336,11 +335,11 @@ lrren <- function(obs_locs,
336335

337336
##### Output for each k-fold
338337
###### Record category (semi-continuous) of testing data
339-
cv_predictions_rr <- terra::extract(rr_raster, extract_testing)[ , 2]
338+
cv_predictions_rr <- terra::extract(rr_raster, as.matrix(extract_testing))[, 1]
340339
cv_labels <- testing[ , 4] # Record labels (marks) of testing data
341340

342341
par_results <- list("cv_predictions_rr" = cv_predictions_rr,
343-
"cv_labels"= cv_labels)
342+
"cv_labels" = cv_labels)
344343
return(par_results)
345344
}
346345

R/perlrren.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#'
1818
#' @details This function performs a sensitivity analysis of an ecological niche model of a single species (presence/absence data), or the presence of one species relative to another, that uses two covariates. The observation locations (presence and absence data) are randomly spatially perturbed (i.e., "jittered") uniformly within a circular disc of a specified radius centered at their recorded location using the \code{\link[spatstat.geom]{rjitter}} function. This method simulates the spatial uncertainty of observations, how that may affect the covariate values at each observation (i.e., misclassification error), and the estimated ecological niche based on the two specified covariates. Observations can be grouped into categories of the uncertainty of class 'factor' and can vary by degrees of uncertainty specified using the \code{radii} argument.
1919
#'
20-
#' The function iteratively estimates the ecological niche using the \code{\link{lrren}} function and computes four summary statistics at every grid cell (i.e., knot) of the estimated surface: 1) mean of the log relative risk, 2) standard deviation of the log relative risk, 3) mean of the asymptotically normal p-value, and 4) proportion of iterations were statistically significant based on a two-tailed alpha-level threshold (argument \code{alpha}). The process can be performed in parallel if \code{parallel = TRUE} using the \code{\link{future}}, \code{\link{doFuture}}, \code{\link{doRNG}}, and \code{\link{foreach}} packages. The computed surfaces can be visualized using the \code{\link{plot_perturb}} function. If \code{predict = TRUE}, this function will predict the four summary statistics at every location specified with \code{predict_locs} and can also be visualized using the \code{\link{plot_perturb}} function.
20+
#' The function iteratively estimates the ecological niche using the \code{\link{lrren}} function and computes four summary statistics at every grid cell (i.e., knot) of the estimated surface: 1) mean of the log relative risk, 2) standard deviation of the log relative risk, 3) mean of the asymptotically normal p-value, and 4) proportion of iterations were statistically significant based on a two-tailed alpha-level threshold (argument \code{alpha}). The process can be performed in parallel if \code{parallel = TRUE} using the \code{\link[future]{future}}, \code{\link[doFuture]{doFuture}}, \code{\link[doRNG]{doRNG}}, and \code{\link[foreach]{foreach}} packages. The computed surfaces can be visualized using the \code{\link{plot_perturb}} function. If \code{predict = TRUE}, this function will predict the four summary statistics at every location specified with \code{predict_locs} and can also be visualized using the \code{\link{plot_perturb}} function.
2121
#'
2222
#' For more information about the spatial perturbation, please refer to the \code{\link[spatstat.geom]{rjitter}} function documentation.
2323
#'

R/utils.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ progBar <- function(kk, N, per = 1) {
3535

3636
# Temporary stopgap for converting 'SpatRaster' to 'im'
3737
## Modification of `as.im.RasterLayer` from `maptools` because `maptools` is retiring in 2023
38-
as.im.SpatRaster <- function (from, factor.col.name = NULL) {
38+
as.im.SpatRaster <- function(from, factor.col.name = NULL) {
3939
if (!requireNamespace("spatstat.geom", quietly = TRUE)) {
4040
stop(paste("package spatstat.geom required; please install it (or the full spatstat package) first"))
4141
}

0 commit comments

Comments
 (0)