Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2.1.3] on cran #436

Merged
merged 15 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wallace
Version: 2.1.2
Date: 2024-03-08
Version: 2.1.3
Date: 2024-07-18
Title: A Modular Platform for Reproducible Modeling of Species Niches
and Distributions
Description: The 'shiny' application Wallace is a modular platform for
Expand All @@ -12,24 +12,24 @@ Description: The 'shiny' application Wallace is a modular platform for
most package functionality can be found on the package's GitHub Pages
website: <https://wallaceecomod.github.io/wallace/articles/tutorial-v2.html>.
Authors@R:
c(person("Jamie M.", "Kass", email = "[email protected]", role = "aut"),
c(person("Bethany A.", "Johnson", email = "[email protected]", role = "aut"),
person("Jamie M.", "Kass", email = "[email protected]", role = "aut"),
person("Gonzalo E.", "Pinilla-Buitrago", email = "[email protected]", role = "aut"),
person("Andrea", "Paz", email = "[email protected]", role = "aut"),
person("Bethany A.", "Johnson", email = "[email protected]", role = "aut"),
person("Valentina", "Grisales-Betancur", email = "[email protected]", role = "aut"),
person("Dean", "Attali", email = "[email protected]", role = "aut"),
person("Matthew E.", "Aiello-Lammens", email = "[email protected]", role = "aut"),
person("Cory", "Merow", email = "[email protected]", role = "aut"),
person("Mary E.", "Blair", email = "[email protected]", role = c("aut", "cre")),
person("Robert P.", "Anderson", email = "[email protected]", role = "aut"),
person("Sarah I.", "Meenan", email = "[email protected]", role = "ctb"),
person("Olivier", "Broennimann", email = "[email protected]", role = "ctb"),
person("Peter J.", "Galante", email = "[email protected]", role = "ctb"),
person("Brian S.", "Maitner", email = "[email protected]", role = "ctb"),
person("Hannah L.", "Owens", email = "[email protected]", role = "ctb"),
person("Sara", "Varela", email = "[email protected]", role = "ctb"),
person("Bruno", "Vilela", email = "[email protected]", role = "ctb"),
person("Robert", "Muscarella", email = "[email protected]", role = "ctb"))
person("Andrea", "Paz", email = "[email protected]", role = "aut"),
person("Valentina", "Grisales-Betancur", email = "[email protected]", role = "aut"),
person("Dean", "Attali", email = "[email protected]", role = "aut"),
person("Matthew E.", "Aiello-Lammens", email = "[email protected]", role = "aut"),
person("Cory", "Merow", email = "[email protected]", role = "aut"),
person("Mary E.", "Blair", email = "[email protected]", role = c("aut", "cre")),
person("Robert P.", "Anderson", email = "[email protected]", role = "aut"),
person("Sarah I.", "Meenan", email = "[email protected]", role = "ctb"),
person("Olivier", "Broennimann", email = "[email protected]", role = "ctb"),
person("Peter J.", "Galante", email = "[email protected]", role = "ctb"),
person("Brian S.", "Maitner", email = "[email protected]", role = "ctb"),
person("Hannah L.", "Owens", email = "[email protected]", role = "ctb"),
person("Sara", "Varela", email = "[email protected]", role = "ctb"),
person("Bruno", "Vilela", email = "[email protected]", role = "ctb"),
person("Robert", "Muscarella", email = "[email protected]", role = "ctb"))
Depends:
R (>= 3.5.0),
shiny (>= 1.6.0),
Expand All @@ -39,6 +39,7 @@ Imports:
DT (>= 0.5),
ecospat (>= 4.0.0),
ENMeval (>= 2.0.3),
geodata,
knitcitations,
leafem,
leaflet.extras (>= 1.0.0),
Expand Down
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
wallace 2.1.3
=============
- Fixed NULL error in poccs_selectOccs Rmd code
- Updated JK's email
- Added model name (FC + RM) to file name when prediction downloaded
- Fixed vis_responsePlot knitting to Rmd
- Fixed predictor variable bug in vis_responsePlot Rmd
- Fixed NA value warning in userEnvs
- Fixed broken function to disable `xfer_time` when using `envs_userEnvs`
- Replaced `raster::getdata` with `geodata` functions
- WorldClim v2.1 bioclimatic variables now available for Envs & Xfer_time!
- Added tryCatch for querying worldclim data (envs_wc & xfer_time)

wallace 2.1.2
=============
- Fixed FAIL in test_occs_queryDB
Expand Down
41 changes: 32 additions & 9 deletions R/envs_worldclim.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# envs_worldclim.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -53,8 +53,9 @@
#'
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Bethany A. Johnson <bjohnso005@@citymail.cuny.edu>
#'
#' @seealso \code{\link[raster]{getData}}
#' @seealso \code{\link[geodata]{worldclim_global}}, \code{\link[geodata]{worldclim_tile}}
#'
#' @export

