Skip to content

Commit

Permalink
Merge pull request wallaceEcoMod#437 from bjohnso005/biomodelos
Browse files Browse the repository at this point in the history
merge v2.1.3 into biomodelos
  • Loading branch information
danflop authored Aug 2, 2024
2 parents e9c278a + b723597 commit ba74553
Show file tree
Hide file tree
Showing 56 changed files with 402 additions and 252 deletions.
41 changes: 22 additions & 19 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wallace
Version: 2024.02.23
Date: 2024-02-23
Version: 2024.08.02
Date: 2024-08-02
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 @@ -40,11 +40,14 @@ Imports:
DT (>= 0.5),
ecospat (>= 4.0.0),
ENMeval (>= 2.0.3),
geodata,
knitcitations,
leafem,
leaflet.extras (>= 1.0.0),
magrittr,
maskRangeR,
markdown,
methods,
RColorBrewer,
rJava,
rlang,
Expand Down
21 changes: 21 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
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
- Fixed bug in error msgs for xfer_time
- Fixed broken link in v1 vignette
- Added `markdown` to imports
- Updated team members

wallace 2.1.1
=============
- Fixed bug in occ density grid & niche overlap
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
3 changes: 2 additions & 1 deletion R/helper_functions.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.
#
#
# helper_functions.R
# File author: Wallace EcoMod Dev Team. 2023.
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -74,6 +74,7 @@ spurious <- function(x) {
RColorBrewer::brewer.pal(x)
leafem::addMouseCoordinates(x)
leaflet.extras::removeDrawToolbar(x)
markdown::html_format()
rmarkdown::github_document(x)
shinyWidgets::pickerInput(x)
shinyjs::disable(x)
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
Loading

0 comments on commit ba74553

Please sign in to comment.