diff --git a/DESCRIPTION b/DESCRIPTION index c2d8aa0ca..fc6e3e62f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 @@ -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: . Authors@R: - c(person("Jamie M.", "Kass", email = "jamie.kass@oist.jp", role = "aut"), + c(person("Bethany A.", "Johnson", email = "bjohnso005@citymail.cuny.edu", role = "aut"), + person("Jamie M.", "Kass", email = "jamie.m.kass@gmail.com", role = "aut"), person("Gonzalo E.", "Pinilla-Buitrago", email = "gepinillab@gmail.com", role = "aut"), - person("Andrea", "Paz", email = "paz.andreita@gmail.com", role = "aut"), - person("Bethany A.", "Johnson", email = "bjohnso005@citymail.cuny.edu", role = "aut"), - person("Valentina", "Grisales-Betancur", email = "vgrisale@eafit.edu.co", role = "aut"), - person("Dean", "Attali", email = "daattali@gmail.com", role = "aut"), - person("Matthew E.", "Aiello-Lammens", email = "matt.lammens@gmail.com", role = "aut"), - person("Cory", "Merow", email = "corymerow@gmail.com", role = "aut"), - person("Mary E.", "Blair", email = "mblair1@amnh.org", role = c("aut", "cre")), - person("Robert P.", "Anderson", email = "randerson@ccny.cuny.edu", role = "aut"), - person("Sarah I.", "Meenan", email = "sarah.meenan@gmail.com", role = "ctb"), - person("Olivier", "Broennimann", email = "olivier.broennimann@unil.ch", role = "ctb"), - person("Peter J.", "Galante", email = "pgalante@amnh.org", role = "ctb"), - person("Brian S.", "Maitner", email = "bmaitner@gmail.com", role = "ctb"), - person("Hannah L.", "Owens", email = "hannah.owens@gmail.com", role = "ctb"), - person("Sara", "Varela", email = "sara_varela@yahoo.com", role = "ctb"), - person("Bruno", "Vilela", email = "bvilela@wustl.edu", role = "ctb"), - person("Robert", "Muscarella", email = "bob.muscarella@gmail.com", role = "ctb")) + person("Andrea", "Paz", email = "paz.andreita@gmail.com", role = "aut"), + person("Valentina", "Grisales-Betancur", email = "vgrisale@eafit.edu.co", role = "aut"), + person("Dean", "Attali", email = "daattali@gmail.com", role = "aut"), + person("Matthew E.", "Aiello-Lammens", email = "matt.lammens@gmail.com", role = "aut"), + person("Cory", "Merow", email = "corymerow@gmail.com", role = "aut"), + person("Mary E.", "Blair", email = "mblair1@amnh.org", role = c("aut", "cre")), + person("Robert P.", "Anderson", email = "randerson@ccny.cuny.edu", role = "aut"), + person("Sarah I.", "Meenan", email = "sarah.meenan@gmail.com", role = "ctb"), + person("Olivier", "Broennimann", email = "olivier.broennimann@unil.ch", role = "ctb"), + person("Peter J.", "Galante", email = "pgalante@amnh.org", role = "ctb"), + person("Brian S.", "Maitner", email = "bmaitner@gmail.com", role = "ctb"), + person("Hannah L.", "Owens", email = "hannah.owens@gmail.com", role = "ctb"), + person("Sara", "Varela", email = "sara_varela@yahoo.com", role = "ctb"), + person("Bruno", "Vilela", email = "bvilela@wustl.edu", role = "ctb"), + person("Robert", "Muscarella", email = "bob.muscarella@gmail.com", role = "ctb")) Depends: R (>= 3.5.0), shiny (>= 1.6.0), @@ -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, diff --git a/NEWS.md b/NEWS.md index 15bec38d4..3737810cf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/envs_worldclim.R b/R/envs_worldclim.R index 98ed0c045..77cad85b0 100644 --- a/R/envs_worldclim.R +++ b/R/envs_worldclim.R @@ -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. # -------------------------------------------------------------------------- @@ -53,8 +53,9 @@ #' #' @author Jamie Kass #' @author Gonzalo E. Pinilla-Buitrago +#' @author Bethany A. Johnson #' -#' @seealso \code{\link[raster]{getData}} +#' @seealso \code{\link[geodata]{worldclim_global}}, \code{\link[geodata]{worldclim_tile}} #' #' @export @@ -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, diff --git a/R/helper_functions.R b/R/helper_functions.R index d72aae496..b9c4e4f39 100644 --- a/R/helper_functions.R +++ b/R/helper_functions.R @@ -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. # -------------------------------------------------------------------------- @@ -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) diff --git a/R/model_bioclim.R b/R/model_bioclim.R index 699afcd62..84f9b35e7 100644 --- a/R/model_bioclim.R +++ b/R/model_bioclim.R @@ -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. # -------------------------------------------------------------------------- @@ -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 +#' @author Jamie M. Kass #' @author Gonzalo E. Pinilla-Buitrago # @note @@ -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 ", diff --git a/R/model_maxent.R b/R/model_maxent.R index 6e2db6824..82a53b069 100644 --- a/R/model_maxent.R +++ b/R/model_maxent.R @@ -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. # -------------------------------------------------------------------------- @@ -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 +#' @author Jamie M. Kass #' @author Gonzalo E. Pinilla-Buitrago # @note @@ -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), diff --git a/R/occs_queryDb.R b/R/occs_queryDb.R index 0e5cea1fc..712a8373b 100644 --- a/R/occs_queryDb.R +++ b/R/occs_queryDb.R @@ -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. # -------------------------------------------------------------------------- @@ -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", @@ -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", diff --git a/R/part_partitionOccs.R b/R/part_partitionOccs.R index 4fe048bd3..17fff7961 100644 --- a/R/part_partitionOccs.R +++ b/R/part_partitionOccs.R @@ -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. # -------------------------------------------------------------------------- @@ -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) diff --git a/R/penvs_bgSample.R b/R/penvs_bgSample.R index e23a426bb..e16523ac8 100644 --- a/R/penvs_bgSample.R +++ b/R/penvs_bgSample.R @@ -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. # -------------------------------------------------------------------------- @@ -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) diff --git a/R/poccs_selectOccs.R b/R/poccs_selectOccs.R index 1d15ea255..2b22c156b 100644 --- a/R/poccs_selectOccs.R +++ b/R/poccs_selectOccs.R @@ -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. # -------------------------------------------------------------------------- @@ -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,] diff --git a/R/run_wallace.R b/R/run_wallace.R index d74c16258..325b713ea 100644 --- a/R/run_wallace.R +++ b/R/run_wallace.R @@ -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. # -------------------------------------------------------------------------- @@ -36,7 +36,7 @@ #' if(interactive()) { #' run_wallace() #' } -#' @author Jamie Kass +#' @author Jamie Kass #' @author Gonzalo E. Pinilla-Buitrago #' @export run_wallace <- function(launch.browser = TRUE, port = getOption("shiny.port"), diff --git a/R/vis_bioclimPlot.R b/R/vis_bioclimPlot.R index 2b3c4b383..d979c50f2 100644 --- a/R/vis_bioclimPlot.R +++ b/R/vis_bioclimPlot.R @@ -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. # -------------------------------------------------------------------------- @@ -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 +#' @author Jamie Kass #' @author Gonzalo E. Pinilla-Buitrago # @note #' @seealso diff --git a/R/xfer_area.R b/R/xfer_area.R index f89aedde8..f0c2e9cd3 100644 --- a/R/xfer_area.R +++ b/R/xfer_area.R @@ -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. # -------------------------------------------------------------------------- @@ -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 +#' @author Jamie Kass #' @author Andrea Paz #' @author Gonzalo E. Pinilla-Buitrago +#' @author Bethany A. Johnson # @note #' @seealso \code{\link[dismo]{predict}}, \code{\link{xfer_time}} #' \code{\link{xfer_userEnvs}} diff --git a/R/xfer_mess.R b/R/xfer_mess.R index ed61838ec..28efe4e4c 100644 --- a/R/xfer_mess.R +++ b/R/xfer_mess.R @@ -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. # -------------------------------------------------------------------------- @@ -69,7 +69,7 @@ #' xferExtRas = envsFut) #' } # @return -#' @author Jamie Kass +#' @author Jamie Kass #' @author Gonzalo E. Pinilla-Buitrago # @note diff --git a/R/xfer_time.R b/R/xfer_time.R index 4e28f11d3..832f4fcd8 100644 --- a/R/xfer_time.R +++ b/R/xfer_time.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # xfer_time.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -92,9 +92,10 @@ #' 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 +#' @author Jamie Kass #' @author Andrea Paz #' @author Gonzalo E. Pinilla-Buitrago +#' @author Bethany A. Johnson #' @seealso \code{\link[dismo]{predict}}, \code{\link{xfer_time}} #' \code{\link{xfer_userEnvs}} #' @export diff --git a/R/xfer_userEnvs.R b/R/xfer_userEnvs.R index 6a2c0fce8..8d87f0c71 100644 --- a/R/xfer_userEnvs.R +++ b/R/xfer_userEnvs.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # xfer_userEnvs.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -76,9 +76,10 @@ #' clamp = FALSE, xfExt = polyExt) #' } #' -#' @author Jamie Kass +#' @author Jamie Kass #' @author Andrea Paz #' @author Gonzalo E. Pinilla-Buitrago +#' @author Bethany A. Johnson # @note #' @seealso \code{\link[dismo]{predict}}, \code{\link{xfer_time}} #' \code{\link{xfer_userExtent}} diff --git a/README.md b/README.md index 41a7d230a..fc691aa4a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![R-CMD-check](https://github.com/wallaceEcoMod/wallace/workflows/R-CMD-check/badge.svg)](https://github.com/wallaceEcoMod/wallace/actions) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![CRAN version](http://www.r-pkg.org/badges/version/wallace)](https://CRAN.R-project.org/package=wallace) [![downloads](https://cranlogs.r-pkg.org:443/badges/grand-total/wallace?color=orange)](https://cranlogs.r-pkg.org:443/badges/grand-total/wallace?color=orange) -# Wallace (v2024.02.23) +# Wallace (v2024.08.02) *Wallace* is a modular platform for reproducible modeling of species niches and distributions, written in R. The application guides users through a complete analysis, from the acquisition of data to visualizing model predictions on an interactive map, thus bundling complex workflows into a single, streamlined interface. Install *Wallace* via CRAN and run the application with the following R code. diff --git a/inst/shiny/Rmd/text_about.Rmd b/inst/shiny/Rmd/text_about.Rmd index 686618f05..ac9187593 100644 --- a/inst/shiny/Rmd/text_about.Rmd +++ b/inst/shiny/Rmd/text_about.Rmd @@ -6,7 +6,7 @@ output: html_document ### **What is *Wallace*?** logo -Welcome to *Wallace*, a flexible application for reproducible ecological modeling, built for community expansion. The current version of *Wallace* (v2024.02.23) steps the user through a full niche/distribution modeling analysis, from data acquisition to visualizing results. +Welcome to *Wallace*, a flexible application for reproducible ecological modeling, built for community expansion. The current version of *Wallace* (v2024.08.02) steps the user through a full niche/distribution modeling analysis, from data acquisition to visualizing results. The application is written in `R` with the web app development package `shiny`. Please find the stable version of *Wallace* on CRAN, and the development version on Github. We also maintain a *Wallace* website that has some basic info, links, and will be updated with tutorial materials in the near future. diff --git a/inst/shiny/Rmd/text_intro_tab.Rmd b/inst/shiny/Rmd/text_intro_tab.Rmd index 3e89dc2eb..dc5b4d212 100644 --- a/inst/shiny/Rmd/text_intro_tab.Rmd +++ b/inst/shiny/Rmd/text_intro_tab.Rmd @@ -5,7 +5,7 @@ output: html_document #### WORKFLOW -*Wallace* (v2024.02.23) currently includes ten components, or steps of a possible workflow. Each component includes two or more modules, which are possible analyses for that step. +*Wallace* (v2024.08.02) currently includes ten components, or steps of a possible workflow. Each component includes two or more modules, which are possible analyses for that step. **Components:** diff --git a/inst/shiny/Rmd/text_team.Rmd b/inst/shiny/Rmd/text_team.Rmd index dfdd4b16b..fd06e36e4 100644 --- a/inst/shiny/Rmd/text_team.Rmd +++ b/inst/shiny/Rmd/text_team.Rmd @@ -8,14 +8,19 @@ output: html_document ## Developers +bethany + +Bethany A. Johnson (lead developer) received her MS in Biology from the City College of New York and is currently a Visiting Scientist at the Center for Biodiversity & Conservation at the American Museum of Natural History. +
+ jamie -Jamie M. Kass (co-lead developer) received his PhD at CUNY Graduate Center and City College of New York and is currently a Postdoctoral Scholar at Okinawa Institute of Science and Technology Graduate University. +Jamie M. Kass (developer) received his PhD at CUNY Graduate Center and City College of New York, did a Postdoc at Okinawa Institute of Science and Technology, and currently is Associate Professor at Tohoku University.
gonzalo -Gonzalo E. Pinilla-Buitrago (co-lead developer) received his PhD from the CUNY Graduate Center and City College of New York. He is currently a Postdoctoral Researcher at University of Connecticut. +Gonzalo E. Pinilla-Buitrago (developer) received his PhD from the CUNY Graduate Center and City College of New York. He is currently a Postdoctoral Researcher at University of Connecticut.
andrea @@ -23,10 +28,7 @@ output: html_document Andrea Paz (developer) received her PhD at CUNY Graduate Center and City College of New York, after which she was a Postdoctoral Researcher at the Crowther Lab in ETH Zürich. She is now an Assistant Professor at the Biological Sciences Department, University of Montréal.
-bethany - -Bethany A. Johnson (developer) received her MS in Biology from the City College of New York and is currently a Visiting Scientist at the Center for Biodiversity & Conservation at the American Museum of Natural History. -
+dani beth @@ -36,7 +38,7 @@ output: html_document Daniel López Lozano (developer) is a Biodiversity Informatics Specialist at the American Museum of Natural History's Center for Biodiversity & Conservation.
-valentina +valentina Valentina Grisales-Betancur (developer) completed her undergraduate degree at EAFIT University in Colombia and visited the Anderson lab at CCNY and Blair lab at AMNH.
@@ -90,9 +92,9 @@ Sarah Meenan (contributor) completed her undergraduate degree from the City Coll Brian S. Maitner (contributor, external partner) is a researcher at the Geography Department of the University at Buffalo, SUNY.
-hannahO +hannahO -Hannah Owens (contributor, external partner) is a Marie Skłodowska Curie Fellow at the Center for Macroecology, Evolution, and Climate at the University of Copenhagen. +Hannah Owens (contributor, external partner) is an assistant professor at the Center for Global Mountain Biodiversity & the Center for Macroecology, Evolution, and Climate; Section for Biodiversity; Globe Institute; at the University of Copenhagen.
saraV diff --git a/inst/shiny/Rmd/userReport_intro.Rmd b/inst/shiny/Rmd/userReport_intro.Rmd index fb476f2a2..5439139b5 100644 --- a/inst/shiny/Rmd/userReport_intro.Rmd +++ b/inst/shiny/Rmd/userReport_intro.Rmd @@ -10,7 +10,7 @@ knit_engines$set(asis = function(options) { knitr::opts_chunk$set(message = FALSE, warning = FALSE, eval = FALSE) ``` -Please find below the R code history from your *Wallace* v2024.02.23 session. +Please find below the R code history from your *Wallace* v2024.08.02 session. You can reproduce your session results by running this R Markdown file in RStudio. diff --git a/inst/shiny/modules/envs_userEnvs.R b/inst/shiny/modules/envs_userEnvs.R index c521b4364..545122d2b 100644 --- a/inst/shiny/modules/envs_userEnvs.R +++ b/inst/shiny/modules/envs_userEnvs.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # envs_userEnvs.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -79,9 +79,14 @@ envs_userEnvs_module_server <- function(input, output, session, common) { if (length(unique(checkNA$isNA)) != 1) { logger %>% writeLog( - type = "error", - 'Input rasters have unmatching NAs pixel values.') - return() + type = "warning", + 'Input rasters have unmatching NA pixel values. + This may cause issues in further analyses. + See Module Guidance for more info.') + # BAJ 7/16/2024 if users report problems with espace, add... + #common$disable_module(component = "espace", module = "pca") + #common$disable_module(component = "espace", module = "occDens") + #common$disable_module(component = "espace", module = "nicheOv") } # loop over all species if batch is on @@ -146,7 +151,7 @@ envs_userEnvs_module_server <- function(input, output, session, common) { } common$update_component(tab = "Results") - common$disable_module(component = "xfer", module = "xferTime") + common$disable_module(component = "xfer", module = "time") }) output$envsPrint <- renderPrint({ diff --git a/inst/shiny/modules/envs_userEnvs.md b/inst/shiny/modules/envs_userEnvs.md index 6bad88928..5e2165f82 100644 --- a/inst/shiny/modules/envs_userEnvs.md +++ b/inst/shiny/modules/envs_userEnvs.md @@ -25,3 +25,7 @@ writeRaster(r, path_to_new_projected_raster_file) Users will need to know what the original CRS of their rasters is, then look up (i.e., Google search) its proj4 format. After saving, upload the new projected rasters and continue with your analysis. *NOTE: A reminder that some file types like .asc cannot embed CRS information in the file, so please avoid these types -- instead use types such as .tif that retain the CRS.* + +A warning message will appear if your layers have NA values falling in pixels that are not consistent among each layer. You can continue using them, but some downstream steps of analyses may not be functional. Alternatively, you can assign values in a GIS program or mask the layers to have matching NA values outside of Wallace in R. + +Using your own environmental data will disable the Module: *Transfer to New Time*, as this module requires WorldClim bioclimatic variables. The Module: *Transfer to User Environments* is still available. diff --git a/inst/shiny/modules/envs_worldclim.R b/inst/shiny/modules/envs_worldclim.R index 2d736744c..3b134330f 100644 --- a/inst/shiny/modules/envs_worldclim.R +++ b/inst/shiny/modules/envs_worldclim.R @@ -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. # -------------------------------------------------------------------------- @@ -145,11 +145,11 @@ envs_worldclim_module_server <- function(input, output, session, common) { # METADATA #### spp[[sp]]$rmm$data$environment$variableNames <- names(wcbc) - spp[[sp]]$rmm$data$environment$yearMin <- 1960 - spp[[sp]]$rmm$data$environment$yearMax <- 1990 + spp[[sp]]$rmm$data$environment$yearMin <- 1970 + spp[[sp]]$rmm$data$environment$yearMax <- 2000 spp[[sp]]$rmm$data$environment$resolution <- paste(round(raster::res(wcbc)[1] * 60, digits = 2), "minutes") spp[[sp]]$rmm$data$environment$extent <- as.character(raster::extent(wcbc)) - spp[[sp]]$rmm$data$environment$sources <- 'WorldClim 1.4' + spp[[sp]]$rmm$data$environment$sources <- 'WorldClim v2.1' spp[[sp]]$rmm$data$environment$projection <- as.character(raster::crs(wcbc)) spp[[sp]]$rmm$code$wallace$wcRes <- input$wcRes diff --git a/inst/shiny/modules/envs_worldclim.Rmd b/inst/shiny/modules/envs_worldclim.Rmd index 5b43bed52..a951f3058 100644 --- a/inst/shiny/modules/envs_worldclim.Rmd +++ b/inst/shiny/modules/envs_worldclim.Rmd @@ -1,6 +1,6 @@ ```{asis, echo = {{envs_worldclim_knit}}, eval = {{envs_worldclim_knit}}, include = {{envs_worldclim_knit}}} ### Obtain environmental data -Using WorldClim (http://www.worldclim.org/) bioclimatic dataset at resolution of `r {{wcRes_rmd}}` arcmin. +Using WorldClim v2.1 (http://www.worldclim.org/) bioclimatic dataset at resolution of `r {{wcRes_rmd}}` arcmin. ``` ```{r, echo = {{envs_worldclim_knit}}, include = {{envs_worldclim_knit}}} diff --git a/inst/shiny/modules/envs_worldclim.md b/inst/shiny/modules/envs_worldclim.md index 4bb901d8e..1d0829034 100644 --- a/inst/shiny/modules/envs_worldclim.md +++ b/inst/shiny/modules/envs_worldclim.md @@ -2,7 +2,7 @@ **BACKGROUND** -The WorldClim project provides bioclimatic variables for the Earth's land surfaces for all continents except Antarctica. Monthly data from weather stations were spatially interpolated using elevation as a covariate; subsequently, 19 bioclimatic variables were derived, reflecting various aspects of temperature and precipitation (Hijmans et al. 2005). The descriptions of each variable are listed below, taken from the WorldClim website, where more details can be found. +The WorldClim project provides bioclimatic variables for the Earth's land surfaces for all continents except Antarctica. Monthly data from weather stations were spatially interpolated using elevation as a covariate; subsequently, 19 bioclimatic variables were derived, reflecting various aspects of temperature and precipitation (Fick & Hijmans 2017). The descriptions of each variable are listed below, taken from the WorldClim website, where more details can be found. BIO1 = Annual Mean Temperature BIO2 = Mean Diurnal Range (Mean of monthly (max temp - min temp)) @@ -26,10 +26,12 @@ BIO19 = Precipitation of Coldest Quarter **IMPLEMENTATION** -This module relies on the R package `raster` (Hijmans et al. 2021) to download bioclimatic variables from the WorldClim server. -*Wallace* makes all four resolutions of the data available (10 arcmin ≈ 20 km, 5 arcmin ≈ 10 km, 2.5 arcmin ≈ 5 km, and 30 arcsec ≈ 1 km). Although a later version of WorldClim exists (v2; Fick and Hijmans 2017), it is not available for automated download via the `raster` package; therefore, *Wallace* provides the data from WorldClim v1 (Hijmans et al. 2005). +This module relies on the R package `geodata` (Hijmans et al. 2024) to download WorldClim v2.1 bioclimatic variables from the WorldClim server (Fick and Hijmans 2017). +*Wallace* makes all four resolutions of the data available (10 arcmin ≈ 20 km, 5 arcmin ≈ 10 km, 2.5 arcmin ≈ 5 km, and 30 arcsec ≈ 1 km). + The finest-grain WorldClim dataset (30 arcsec) can only be downloaded by separate 30 x 30 degree tiles in the current implementation of dismo (1.1-1), so *Wallace* uses the current center of the map display as the tile reference for this resolution. This means that analyses with 30 arcsec climatic data using the current version of *Wallace* are restricted to the extent of a single tile. To visualize the tile, check the “30 arcsec tile” box in the bottom left corner of the map. This will let the user see if the occurrences are all contained within the tile or whether they extend beyond it. When running locally, the dataset is downloaded to the *Wallace* folder (which can take substantial time), but *Wallace* will use the downloaded data for later runs when the same resolution is selected. + The “Batch” option will load the environmental variables selected at the chosen resolution for all the species that have occurrence data uploaded. @@ -37,6 +39,4 @@ The “Batch” option will load the environmental variables selected at the cho Fick, S.E., & Hijmans, R.J. (2017). WorldClim 2: new 1-km spatial resolution climate surfaces for global land areas. *International Journal of Climatology*, 37(12), 4302-4315. DOI: 10.1002/joc.5086 -Hijmans, R.J., Cameron, S.E., Parra, J.L., Jones, P.G., & Jarvis, A. (2005). Very high resolution interpolated climate surfaces for global land areas. *International Journal of Climatology*, 25(15), 1965-1978. DOI: 10.1002/joc.1276 - -Hijmans, R.J., et al. (2021). raster: Geographic Data Analysis and Modeling. R package version 3.4-13. CRAN +Hijmans, R.J., et al. (2024). geodata: Download Geographic Data. R package version 0.6-2. CRAN diff --git a/inst/shiny/modules/envs_worldclim.yml b/inst/shiny/modules/envs_worldclim.yml index f1a762868..01cd52258 100644 --- a/inst/shiny/modules/envs_worldclim.yml +++ b/inst/shiny/modules/envs_worldclim.yml @@ -1,5 +1,5 @@ component: "envs" short_name: "WorldClim Bioclims" long_name: "WorldClim Bioclims" -authors: "Jamie M. Kass, Gonzalo E. Pinilla-Buitrago, Robert P. Anderson" -package: [raster] +authors: "Jamie M. Kass, Gonzalo E. Pinilla-Buitrago, Bethany A. Johnson, Robert P. Anderson" +package: [raster, geodata] diff --git a/inst/shiny/modules/model_bioclim.Rmd b/inst/shiny/modules/model_bioclim.Rmd index b2b5f16fc..459243090 100644 --- a/inst/shiny/modules/model_bioclim.Rmd +++ b/inst/shiny/modules/model_bioclim.Rmd @@ -1,6 +1,6 @@ ```{asis, echo = {{model_bioclim_knit}}, eval = {{model_bioclim_knit}}, include = {{model_bioclim_knit}}} ### Build and Evaluate Niche Model -Generating a species distribution model using the bioclim alogorithm as implemented in ENMeval V2.0. +Generating a species distribution model using the bioclim algorithm as implemented in ENMeval V2.0. ``` ```{r, echo = {{model_bioclim_knit}}, include = {{model_bioclim_knit}}} diff --git a/inst/shiny/modules/occs_queryDb.yml b/inst/shiny/modules/occs_queryDb.yml index 163334f3c..ea485af61 100644 --- a/inst/shiny/modules/occs_queryDb.yml +++ b/inst/shiny/modules/occs_queryDb.yml @@ -1,5 +1,5 @@ component: occs short_name: Query Database (Present) long_name: Query Database (Present) -authors: Jamie M. Kass, Bruno Vilela, Gonzalo E. Pinilla-Buitrago, Hannah Owens, Cory Merow, Robert P. Anderson +authors: Jamie M. Kass, Bruno Vilela, Gonzalo E. Pinilla-Buitrago, Hannah Owens, Andrea Paz, Cory Merow, Robert P. Anderson package: [BIEN, occCite, spocc] diff --git a/inst/shiny/modules/vis_bioclimPlot.R b/inst/shiny/modules/vis_bioclimPlot.R index 8bf68cf79..1166cd5a2 100644 --- a/inst/shiny/modules/vis_bioclimPlot.R +++ b/inst/shiny/modules/vis_bioclimPlot.R @@ -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. # -------------------------------------------------------------------------- @@ -28,7 +28,8 @@ vis_bioclimPlot_module_ui <- function(id) { numericInput(ns("bc1"), "Axis 1", value = 1, min = 1, max = 19), numericInput(ns("bc2"), "Axis 2", value = 2, min = 1, max = 19), numericInput(ns("bcProb"), "Set threshold", value = 0.9, min = 0.75, - max = 1, step = 0.05) + max = 1, step = 0.05), + h5("BIOCLIM envelope plots are displayed automatically in 'Results' tab") ) } diff --git a/inst/shiny/modules/vis_maxentEvalPlot.R b/inst/shiny/modules/vis_maxentEvalPlot.R index 4be1dcc73..6fd0e022a 100644 --- a/inst/shiny/modules/vis_maxentEvalPlot.R +++ b/inst/shiny/modules/vis_maxentEvalPlot.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # vis_maxentEvalPlot.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -32,7 +32,7 @@ vis_maxentEvalPlot_module_ui <- function(id) { "average OR 10%" = 'or.10p', "delta AICc" = 'delta.AICc'), selected = 'auc.val'), - h6("Maxent evaluation plots display automatically in 'Results' tab") + h5("Maxent evaluation plots display automatically in 'Results' tab") ) } diff --git a/inst/shiny/modules/vis_responsePlot.R b/inst/shiny/modules/vis_responsePlot.R index 02a4c0b6f..c180303a3 100644 --- a/inst/shiny/modules/vis_responsePlot.R +++ b/inst/shiny/modules/vis_responsePlot.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # vis_responsePlot.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -38,14 +38,15 @@ vis_responsePlot_module_server <- function(input, output, session, common) { curEnv <- common$curEnv evalOut <- common$evalOut - observeEvent(input,{ + observe({ req(curSp()) req(curModel()) req(evalOut()) #for rmd - spp[[curSp()]]$rmd$vis_responsePlot <- TRUE + if (spp[[curSp()]]$rmm$model$algorithms == "maxnet" | spp[[curSp()]]$rmm$model$algorithms == "maxent.jar"){ spp[[curSp()]]$rmd$vis_curModel <- curModel() + spp[[curSp()]]$rmd$vis_responsePlot <- TRUE } }) diff --git a/inst/shiny/modules/vis_responsePlot.Rmd b/inst/shiny/modules/vis_responsePlot.Rmd index 58c3f4ddc..82cecbd9c 100644 --- a/inst/shiny/modules/vis_responsePlot.Rmd +++ b/inst/shiny/modules/vis_responsePlot.Rmd @@ -4,12 +4,16 @@ Visualize response curves from "{{alg_rmd}}" model. ``` ```{r, echo = {{vis_responsePlot_knit & vis_maxnet_knit}}, include = {{vis_responsePlot_knit & vis_maxnet_knit}}} +# Retrieve env variables +n <- mxNonzeroCoefs(model_{{spAbr}}@models[["{{curModel_rmd}}"]], "maxnet") + # Create response curves +for (i in n) { maxnet::response.plot( model_{{spAbr}}@models[["{{curModel_rmd}}"]], - v = names(bgMask_{{spAbr}}), + v = i, type = "cloglog") - +} ``` ```{asis, echo = {{vis_responsePlot_knit & !vis_maxnet_knit}}, eval = {{vis_responsePlot_knit & !vis_maxnet_knit}}, include = {{vis_responsePlot_knit & !vis_maxnet_knit}}} @@ -18,8 +22,13 @@ Visualize response curves from "{{alg_rmd}}" model. ``` ```{r, echo = {{vis_responsePlot_knit & !vis_maxnet_knit }}, include = {{vis_responsePlot_knit & !vis_maxnet_knit}}} +# Retrieve env variables +n <- mxNonzeroCoefs(model_{{spAbr}}@models[["{{curModel_rmd}}"]], "maxent.jar") + # Create response curves +for (i in n) { dismo::response( model_{{spAbr}}@models[["{{curModel_rmd}}"]], - var = names(bgMask_{{spAbr}})) + var = i) +} ``` diff --git a/inst/shiny/modules/xfer_area.R b/inst/shiny/modules/xfer_area.R index 66b581a37..2b76ebc2a 100644 --- a/inst/shiny/modules/xfer_area.R +++ b/inst/shiny/modules/xfer_area.R @@ -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. # -------------------------------------------------------------------------- @@ -87,7 +87,7 @@ xfer_area_module_server <- function(input, output, session, common) { ns <- session$ns req(curSp(), evalOut()) if (spp[[curSp()]]$rmm$model$algorithms != "BIOCLIM") { - h5("Prediction output is the same than Visualize component ") + h5("Prediction output is the same as Visualize component ") } }) @@ -289,9 +289,9 @@ xfer_area_module_server <- function(input, output, session, common) { printVecAsis(raster::cellStats(xferExt, min), asChar = TRUE) spp[[curSp()]]$rmm$data$transfer$environment1$maxVal <- printVecAsis(raster::cellStats(xferExt, max), asChar = TRUE) - if (spp[[curSp()]]$rmm$data$environment$sources == 'WorldClim 1.4') { - spp[[curSp()]]$rmm$data$transfer$environment1$yearMin <- 1960 - spp[[curSp()]]$rmm$data$transfer$environment1$yearMax <- 1990 + if (spp[[curSp()]]$rmm$data$environment$sources == 'WorldClim 2.1') { + spp[[curSp()]]$rmm$data$transfer$environment1$yearMin <- 1970 + spp[[curSp()]]$rmm$data$transfer$environment1$yearMax <- 2000 } spp[[curSp()]]$rmm$data$transfer$environment1$resolution <- paste(round(raster::res(xferExt)[1] * 60, digits = 2), "degrees") diff --git a/inst/shiny/modules/xfer_time.R b/inst/shiny/modules/xfer_time.R index 0dce7a60c..1b4e7e151 100644 --- a/inst/shiny/modules/xfer_time.R +++ b/inst/shiny/modules/xfer_time.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # xfer_time.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -72,15 +72,40 @@ xfer_time_module_ui <- function(id) { conditionalPanel(sprintf("input['%s'] == 'worldclim'", ns("selTimeVar")), selectInput(ns("selTime"), label = "Select time period", choices = list("Select period" = "", - "2050" = 50, - "2070" = 70)), - uiOutput(ns('selGCMui')), - selectInput(ns('selRCP'), label = "Select RCP", - choices = list("Select RCP" = "", - '2.6' = 26, - '4.5' = 45, - '6.0' = 60, - '8.5' = 85))), + "2021-2040" = "2021-2040", + "2041-2060" = "2041-2060", + "2061-2080" = "2061-2080")), + selectInput(ns("selGCM"), label = "Select global circulation model", + choices = list("Select GCM" = "", + "ACCESS-CM2" = "ACCESS-CM2", + "ACCESS-ESM1-5" = "ACCESS-ESM1-5", + "AWI-CM-1-1-MR" = "AWI-CM-1-1-MR", + "BCC-CSM2-MR" = "BCC-CSM2-MR", + "CanESM5" = "CanESM5", + "CanESM5-CanOE" = "CanESM5-CanOE", + "CMCC-ESM2" = "CMCC-ESM2", + "CNRM-CM6-1" = "CNRM-CM6-1", + "CNRM-CM6-1-HR" = "CNRM-CM6-1-HR", + "CNRM-ESM2-1" = "CNRM-ESM2-1", + "EC-Earth3-Veg" = "EC-Earth3-Veg", + "EC-Earth3-Veg-LR" = "EC-Earth3-Veg-LR", + "GISS-E2-1-G" = "GISS-E2-1-G", + "GISS-E2-1-H" = "GISS-E2-1-H", + "INM-CM4-8" = "INM-CM4-8", + "INM-CM5-0" = "INM-CM5-0", + "IPSL-CM6A-LR" = "IPSL-CM6A-LR", + "MIROC-ES2L" = "MIROC-ES2L", + "MIROC6" = "MIROC6", + "MPI-ESM1-2-HR" = "MPI-ESM1-2-HR", + "MPI-ESM1-2-LR" = "MPI-ESM1-2-LR", + "MRI-ESM2-0" = "MRI-ESM2-0", + "UKESM1-0-LL" = "UKESM1-0-LL")), + selectInput(ns('selRCP'), label = "Select shared socioeconomic pathway", + choices = list("Select SSP" = "", + "126" = "126", + "245" = "245", + "370" = "370", + "585" = "585"))), conditionalPanel(sprintf("input['%s'] == 'ecoclimate'", ns("selTimeVar")), tags$div(title = 'Select AOGCM', selectInput(ns("xfAOGCM"), @@ -154,22 +179,23 @@ xfer_time_module_server <- function(input, output, session, common) { MG = "MRI-CGCM3", NO = "NorESM1-M") # dynamic ui for GCM selection: choices differ depending on choice of time period - output$selGCMui <- renderUI({ - ns <- session$ns - - if (input$selTime == 'lgm') { - gcms <- c('CC', 'MR', 'MC') - } else if (input$selTime == 'mid') { - gcms <- c("BC", "CC", "CE", "CN", "HG", "IP", "MR", "ME", "MG") - } else { - gcms <- c("AC", "BC", "CC", "CE", "CN", "GF", "GD", "GS", "HD", - "HG", "HE", "IN", "IP", "MI", "MR", "MC", "MP", "MG", "NO") - } - names(gcms) <- GCMlookup[gcms] - gcms <- as.list(c("Select GCM" = "", gcms)) - selectInput(ns("selGCM"), label = "Select global circulation model", - choices = gcms) - }) + # 7/16/2024: BAJ removed after geodata & WCv2.1 update, but kept in case needed later + # output$selGCMui <- renderUI({ + # ns <- session$ns + # + # if (input$selTime == 'lgm') { + # gcms <- c('CC', 'MR', 'MC') + # } else if (input$selTime == 'mid') { + # gcms <- c("BC", "CC", "CE", "CN", "HG", "IP", "MR", "ME", "MG") + # } else { + # gcms <- c("AC", "BC", "CC", "CE", "CN", "GF", "GD", "GS", "HD", + # "HG", "HE", "IN", "IP", "MI", "MR", "MC", "MP", "MG", "NO") + # } + # names(gcms) <- GCMlookup[gcms] + # gcms <- as.list(c("Select GCM" = "", gcms)) + # selectInput(ns("selGCM"), label = "Select global circulation model", + # choices = gcms) + # }) observeEvent(input$goXferExtTime, { # ERRORS #### @@ -284,49 +310,84 @@ xfer_time_module_server <- function(input, output, session, common) { "). You can not transfer to a New Time.") return() } - if(input$selTime == "") { - logger %>% writeLog(type = 'error', "Please select transfer time period.") - return() - } - if(input$selGCM == "") { - logger %>% writeLog(type = 'error', "Please select global circulation model.") - return() - } - if(input$selRCP == "") { - logger %>% writeLog(type = 'error', "Please select RCP.") - return() + + if (input$selTimeVar == 'worldclim') { + # warnings for wc selections + if(input$selTime == "") { + logger %>% writeLog(type = 'error', "Please select transfer time period.") + return() + } + if(input$selGCM == "") { + logger %>% writeLog(type = 'error', "Please select global circulation model.") + return() + } + if(input$selRCP == "") { + logger %>% writeLog(type = 'error', "Please select a SSP.") + return() + } + } else if (input$selTimeVar == 'ecoclimate') { + # warnings for ecoclimate selections + if(input$xfAOGCM == "") { + logger %>% writeLog(type = 'error', "Please select transfer AOGCM.") + return() + } + if(input$xfScenario == "") { + logger %>% writeLog(type = 'error', "Please select transfer temporal scenario.") + return() + } } + # DATA #### if (input$selTimeVar == 'worldclim') { # code taken from dismo getData() function to catch if user is trying to # download a missing combo of gcm / rcp - gcms <- c('AC', 'BC', 'CC', 'CE', 'CN', 'GF', 'GD', 'GS', 'HD', 'HG', 'HE', - 'IN', 'IP', 'MI', 'MR', 'MC', 'MP', 'MG', 'NO') - rcps <- c(26, 45, 60, 85) - m <- matrix(c(0,1,1,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,0,1,1,0,0,1,0,1,1,1,0,0,1,1,1,1,0,1,1,1,1,1,0,1, - 0,1,1,1,1,1,1,1,1,1,1,1,1,1), ncol = 4) - i <- m[which(input$selGCM == gcms), which(input$selRCP == rcps)] - if (!i) { - logger %>% - writeLog(type = 'error', - paste0('This combination of GCM and RCP is not available. Please ', - 'make a different selection.')) - return() - } + # 7/16/2024: BAJ removed after geodata & WCv2.1 update, but kept in case needed later + # gcms <- c('AC', 'BC', 'CC', 'CE', 'CN', 'GF', 'GD', 'GS', 'HD', 'HG', 'HE', + # 'IN', 'IP', 'MI', 'MR', 'MC', 'MP', 'MG', 'NO') + # rcps <- c(26, 45, 60, 85) + # m <- matrix(c(0,1,1,0,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + # 1,1,1,1,1,1,1,0,1,1,0,0,1,0,1,1,1,0,0,1,1,1,1,0,1,1,1,1,1,0,1, + # 0,1,1,1,1,1,1,1,1,1,1,1,1,1), ncol = 4) + # i <- m[which(input$selGCM == gcms), which(input$selRCP == rcps)] + # if (!i) { + # logger %>% + # writeLog(type = 'error', + # paste0('This combination of GCM and RCP is not available. Please ', + # 'make a different selection.')) + # return() + # } + smartProgress( logger, message = paste("Retrieving WorldClim data for", input$selTime, input$selRCP, "..."), { - xferTimeEnvs <- - raster::getData('CMIP5', var = "bio", res = round(envsRes * 60, 1), - rcp = input$selRCP, model = input$selGCM, - year = input$selTime) + #BAJ eventually add 'if (res > 30){, cmip6_world(), }else use{ cmip6_tile()} + xferTimeEnvs <- tryCatch(expr = geodata::cmip6_world(model = input$selGCM, + ssp = input$selRCP, + time = input$selTime, + var = "bio", + res = round(envsRes * 60, 1), + path=tempdir()), + error= function(e) NULL) + #BAJ geodata::cmip6_tile(lon, lat, model, ssp, time, var, path) for 30arcsec tile + + # trycatch error + if (is.null(xferTimeEnvs)) { + logger %>% writeLog( + type = "error", + paste0("Unable to retrieve data from WorldClim. + Server may be down. + Please use User-Specified module instead.")) + return() + } else { names(xferTimeEnvs) <- paste0('bio', c(paste0('0',1:9), 10:19)) # in case user subsetted bioclims xferTimeEnvs <- xferTimeEnvs[[names(envs())]] + # convert spatraster to raster + xferTimeEnvs <- raster::stack(xferTimeEnvs) + } } ) } else if (input$selTimeVar == 'ecoclimate') { @@ -394,11 +455,11 @@ xfer_time_module_server <- function(input, output, session, common) { } xferTimeThr <- xferTime > thr if (input$selTimeVar == 'worldclim') { - logger %>% writeLog(hlSpp(curSp()), "Transfer of model to ", paste0('20', input$selTime), + logger %>% writeLog(hlSpp(curSp()), "Transfer of model to ", input$selTime, ' with threshold ', input$threshold, ' (', formatC(thr, format = "e", 2), ") for GCM ", - GCMlookup[input$selGCM], " under RCP ", - as.numeric(input$selRCP)/10.0, ".") + input$selGCM, " under SSP ", + as.numeric(input$selRCP), ".") } else if (input$selTimeVar == 'ecoclimate') { logger %>% writeLog(hlSpp(curSp()), "Transfer of model to ", input$xfScenario, ' with threshold ', input$threshold, ' (', @@ -408,9 +469,9 @@ xfer_time_module_server <- function(input, output, session, common) { } else { xferTimeThr <- xferTime if (input$selTimeVar == 'worldclim') { - logger %>% writeLog(hlSpp(curSp()), "Transfer of model to ", paste0('20', input$selTime), - ' with ', predType, " output for GCM ", GCMlookup[input$selGCM], - " under RCP ", as.numeric(input$selRCP)/10.0, ".") + logger %>% writeLog(hlSpp(curSp()), "Transfer of model to ", input$selTime, + ' with ', predType, " output for GCM ", input$selGCM, + " under SSP ", as.numeric(input$selRCP), ".") } else if (input$selTimeVar == 'ecoclimate') { logger %>% writeLog(hlSpp(curSp()), "Transfer of model to ", input$xfScenario, ' with ', predType, " output for GCM ", input$xfAOGCM, ".") @@ -426,7 +487,7 @@ xfer_time_module_server <- function(input, output, session, common) { spp[[curSp()]]$transfer$mapXfer <- xferTimeThr spp[[curSp()]]$transfer$mapXferVals <- getRasterVals(xferTimeThr, predType) if (input$selTimeVar == "worldclim") { - spp[[curSp()]]$transfer$xfEnvsDl <- paste0('CMIP5_', envsRes * 60, "min_RCP", + spp[[curSp()]]$transfer$xfEnvsDl <- paste0('CMIP5_', envsRes * 60, "min_SSP", input$selRCP, "_", input$selGCM, "_", input$selTime) } else if (input$selTimeVar == "ecoclimate") { @@ -451,7 +512,7 @@ xfer_time_module_server <- function(input, output, session, common) { spp[[curSp()]]$rmm$data$transfer$environment1$extentRule <- "transfer to user-selected new time" if (input$selTimeVar == "worldclim") { - xferYr <- paste0('20', input$selTime) + xferYr <- input$selTime ###For RMD only spp[[curSp()]]$rmm$code$wallace$transfer_worldclim <- TRUE spp[[curSp()]]$rmm$code$wallace$transfer_GCM <- input$selGCM @@ -460,11 +521,11 @@ xfer_time_module_server <- function(input, output, session, common) { spp[[curSp()]]$rmm$data$transfer$environment1$yearMin <- xferYr spp[[curSp()]]$rmm$data$transfer$environment1$yearMax <- xferYr - spp[[curSp()]]$rmm$data$transfer$environment1$sources <- "WorldClim 1.4" + spp[[curSp()]]$rmm$data$transfer$environment1$sources <- "WorldClim 2.1" spp[[curSp()]]$rmm$data$transfer$environment1$notes <- paste("transfer to year", xferYr, "for GCM", - GCMlookup[input$selGCM], "under RCP", - as.numeric(input$selRCP)/10.0) + input$selGCM, "under SSP", + as.numeric(input$selRCP)) } else if (input$selTimeVar == "ecoclimate") { spp[[curSp()]]$rmm$code$wallace$transfer_ecoclimate <- TRUE spp[[curSp()]]$rmm$code$wallace$transfer_AOGCM <- input$xfAOGCM diff --git a/inst/shiny/modules/xfer_time.Rmd b/inst/shiny/modules/xfer_time.Rmd index 7bcba89f6..e5b6ab3d5 100644 --- a/inst/shiny/modules/xfer_time.Rmd +++ b/inst/shiny/modules/xfer_time.Rmd @@ -1,21 +1,23 @@ ```{asis, echo = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, eval = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}} ### Transfer model -Transferring the model to the same modelling area with no threshold rule. New time based on "{{envs_name_rmd}}" variables for {{yearMin_rmd}} using a "{{model_rmd}}" GCM and an RCP of *`r {{rcp_rmd}}/10`*. +Transferring the model to the same modelling area with no threshold rule. New time based on {{envs_name_rmd}} variables for {{yearMin_rmd}} using a {{model_rmd}} GCM and an SSP of {{rcp_rmd}}. ``` ```{r, echo = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}} #Download variables for transferring -xferTimeEnvs_{{spAbr}} <- raster::getData( - 'CMIP5', +xferTimeEnvs_{{spAbr}} <- geodata::cmip6_world( + model = "{{model_rmd}}", + ssp = "{{rcp_rmd}}", + time = "{{year_rmd}}", var = "bio", res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), - rcp = {{rcp_rmd}}, - model = "{{model_rmd}}", - year = {{year_rmd}}) + path = tempdir()) names(xferTimeEnvs_{{spAbr}}) <- paste0('bio', c(paste0('0',1:9), 10:19)) # Select variables for transferring to match variables used for modelling xferTimeEnvs_{{spAbr}} <- xferTimeEnvs_{{spAbr}}[[names(bgMask_{{spAbr}})]] +# Convert to rasterstack +xferTimeEnvs_{{spAbr}} <- raster::stack(xferTimeEnvs_{{spAbr}}) # Generate a transfer of the model to the desired area and time xfer_time_{{spAbr}} <-xfer_time( @@ -58,22 +60,24 @@ m %>% ```{asis, echo = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, eval = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}} ### Transfer model -Transferring the model to the same modelling area with a "{{xfer_thresholdRule_rmd}}" threshold rule of {{xfer_threshold_rmd}}. New time based on "{{envs_name_rmd}}" variables for {{yearMin_rmd}} using a "{{model_rmd}}" GCM and an RCP of *`r {{rcp_rmd}}/10`*. +Transferring the model to the same modelling area with a "{{xfer_thresholdRule_rmd}}" threshold rule of {{xfer_threshold_rmd}}. New time based on {{envs_name_rmd}} variables for {{yearMin_rmd}} using a {{model_rmd}} GCM and an SSP of {{rcp_rmd}}. ``` ```{r, echo = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}} #Download variables for transferring -xferTimeEnvs_{{spAbr}} <- raster::getData( - 'CMIP5', +xferTimeEnvs_{{spAbr}} <- geodata::cmip6_world( + model = "{{model_rmd}}", + ssp = "{{rcp_rmd}}", + time = "{{year_rmd}}", var = "bio", res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), - rcp = {{rcp_rmd}}, - model = "{{model_rmd}}", - year = {{year_rmd}}) + path = tempdir()) names(xferTimeEnvs_{{spAbr}}) <- paste0('bio', c(paste0('0',1:9), 10:19)) # Select variables for transferring to match variables used for modelling xferTimeEnvs_{{spAbr}} <- xferTimeEnvs_{{spAbr}}[[names(bgMask_{{spAbr}})]] +# Convert to rasterstack +xferTimeEnvs_{{spAbr}} <- raster::stack(xferTimeEnvs_{{spAbr}}) # Generate a transfer of the model to the desired area and time xfer_time_{{spAbr}} <-xfer_time( @@ -126,22 +130,24 @@ m %>% ```{asis, echo = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, eval = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}} ### Transfer model -Transferring the model to a user drawn area with no threshold. New time based on "{{envs_name_rmd}}" variables for {{yearMin_rmd}} using a "{{model_rmd}}" GCM and an RCP of *`r {{rcp_rmd}}/10`*. +Transferring the model to a user drawn area with no threshold. New time based on {{envs_name_rmd}} variables for {{yearMin_rmd}} using a {{model_rmd}} GCM and an SSP of {{rcp_rmd}}. ``` ```{r, echo = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}} #Download variables for transferring -xferTimeEnvs_{{spAbr}} <- raster::getData( - 'CMIP5', +xferTimeEnvs_{{spAbr}} <- geodata::cmip6_world( + model = "{{model_rmd}}", + ssp = "{{rcp_rmd}}", + time = "{{year_rmd}}", var = "bio", res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), - rcp = {{rcp_rmd}}, - model = "{{model_rmd}}", - year = {{year_rmd}}) + path = tempdir()) names(xferTimeEnvs_{{spAbr}}) <- paste0('bio', c(paste0('0',1:9), 10:19)) # Select variables for transferring to match variables used for modelling xferTimeEnvs_{{spAbr}} <- xferTimeEnvs_{{spAbr}}[[names(bgMask_{{spAbr}})]] +# Convert to rasterstack +xferTimeEnvs_{{spAbr}} <- raster::stack(xferTimeEnvs_{{spAbr}}) # Generate the area of transfer according to the drawn polygon in the GUI xfer_draw_{{spAbr}} <-xfer_draw( @@ -191,22 +197,24 @@ m %>% ```{asis, echo = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, eval = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}} ### Transfer model -Transferring the model to a user drawn area with a "{{xfer_thresholdRule_rmd}}" threshold rule of {{xfer_threshold_rmd}}. New time based on "{{envs_name_rmd}}" variables for {{yearMin_rmd}} using a "{{model_rmd}}" GCM and an RCP of *`r {{rcp_rmd}}/10`*. +Transferring the model to a user drawn area with a "{{xfer_thresholdRule_rmd}}" threshold rule of {{xfer_threshold_rmd}}. New time based on {{envs_name_rmd}} variables for {{yearMin_rmd}} using a {{model_rmd}} GCM and an SSP of {{rcp_rmd}}. ``` ```{r, echo = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & !xfer_time_user_knit & xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}} #Download variables for transferring -xferTimeEnvs_{{spAbr}} <- raster::getData( - 'CMIP5', - var = "bio", - res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), - rcp = {{rcp_rmd}}, +xferTimeEnvs_{{spAbr}} <- geodata::cmip6_world( model = "{{model_rmd}}", - year = {{year_rmd}}) + ssp = "{{rcp_rmd}}", + time = "{{year_rmd}}", + var = "bio", + res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), + path = tempdir()) names(xferTimeEnvs_{{spAbr}}) <- paste0('bio', c(paste0('0',1:9), 10:19)) # Select variables for transferring to match variables used for modelling xferTimeEnvs_{{spAbr}} <- xferTimeEnvs_{{spAbr}}[[names(bgMask_{{spAbr}})]] +# Convert to rasterstack +xferTimeEnvs_{{spAbr}} <- raster::stack(xferTimeEnvs_{{spAbr}}) # Generate the area of transfer according to the drawn polygon in the GUI xfer_draw_{{spAbr}} <-xfer_draw( @@ -264,24 +272,25 @@ m %>% ```{asis, echo = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, eval = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}} ### Transfer model -Transferring the model to a user provided area area with no threshold. New time based on "{{envs_name_rmd}}" variables for {{yearMin_rmd}} using a "{{model_rmd}}" GCM and an RCP of *`r {{rcp_rmd}}/10`*. +Transferring the model to a user provided area area with no threshold. New time based on {{envs_name_rmd}} variables for {{yearMin_rmd}} using a {{model_rmd}} GCM and an SSP of {{rcp_rmd}}. ``` ```{r, echo = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & !xfer_time_threshold_knit & xfer_time_worldclim_knit}}} # Download variables for transferring -xferTimeEnvs_{{spAbr}} <- raster::getData( - 'CMIP5', - var = "bio", - res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), - rcp = {{rcp_rmd}}, +xferTimeEnvs_{{spAbr}} <- geodata::cmip6_world( model = "{{model_rmd}}", - year = {{year_rmd}}) + ssp = "{{rcp_rmd}}", + time = "{{year_rmd}}", + var = "bio", + res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), + path = tempdir()) names(xferTimeEnvs_{{spAbr}}) <- paste0('bio', c(paste0('0',1:9), 10:19)) - # Select variables for transferring to match variables used for modelling xferTimeEnvs_{{spAbr}} <- xferTimeEnvs_{{spAbr}}[[names(bgMask_{{spAbr}})]] +# Convert to rasterstack +xferTimeEnvs_{{spAbr}} <- raster::stack(xferTimeEnvs_{{spAbr}}) # Generate the area of transfer based on user provided files ##User must input the path to shapefile or csv file and the file name @@ -332,24 +341,25 @@ m %>% ```{asis, echo = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, eval = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}} ### Transfer model -Transferring the model to a user provided area with a "{{xfer_thresholdRule_rmd}}" threshold rule of {{xfer_threshold_rmd}}. New time based on "{{envs_name_rmd}}" variables for {{yearMin_rmd}} using a "{{model_rmd}}" GCM and an RCP of *`r {{rcp_rmd}}/10`*. +Transferring the model to a user provided area with a "{{xfer_thresholdRule_rmd}}" threshold rule of {{xfer_threshold_rmd}}. New time based on {{envs_name_rmd}} variables for {{yearMin_rmd}} using a {{model_rmd}} GCM and an SSP of {{rcp_rmd}}. ``` ```{r, echo = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}, include = {{xfer_time_knit & xfer_time_user_knit & !xfer_time_drawn_knit & xfer_time_threshold_knit & xfer_time_worldclim_knit}}} # Download variables for transferring from Worldclim -xferTimeEnvs_{{spAbr}} <- raster::getData( - 'CMIP5', - var = "bio", - res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), - rcp = {{rcp_rmd}}, - model = "{{model_rmd}}", - year = {{year_rmd}}) +xferTimeEnvs_{{spAbr}} <- geodata::cmip6_world( + model = "{{model_rmd}}", + ssp = "{{rcp_rmd}}", + time = "{{year_rmd}}", + var = "bio", + res = round((raster::res(bgMask_{{spAbr}}) * 60)[1],1), + path = tempdir()) names(xferTimeEnvs_{{spAbr}}) <- paste0('bio', c(paste0('0',1:9), 10:19)) - # Select variables for transferring to match variables used for modelling xferTimeEnvs_{{spAbr}} <- xferTimeEnvs_{{spAbr}}[[names(bgMask_{{spAbr}})]] +# Convert to rasterstack +xferTimeEnvs_{{spAbr}} <- raster::stack(xferTimeEnvs_{{spAbr}}) # Generate the area of transfer based on user provided files ##User must input the path to shapefile or csv file and the file name diff --git a/inst/shiny/modules/xfer_time.md b/inst/shiny/modules/xfer_time.md index 06ab41442..9a16bbe51 100644 --- a/inst/shiny/modules/xfer_time.md +++ b/inst/shiny/modules/xfer_time.md @@ -4,16 +4,14 @@ In simple terms, applying or “transferring” a niche/distributional model to a region or time period different from the ones used to make the model involves making a prediction based on the model and the new values of the predictor variables. In reality, however, researchers should be cognizant of many possible pitfalls, including non-analog conditions (e.g., requiring extrapolation in environmental space; see **Component: Build and Evaluate Niche Model**) and heterogeneity in the effects of species interactions (Fitzpatrick and Hargrove 2009; Anderson 2013). -To predict to different times, datasets describing environmental variables in these times are needed. Global circulation models (GCMs) provide estimates for climate for both the past and future. Various GCMs may have disparate estimates because they are based on different assumptions. Wallace currently uses future climate data for 2050 and 2070 from the IPCC fifth assessment report (AR5) climate projections based on the user’s selection of WorldClim or ecoClimate source variables. The four Representative Concentration Pathways (RCPs) available (RCP2.6, RCP4.5, RCP6.0, and RCP8.5) span a range of climate change scenarios from different greenhouse gas emission outcomes. More information on climate change models can be found here (Hausfather 2019). - -NOTE: The IPCC sixth assessment report replaced the use of RCPs with Shared Socioeconomic Pathways (SSPs). The user should note that Wallace uses the terminology associated with AR5, but future versions, as well as other source material, may mention SSPs. +To predict to different times, datasets describing environmental variables in these times are needed. Global circulation models (GCMs) provide estimates for climate for both the past and future. Various GCMs may have disparate estimates because they are based on different assumptions. Wallace currently uses future climate data based on the user’s selection of WorldClim or ecoClimate source variables. For WorldClim, CMIP6 downscaled future climate projections are available via WorldClim v2.1. Some climate projections use the four Representative Concentration Pathways (RCPs) available (RCP2.6, RCP4.5, RCP6.0, and RCP8.5), which span a range of climate change scenarios from different greenhouse gas emission outcomes. Others use Shared Socio-economic Pathways (SSPs; 126, 245, 370 and 585). More information on climate change models can be found here (Hausfather 2019). **IMPLEMENTATION** -This module relies on functionality for model prediction grids from the R package `dismo` (Hijmans et al. 2020). +This module relies on functionality for model prediction grids from the R package `dismo` (Hijmans et al. 2020) and `geodata` for accessing climate data ((Hijmans et al. 2024). Users must first select a model. Depending on the ENMeval (Kass et al. 2021) settings selected in **Component: Build and Evaluate Niche Model**, there may be multiple choices for Maxent. For Step 1, users choose their study region. This is done by drawing a polygon, choosing to use the same extent as the model prediction, or uploading a polygon. The uploaded polygon must be a shapefile (include .shp, .shx, and .dbf) or a CSV file with field order (longitude, latitude). Once the study region has been delimited, “Create” chooses this extent for all transfer operations. -In Step 2, users must then select a time period to transfer and the source of variables (Worldclim or ecoClimate). The WorldClim option allows users to select a time period (year 2050 or 2070), and also a GCM and RCP that estimates the future climate. Using ecoClimate lets users select the Atmospheric Oceanic General Circulation Model and the temporal scenario (2080-2100 at different RCPs, Holocene, or LGM). +In Step 2, users must then select a time period to transfer and the source of variables (Worldclim or ecoClimate). The WorldClim option allows users to select a time period (year 2050 or 2070), and also a GCM and RCP that estimates the future climate. Note, three GCMs (FIO-ESM-2-0, GFDL-ESM4, & HadGEM3-GC31-LL) are excluded due to unavailibility for all SSP options. Using ecoClimate lets users select the Atmospheric Oceanic General Circulation Model and the temporal scenario (2080-2100 at different RCPs, Holocene, or LGM). “Transfer” calculates the modeled response for the predictor variable values for each cell of the selected extent and plots the prediction on the map. Users can download the prediction as either raster grid types for analysis (.asc, .grd and .tif), or as an image file (.png). @@ -30,5 +28,7 @@ Hausfather, Z. (2019). CMIP6: the next generation of climate models explained. C Hijmans, R.J., Phillips, S., Leathwick, J., & Elith, J. (2020). dismo: Species Distribution Modeling. R package version 1.3-3. CRAN +Hijmans, R.J., et al. (2024). geodata: Download Geographic Data. R package version 0.6-2. CRAN + Kass, J., Muscarella, R., Galante, P.J., Bohl, C.L., Pinilla-Buitrago, G.E., Boria, R.A., Soley-Guardia, M., & Anderson, R.P. (2021). ENMeval: Automated Tuning and Evaluations of Ecological Niche Models. R package version 2.0 CRAN diff --git a/inst/shiny/modules/xfer_time.yml b/inst/shiny/modules/xfer_time.yml index 9408ed7c7..e35f9c0eb 100644 --- a/inst/shiny/modules/xfer_time.yml +++ b/inst/shiny/modules/xfer_time.yml @@ -2,4 +2,4 @@ component: "xfer" short_name: "Transfer to New Time" long_name: "Transfer to New Time" authors: "Jamie M. Kass, Bruno Vilela, Gonzalo E. Pinilla-Buitrago, Bethany A. Johnson, Robert P. Anderson" -package: [dismo] +package: [geodata, dismo] diff --git a/inst/shiny/modules/xfer_user.R b/inst/shiny/modules/xfer_user.R index 47eae8234..c93b84ac9 100644 --- a/inst/shiny/modules/xfer_user.R +++ b/inst/shiny/modules/xfer_user.R @@ -1,6 +1,6 @@ # Wallace EcoMod: a flexible platform for reproducible modeling of # species niches and distributions. -# +# # xfer_user.R # File author: Wallace EcoMod Dev Team. 2023. # -------------------------------------------------------------------------- @@ -107,7 +107,7 @@ xfer_user_module_server <- function(input, output, session, common) { ns <- session$ns req(curSp(), evalOut()) if (spp[[curSp()]]$rmm$model$algorithms != "BIOCLIM") { - h5("Prediction output is the same than Visualize component") + h5("Prediction output is the same as Visualize component") } }) diff --git a/inst/shiny/server.R b/inst/shiny/server.R index 985f9c1a6..bcaba58bc 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -842,9 +842,9 @@ function(input, output, session) { thresholdRule <- rmm()$prediction$binary$thresholdRule predType <- rmm()$prediction$notes if (thresholdRule == 'none') { - paste0(curSp(), "_", predType, '.', ext) + paste0(curSp(), "_", curModel(), "_", predType, '.', ext) } else { - paste0(curSp(), "_", thresholdRule, '.', ext) + paste0(curSp(), "_", curModel(), "_", thresholdRule, '.', ext) } }, content = function(file) { diff --git a/inst/shiny/www/img/daniel.jpeg b/inst/shiny/www/img/daniel.jpeg new file mode 100644 index 000000000..faf7d43fd Binary files /dev/null and b/inst/shiny/www/img/daniel.jpeg differ diff --git a/inst/shiny/www/img/hannahO.jpeg b/inst/shiny/www/img/hannahO.jpeg new file mode 100644 index 000000000..cf41bad4d Binary files /dev/null and b/inst/shiny/www/img/hannahO.jpeg differ diff --git a/inst/shiny/www/img/hannahO.png b/inst/shiny/www/img/hannahO.png deleted file mode 100644 index d478bb1d4..000000000 Binary files a/inst/shiny/www/img/hannahO.png and /dev/null differ diff --git a/inst/shiny/www/img/valentina.jpeg b/inst/shiny/www/img/valentina.jpeg new file mode 100644 index 000000000..6abd4cbff Binary files /dev/null and b/inst/shiny/www/img/valentina.jpeg differ diff --git a/inst/shiny/www/img/valentina.png b/inst/shiny/www/img/valentina.png deleted file mode 100644 index 86b45f0a6..000000000 Binary files a/inst/shiny/www/img/valentina.png and /dev/null differ diff --git a/man/envs_worldclim.Rd b/man/envs_worldclim.Rd index fcc5e7b10..9741b053e 100644 --- a/man/envs_worldclim.Rd +++ b/man/envs_worldclim.Rd @@ -45,10 +45,12 @@ arcmin10 <- envs_worldclim(bcRes, bcSel = envar) } \seealso{ -\code{\link[raster]{getData}} +\code{\link[geodata]{worldclim_global}}, \code{\link[geodata]{worldclim_tile}} } \author{ Jamie Kass Gonzalo E. Pinilla-Buitrago + +Bethany A. Johnson } diff --git a/man/model_bioclim.Rd b/man/model_bioclim.Rd index 960fabd7a..ef316188c 100644 --- a/man/model_bioclim.Rd +++ b/man/model_bioclim.Rd @@ -57,7 +57,7 @@ m <- model_bioclim(occs, bg, partblock, envs) \code{\link[ENMeval]{ENMevaluate}} } \author{ -Jamie M. Kass +Jamie M. Kass Gonzalo E. Pinilla-Buitrago } diff --git a/man/model_maxent.Rd b/man/model_maxent.Rd index 6a2e5ac47..5a443d9a3 100644 --- a/man/model_maxent.Rd +++ b/man/model_maxent.Rd @@ -101,7 +101,7 @@ m <- model_maxent(occs = occs, bg = bg, user.grp = partblock, \code{\link[ENMeval]{ENMevaluate}} } \author{ -Jamie M. Kass +Jamie M. Kass Gonzalo E. Pinilla-Buitrago } diff --git a/man/run_wallace.Rd b/man/run_wallace.Rd index 90c5c9277..440f8bd01 100644 --- a/man/run_wallace.Rd +++ b/man/run_wallace.Rd @@ -34,7 +34,7 @@ run_wallace() } } \author{ -Jamie Kass +Jamie Kass Gonzalo E. Pinilla-Buitrago } diff --git a/man/vis_bioclimPlot.Rd b/man/vis_bioclimPlot.Rd index 8bb4d8f30..51f557faf 100644 --- a/man/vis_bioclimPlot.Rd +++ b/man/vis_bioclimPlot.Rd @@ -61,7 +61,7 @@ bioclimPlot <- vis_bioclimPlot(x = m@models$bioclim, \code{\link{model_bioclim}} \code{\link[ENMeval]{ENMevaluate}} } \author{ -Jamie Kass +Jamie Kass Gonzalo E. Pinilla-Buitrago } diff --git a/man/xfer_area.Rd b/man/xfer_area.Rd index 476f9429f..2b6513592 100644 --- a/man/xfer_area.Rd +++ b/man/xfer_area.Rd @@ -94,9 +94,11 @@ modXfer <- xfer_area(evalOut = m, curModel = 1, envs, \code{\link{xfer_userEnvs}} } \author{ -Jamie Kass +Jamie Kass Andrea Paz Gonzalo E. Pinilla-Buitrago + +Bethany A. Johnson } diff --git a/man/xfer_mess.Rd b/man/xfer_mess.Rd index 681863777..3b14f2217 100644 --- a/man/xfer_mess.Rd +++ b/man/xfer_mess.Rd @@ -65,7 +65,7 @@ xferMess <- xfer_mess(occs = occsEnvs, bg = bgEnvs, bgMsk = envs, \code{\link{xfer_userEnvs}} } \author{ -Jamie Kass +Jamie Kass Gonzalo E. Pinilla-Buitrago } diff --git a/man/xfer_time.Rd b/man/xfer_time.Rd index 07336a301..2f187e211 100644 --- a/man/xfer_time.Rd +++ b/man/xfer_time.Rd @@ -103,9 +103,11 @@ modXfer <- xfer_time(evalOut = m, curModel = 1, \code{\link{xfer_userEnvs}} } \author{ -Jamie Kass +Jamie Kass Andrea Paz Gonzalo E. Pinilla-Buitrago + +Bethany A. Johnson } diff --git a/man/xfer_userEnvs.Rd b/man/xfer_userEnvs.Rd index 35a674807..7f43385bb 100644 --- a/man/xfer_userEnvs.Rd +++ b/man/xfer_userEnvs.Rd @@ -88,9 +88,11 @@ modXfer <- xfer_userEnvs(evalOut = m, curModel = 1, envs = envsFut, \code{\link{xfer_userExtent}} } \author{ -Jamie Kass +Jamie Kass Andrea Paz Gonzalo E. Pinilla-Buitrago + +Bethany A. Johnson } diff --git a/tests/testthat/test_occs_queryDb.R b/tests/testthat/test_occs_queryDb.R index 4a0d95f71..7687258b8 100755 --- a/tests/testthat/test_occs_queryDb.R +++ b/tests/testthat/test_occs_queryDb.R @@ -100,11 +100,9 @@ test_that("output data checks", { if ((TRUE %in% duplicated(out.gbif[[i]]$orig[, c('longitude', 'latitude')])) | (NA %in% out.gbif[[i]]$orig[, c('longitude', 'latitude')])) { # the cleaned table must have fewer records than the original one - expect_true((nrow(out.gbif[[i]]$orig)) > (nrow(out.gbif[[i]]$cleaned))) - } else { # if not, - # both tables should have the same number of records - expect_true((nrow(out.gbif[[i]]$orig)) == (nrow(out.gbif[[i]]$cleaned))) - } + # if not, both tables should have the same number of records + expect_true((nrow(out.gbif[[i]]$orig)) >= (nrow(out.gbif[[i]]$cleaned))) + } # there are not "NA" values in longitude OR latitude columns in the cleaned table expect_false(NA %in% out.gbif[[i]]$cleaned$latitude) | (NA %in% out.gbif[[i]]$cleaned$longitude) diff --git a/vignettes/tutorial-v1.Rmd b/vignettes/tutorial-v1.Rmd index cee17b2d4..f4e9a6cda 100644 --- a/vignettes/tutorial-v1.Rmd +++ b/vignettes/tutorial-v1.Rmd @@ -26,9 +26,9 @@ This vignette was written for *Wallace* v. 1.0.5, so if you are using a differen # Introduction *Wallace* is an `R`-based GUI application for ecological modeling that currently focuses on building, evaluating, and visualizing models of species niches and distributions. We will refer to these models as species distribution models (SDMs), and we will not explain them at length here---as you read through, you will be pointed to some sources of detailed info within the application for reference. -*Wallace* has many qualities which we think make it a good example of next-generation scientific software: it's 1) open, 2) expandable, 3) flexible, 4) interactive, 5) instructive, and 6) reproducible. The application features a pannable/zoomable map and dynamic plots and tables. Data for the models can be downloaded from online databases or uploaded by the user. Most results can be downloaded, including the option to save R code that can reproduce your analysis. For more details, including on SDMs, please see our [publication](http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12945/full) in *Methods in Ecology and Evolution*. The citation is below: +*Wallace* has many qualities which we think make it a good example of next-generation scientific software: it's 1) open, 2) expandable, 3) flexible, 4) interactive, 5) instructive, and 6) reproducible. The application features a pannable/zoomable map and dynamic plots and tables. Data for the models can be downloaded from online databases or uploaded by the user. Most results can be downloaded, including the option to save R code that can reproduce your analysis. For more details, including on SDMs, please see our [publication](https://doi.org/10.1111/2041-210X.12945) in *Methods in Ecology and Evolution*. The citation is below: -Kass JM, Vilela B, Aiello-Lammens ME, Muscarella R, Merow C, Anderson RP. (2018). *Wallace*: A flexible platform for reproducible modeling of species niches and distributions built for community expansion. *Methods in Ecology and Evolution*. 9:1151-1156. https://doi-org.ezproxy.gc.cuny.edu/10.1111/2041-210X.12945 +Kass JM, Vilela B, Aiello-Lammens ME, Muscarella R, Merow C, Anderson RP. (2018). *Wallace*: A flexible platform for reproducible modeling of species niches and distributions built for community expansion. *Methods in Ecology and Evolution*. 9:1151-1156. DOI:10.1111/2041-210X.12945 The *Wallace* project's [main page](https://wallaceecomod.github.io/) has links to the [Google Group](https://groups.google.com/forum/#!forum/wallaceecomod), the official [email](mailto:wallaceecomod@gmail.com), the [CRAN page](https://CRAN.R-project.org/package=wallace) hosting the stable version, and the [Github development page](https://github.com/wallaceEcoMod/wallace).