Expand All @@ -66,20 +67,42 @@ envs_worldclim <- function(bcRes, bcSel, mapCntr, doBrick = FALSE,
}

smartProgress(logger, message = "Retrieving WorldClim data...", {
wcbc <- raster::getData(name = "worldclim", var = "bio", res = bcRes,
lon = mapCntr[1], lat = mapCntr[2])
# change names if bio01 is bio1, and so forth
if (bcRes == 0.5) {
names(wcbc) <- gsub("_.*", "", names(wcbc))
}
if (bcRes == 0.5) {
wcbc <- tryCatch(expr = geodata::worldclim_tile(var = "bio",
lon = mapCntr[1], lat = mapCntr[2],
path = tempdir(),
version="2.1"),
error = function(e) NULL)
} else {
wcbc <- tryCatch(expr = geodata::worldclim_global(var = "bio",
res = bcRes,
path = tempdir(),
version = "2.1"),
error= function(e) NULL)
}
#trycatch error
if (is.null(wcbc)) {
logger %>% writeLog(
type = "error",
paste0("Unable to retrieve data from WorldClim.
Server may be down.
Please use User-Specified module instead."))
return()
} else {
# change names to bioXX
names(wcbc) <- gsub(".*_", "bio", names(wcbc))
# change names if bio01 is bio1, and so forth
i <- grep('bio[0-9]$', names(wcbc))
editNames <- paste('bio', sapply(strsplit(names(wcbc)[i], 'bio'),
function(x) x[2]), sep = '0')
names(wcbc)[i] <- editNames

wcbc <- wcbc[[bcSel]]
}
})

# convert from spatraster to raster
wcbc <- raster::stack(wcbc)

# convert to brick for faster processing
if(doBrick == TRUE) {
smartProgress(logger,
Expand Down
8 changes: 4 additions & 4 deletions R/model_bioclim.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# model_bioclim.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -61,7 +61,7 @@
#' @return Function returns an ENMevaluate object with all the evaluated models
#' and a selection of appropriate fields.

#' @author Jamie M. Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie M. Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
# @note

Expand All @@ -73,8 +73,8 @@ model_bioclim <- function(occs, bg, user.grp, bgMsk, logger = NULL,
spN = NULL) {

# get just coordinates
occs.xy <- occs %>% dplyr::select(.data$longitude, .data$latitude)
bg.xy <- bg %>% dplyr::select(.data$longitude, .data$latitude)
occs.xy <- occs %>% dplyr::select("longitude", "latitude")
bg.xy <- bg %>% dplyr::select("longitude", "latitude")

smartProgress(logger,
message = paste0("Building/Evaluating BIOCLIM model for ",
Expand Down
8 changes: 4 additions & 4 deletions R/model_maxent.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# model_maxent.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -83,7 +83,7 @@
#'
#' @return Function returns an ENMevaluate object with all the evaluated models
#' and a selection of appropriate fields.
#' @author Jamie M. Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie M. Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
# @note

Expand Down Expand Up @@ -189,8 +189,8 @@ model_maxent <- function(occs, bg, user.grp, bgMsk, rms, rmsStep, fcs,
}

# get just coordinates
occs.xy <- occs %>% dplyr::select(.data$longitude, .data$latitude)
bg.xy <- bg %>% dplyr::select(.data$longitude, .data$latitude)
occs.xy <- occs %>% dplyr::select("longitude", "latitude")
bg.xy <- bg %>% dplyr::select("longitude", "latitude")
# run ENMeval
e <- ENMeval::ENMevaluate(occs = as.data.frame(occs.xy),
bg = as.data.frame(bg.xy),
Expand Down
28 changes: 14 additions & 14 deletions R/occs_queryDb.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# occs_queryDb.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -259,12 +259,12 @@ occs_queryDb <- function(spNames, occDb, occNum = NULL, doCitations = FALSE,
"institutionCode", "elevation", "coordinateUncertaintyInMeters")
for (i in fields) if (!(i %in% names(occs))) occs[i] <- NA
occs <- occs %>%
dplyr::rename(scientific_name = .data$name,
state_province = .data$stateProvince,
record_type = .data$basisOfRecord,
institution_code = .data$institutionCode,
catalog_number = .data$catalogNumber,
uncertainty = .data$coordinateUncertaintyInMeters)
dplyr::rename(scientific_name = "name",
state_province = "stateProvince",
record_type = "basisOfRecord",
institution_code = "institutionCode",
catalog_number = "catalogNumber",
uncertainty = "coordinateUncertaintyInMeters")

} else if (occDb == 'vertnet') { # standardize VertNet column names
fields <- c("name", "longitude", "latitude", "country", "stateprovince",
Expand All @@ -273,13 +273,13 @@ occs_queryDb <- function(spNames, occDb, occNum = NULL, doCitations = FALSE,
"coordinateuncertaintyinmeters")
for (i in fields) if (!(i %in% names(occs))) occs[i] <- NA
occs <- occs %>%
dplyr::rename(scientific_name = .data$name,
state_province = .data$stateprovince,
record_type = .data$basisofrecord,
institution_code = .data$institutioncode,
catalog_number = .data$catalognumber,
elevation = .data$maximumelevationinmeters,
uncertainty = .data$coordinateuncertaintyinmeters)
dplyr::rename(scientific_name = "name",
state_province = "stateprovince",
record_type = "basisofrecord",
institution_code = "institutioncode",
catalog_number = "catalognumber",
elevation = "maximumelevationinmeters",
uncertainty = "coordinateuncertaintyinmeters")
# } else if (occDb == 'bison') { # standardize BISON column names
# fields <- c("providedScientificName", "longitude", "latitude", "countryCode",
# "stateProvince", "verbatimLocality", "year", "basisOfRecord",
Expand Down
6 changes: 3 additions & 3 deletions R/part_partitionOccs.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# part_partitionOccs.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -96,8 +96,8 @@ part_partitionOccs <- function(occs, bg, method, kfolds = NULL, bgMask = NULL,
return()
}

occs.xy <- occs %>% dplyr::select(.data$longitude, .data$latitude)
bg.xy <- bg %>% dplyr::select(.data$longitude, .data$latitude)
occs.xy <- occs %>% dplyr::select("longitude", "latitude")
bg.xy <- bg %>% dplyr::select("longitude", "latitude")

if (method == 'jack') {
group.data <- ENMeval::get.jackknife(occs.xy, bg.xy)
Expand Down
4 changes: 2 additions & 2 deletions R/penvs_bgSample.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# penvs_bgSample.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -78,7 +78,7 @@ penvs_bgSample <- function(occs, bgMask, bgPtsNum, logger = NULL, spN = NULL) {
smartProgress(logger, message = "Generating background points...", {
bgXY <- dismo::randomPoints(bgMask, bgPtsNum)
bgXY <- bgXY %>% as.data.frame() %>%
dplyr::select(longitude = .data$x, latitude = .data$y)
dplyr::select(longitude = "x", latitude = "y")
bgNonNA <- raster::ncell(bgMask) - raster::freq(bgMask, value = NA)[[1]]
})
bg.prop <- round(nrow(bgXY)/bgPtsNum, digits = 2)
Expand Down
4 changes: 2 additions & 2 deletions R/poccs_selectOccs.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# poccs_selectOccs.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -98,7 +98,7 @@ poccs_selectOccs <- function(occs, polySelXY, polySelID = 1, logger = NULL,
hlSpp(spN),
"Your polygon is selecting all occurrences. None will be removed.")
occs.sel <- occs
return()
return(occs.sel)
}
occs.sel <- occs[-ptRemIndex,]

Expand Down
4 changes: 2 additions & 2 deletions R/run_wallace.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# run_wallace.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -36,7 +36,7 @@
#' if(interactive()) {
#' run_wallace()
#' }
#' @author Jamie Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @export
run_wallace <- function(launch.browser = TRUE, port = getOption("shiny.port")) {
Expand Down
4 changes: 2 additions & 2 deletions R/vis_bioclimPlot.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# vis_bioclimPlot.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -66,7 +66,7 @@
#' that are inside the envelope for all layers (included those not plotted)
#' are shown as green circles and those outside of the envelope for one ore
#' more variables are plotted as orange triangles.
#' @author Jamie Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
# @note
#' @seealso
Expand Down
5 changes: 3 additions & 2 deletions R/xfer_area.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# xfer_area.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -81,9 +81,10 @@
#' RasterBrick or a RasterStack of the environmental variables cropped to the
#' area of transfer. The second element is a raster of the transferred model with
#' the specified output type.
#' @author Jamie Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Andrea Paz <paz.andreita@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Bethany A. Johnson <bjohnso005@@citymail.cuny.edu>
# @note
#' @seealso \code{\link[dismo]{predict}}, \code{\link{xfer_time}}
#' \code{\link{xfer_userEnvs}}
Expand Down
4 changes: 2 additions & 2 deletions R/xfer_mess.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Wallace EcoMod: a flexible platform for reproducible modeling of
# species niches and distributions.
#
#
# xfer_mess.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -69,7 +69,7 @@
#' xferExtRas = envsFut)
#' }
# @return
#' @author Jamie Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>

# @note
Expand Down
2 changes: 1 addition & 1 deletion R/xfer_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
#' RasterBrick or RasterStack of the environmental variables cropped to the
#' area of transfer. The second element is a raster of the transferred model
#' with the specified output type.
#' @author Jamie Kass <jkass@@gradcenter.cuny.edu>
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Andrea Paz <paz.andreita@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Bethany A. Johnson <bjohnso005@@citymail.cuny.edu>
Expand Down
Loading
Loading