Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wallace
Version: 2.1.3
Date: 2024-07-18
Version: 2.2.0
Date: 2025-03-06
Title: A Modular Platform for Reproducible Modeling of Species Niches
and Distributions
Description: The 'shiny' application Wallace is a modular platform for
Expand All @@ -13,6 +13,7 @@ Description: The 'shiny' application Wallace is a modular platform for
website: <https://wallaceecomod.github.io/wallace/articles/tutorial-v2.html>.
Authors@R:
c(person("Bethany A.", "Johnson", email = "bjohnso005@citymail.cuny.edu", role = "aut"),
person("Daniel F.", "Lopez-Lozano", email = "dlopezlozano@amnh.org", 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"),
Expand All @@ -38,7 +39,7 @@ Imports:
dplyr (>= 1.0.2),
DT (>= 0.5),
ecospat (>= 4.0.0),
ENMeval (>= 2.0.3),
ENMeval (>= 2.0.5),
geodata,
knitcitations,
leafem,
Expand Down Expand Up @@ -67,6 +68,7 @@ Suggests:
mapview,
maxnet,
occCite,
predicts,
rangeModelMetadata,
raster,
rgbif (>= 3.3.0),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wallace 2.2.0
=============
- updated for ENMeval v2.0.5 functionality
- updated module skeleton & module addition vignette to include `knitcitations` for References
- RPA edits to guidance texts

wallace 2.1.3
=============
- Fixed NULL error in poccs_selectOccs Rmd code
Expand Down
3 changes: 2 additions & 1 deletion R/model_bioclim.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

#' @author Jamie M. Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Bethany A. Johnson <bjohnso005@@citymail.cuny.edu>
# @note

#' @seealso \code{\link[ENMeval]{ENMevaluate}}
Expand All @@ -79,7 +80,7 @@ model_bioclim <- function(occs, bg, user.grp, bgMsk, logger = NULL,
smartProgress(logger,
message = paste0("Building/Evaluating BIOCLIM model for ",
spName(spN), "..."), {
e <- ENMeval::ENMevaluate(occs = occs.xy, envs = bgMsk, bg = bg.xy,
e <- ENMeval::ENMevaluate(occs = occs.xy, envs = terra::rast(bgMsk), bg = bg.xy,
algorithm = "bioclim", partitions = "user",
user.grp = user.grp)
})
Expand Down
5 changes: 3 additions & 2 deletions R/model_maxent.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#' and a selection of appropriate fields.
#' @author Jamie M. Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Bethany A. Johnson <bjohnso005@@citymail.cuny.edu>
# @note

#' @seealso \code{\link[ENMeval]{ENMevaluate}}
Expand Down Expand Up @@ -196,14 +197,14 @@ model_maxent <- function(occs, bg, user.grp, bgMsk, rms, rmsStep, fcs,
bg = as.data.frame(bg.xy),
partitions = 'user',
user.grp = user.grp,
envs = bgMsk,
envs = terra::rast(bgMsk),
tune.args = tune.args,
doClamp = clampSel,
algorithm = algMaxent,
categoricals = catEnvs,
parallel = parallel,
numCores = numCores,
parallelType = "doSNOW",
# parallelType = "doSNOW",
# taxon.name = NULL,
# user.enm = NULL,
# occs.ind = NULL,
Expand Down
18 changes: 10 additions & 8 deletions R/part_partitionOccs.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
#' (1) 'jack' Non-spatial Partition - jackknife \cr
#' (2) 'rand' Non-spatial Partition - random k-fold \cr
#' (3) 'block' spatial Partition - block \cr
#' (4) 'cb1' spatial Partition - checkerboard 1 (K=2) \cr
#' (5) 'cb2' spatial Partition - checkerboard 2 (K=4) \cr
#' (4) 'cb1' spatial Partition - checkerboard (k=2) \cr
#' (5) 'cb2' spatial Partition - hierarchical checkerboard (k=4) \cr
#' @param kfolds numeric. Number of partitions to create if selected method is
#' random k-fold (must be >=2). If other method then keep default of NULL.
#' @param bgMask a RasterStack or a RasterBrick of environmental layers cropped
Expand Down Expand Up @@ -75,6 +75,7 @@
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Andrea Paz <paz.andreita@@gmail.com>
#' @author Bethany A Johnson <bjohnso005@@citymail.cuny.edu>
# @note
#' @seealso \code{\link[ENMeval]{partitions}}
# @references
Expand Down Expand Up @@ -163,22 +164,23 @@ part_partitionOccs <- function(occs, bg, method, kfolds = NULL, bgMask = NULL,

if(method == 'cb1') {
smartProgress(logger, message = "Aggregating rasters...", {
group.data <- ENMeval::get.checkerboard1(occs.xy, bgMask, bg.xy, aggFact)
group.data <- ENMeval::get.checkerboard(occs.xy, terra::rast(bgMask), bg.xy, aggFact)
})

logger %>% writeLog(hlSpp(spN),
"Occurrences partitioned by checkerboard 1 method with ",
"aggregation factor ", aggFact, ".")
"Occurrences partitioned by checkerboard method with ",
"aggregation factor of ", aggFact, ".")
}

if(method == 'cb2') {
smartProgress(logger, message = "Aggregating rasters...", {
group.data <- ENMeval::get.checkerboard2(occs.xy, bgMask, bg.xy, aggFact)
group.data <- ENMeval::get.checkerboard(occs.xy, terra::rast(bgMask),
bg.xy, c(aggFact, aggFact))
})

logger %>% writeLog(hlSpp(spN),
"Occurrences partitioned by checkerboard 2 method with ",
"aggregation factor ", aggFact, ".")
"Occurrences partitioned by hierarchical checkerboard method with ",
"aggregation factor of ", aggFact, ".")
}
return(group.data)
}
1 change: 1 addition & 0 deletions R/vis_bioclimPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#' more variables are plotted as orange triangles.
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
#' @author Bethany A. Johnson <bjohnso005@@citymail.cuny.edu>
# @note
#' @seealso
#'\code{\link{model_bioclim}} \code{\link[ENMeval]{ENMevaluate}}
Expand Down
27 changes: 18 additions & 9 deletions R/xfer_area.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,22 @@
#' polyExt <-
#' sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(selCoords)),
#' ID = 1)))
#' # load model
#' m <- readRDS(system.file("extdata/model.RDS",
#' package = "wallace"))
#' # build model
#' occs <- read.csv(system.file("extdata/Bassaricyon_alleni.csv",
#' package = "wallace"))
#' bg <- read.csv(system.file("extdata/Bassaricyon_alleni_bgPoints.csv",
#' package = "wallace"))
#' partblock <- part_partitionOccs(occs, bg, method = 'block')
#' m <- model_maxent(occs, bg,
#' user.grp = partblock,
#' bgMsk = envs, rms = c(1:2),
#' rmsStep = 1, fcs = c('L', 'LQ'),
#' clampSel = TRUE,
#' algMaxent = "maxnet",
#' parallel = FALSE)
#' ### run function
#' modXfer <- xfer_area(evalOut = m, curModel = 1, envs,
#' outputType = 'cloglog', alg = 'maxent.jar',
#' outputType = 'cloglog', alg = 'maxnet',
#' clamp = TRUE, xfExt = polyExt)
#' }
#'
Expand Down Expand Up @@ -117,18 +128,16 @@ xfer_area <- function(evalOut, curModel, envs, xfExt, alg, outputType = NULL,

smartProgress(logger, message = 'Transferring model to new area...', {
if (alg == 'BIOCLIM') {
modXferArea <- dismo::predict(evalOut@models[[curModel]], xferMsk,
useC = FALSE)
modXferArea <- dismo::predict(evalOut@models[[curModel]], terra::rast(xferMsk))
} else if (alg == 'maxnet') {
if (outputType == "raw") outputType <- "exponential"
modXferArea <- predictMaxnet(evalOut@models[[curModel]], xferMsk,
type = outputType, clamp = clamp)
} else if (alg == 'maxent.jar') {
modXferArea <- dismo::predict(
evalOut@models[[curModel]], xferMsk,
evalOut@models[[curModel]], terra::rast(xferMsk),
args = c(paste0("outputformat=", outputType),
paste0("doclamp=", tolower(as.character(clamp)))),
na.rm = TRUE)
paste0("doclamp=", tolower(as.character(clamp)))))
}
})

Expand Down
20 changes: 11 additions & 9 deletions R/xfer_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,21 @@
#' selCoords <- matrix(c(longitude, latitude), byrow = FALSE, ncol = 2)
#' polyExt <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(selCoords)),
#' ID = 1)))
#' # load model
#' m <- readRDS(system.file("extdata/model.RDS",
#' package = "wallace"))
#' # build model
#' occs <- read.csv(system.file("extdata/Bassaricyon_alleni.csv",package = "wallace"))
#' bg <- read.csv(system.file("extdata/Bassaricyon_alleni_bgPoints.csv", package = "wallace"))
#' partblock <- part_partitionOccs(occs, bg, method = 'block')
#' m <- model_maxent(occs, bg, user.grp = partblock, bgMsk = envs, rms = c(1:2),
#' rmsStep = 1, fcs = c('L', 'LQ'),
#' clampSel = TRUE, algMaxent = "maxnet", parallel = FALSE)
#' occsEnvs <- m@@occs
#' bgEnvs <- m@@bg
#' envsFut <- list.files(path = system.file('extdata/wc/future',
#' package = "wallace"),
#' full.names = TRUE)
#' envsFut <- raster::stack(envsFut)
#' modXfer <- xfer_time(evalOut = m, curModel = 1,
#' envs = envsFut, alg = 'maxent.jar',
#' envs = envsFut, alg = 'maxnet',
#' xfExt = polyExt, clamp = FALSE, outputType = 'cloglog')
#' }

Expand Down Expand Up @@ -129,18 +133,16 @@ xfer_time <- function(evalOut, curModel, envs, xfExt, alg, outputType = NULL,
logger,
message = ("Transferring to new time..."), {
if (alg == 'BIOCLIM') {
modXferTime <- dismo::predict(evalOut@models[[curModel]], xftMsk,
useC = FALSE)
modXferTime <- dismo::predict(evalOut@models[[curModel]], terra::rast(xftMsk))
} else if (alg == 'maxnet') {
if (outputType == "raw") outputType <- "exponential"
modXferTime <- predictMaxnet(evalOut@models[[curModel]], xftMsk,
type = outputType, clamp = clamp)
} else if (alg == 'maxent.jar') {
modXferTime <- dismo::predict(
evalOut@models[[curModel]], xftMsk,
evalOut@models[[curModel]], terra::rast(xftMsk),
args = c(paste0("outputformat=", outputType),
paste0("doclamp=", tolower(as.character(clamp)))),
na.rm = TRUE)
paste0("doclamp=", tolower(as.character(clamp)))))
}
})
return(list(xferExt = xftMsk, xferTime = modXferTime))
Expand Down
24 changes: 15 additions & 9 deletions R/xfer_userEnvs.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,24 @@
#' selCoords <- matrix(c(longitude, latitude), byrow = FALSE, ncol = 2)
#' polyExt <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(selCoords)),
#' ID = 1)))
#' # load model
#' m <- readRDS(system.file("extdata/model.RDS",
#' package = "wallace"))
#' # build model
#' occs <- read.csv(system.file("extdata/Bassaricyon_alleni.csv",package = "wallace"))
#' bg <- read.csv(system.file("extdata/Bassaricyon_alleni_bgPoints.csv",
#' package = "wallace"))
#' envs <- envs_userEnvs(rasPath = list.files(system.file("extdata/wc",
#' package = "wallace"), pattern = ".tif$", full.names = TRUE),
#' rasName = list.files(system.file("extdata/wc",package = "wallace"),
#' pattern = ".tif$", full.names = FALSE))
#' partblock <- part_partitionOccs(occs, bg, method = 'block')
#' m <- model_maxent(occs, bg, user.grp = partblock, bgMsk = envs, rms = c(1:2),
#' rmsStep = 1, fcs = c('L', 'LQ'), clampSel = TRUE, algMaxent = "maxnet", parallel = FALSE)
#' envsFut <- list.files(path = system.file('extdata/wc/future',
#' package = "wallace"),
#' full.names = TRUE)
#' envsFut <- raster::stack(envsFut)
#' ### run function
#' modXfer <- xfer_userEnvs(evalOut = m, curModel = 1, envs = envsFut,
#' outputType = "cloglog", alg = "maxent.jar",
#' outputType = "cloglog", alg = "maxnet",
#' clamp = FALSE, xfExt = polyExt)
#' }
#'
Expand Down Expand Up @@ -114,18 +122,16 @@ xfer_userEnvs <- function(evalOut, curModel, envs, xfExt, alg, outputType = NULL
logger,
message = 'Transferring model to user uploaded environmental variables & area', {
if (alg == 'BIOCLIM') {
modXferUser <- dismo::predict(evalOut@models[[curModel]], xferMsk,
useC = FALSE)
modXferUser <- dismo::predict(evalOut@models[[curModel]], terra::rast(xferMsk))
} else if (alg == 'maxnet') {
if (outputType == "raw") outputType <- "exponential"
modXferUser <- predictMaxnet(evalOut@models[[curModel]], xferMsk,
type = outputType, clamp = clamp)
} else if (alg == 'maxent.jar') {
modXferUser <- dismo::predict(
evalOut@models[[curModel]], xferMsk,
evalOut@models[[curModel]], terra::rast(xferMsk),
args = c(paste0("outputformat=", outputType),
paste0("doclamp=", tolower(as.character(clamp)))),
na.rm = TRUE)
paste0("doclamp=", tolower(as.character(clamp)))))
}
})

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 (v2.1.3)
# Wallace (v2.2.0)

*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.

Expand All @@ -27,7 +27,7 @@ run_wallace()
Please make sure you have installed the latest versions of both R (<a href= "https://cran.r-project.org/bin/macosx/" target="_blank">Mac OS</a>, <a href= "https://cran.r-project.org/bin/windows/base/" target="_blank">Windows</a>) and RStudio (<a href= "https://posit.co/download/rstudio-desktop/" target="_blank">Mac OS / Windows</a>: choose the free version).

#### How to run Maxent with maxent.jar
*Wallace* v2.1.3 includes two options to run Maxent models: maxnet and maxent.jar. The former, which is an R implementation and fits the model with the package `glmnet`, is now the default and does not require the package `rJava` (see Phillips et al. 2017). The latter, which is the Java implementation, runs the `maxent()` function in the package `dismo`. This function requires the user to place the `maxent.jar` file in the `/java` directory of the `dismo` package root folder. You can download Maxent <a href="https://biodiversityinformatics.amnh.org/open_source/maxent/" target="_blank">here</a>, and locate `maxent.jar`, which is the Maxent program itself, in the downloaded folder. You can find the directory path to `dismo/java` by running `system.file('java', package="dismo")` at the R console. Simply copy `maxent.jar` and paste it into this folder. If you try to run Maxent in *Wallace* without the file in place, you will get a warning message in the log window and Maxent will not run.
*Wallace* v2.2.0 includes two options to run Maxent models: maxnet and maxent.jar. The former, which is an R implementation and fits the model with the package `glmnet`, is now the default and does not require the package `rJava` (see Phillips et al. 2017). The latter, which is the Java implementation, runs the `maxent()` function in the package `dismo`. This function requires the user to place the `maxent.jar` file in the `/java` directory of the `dismo` package root folder. You can download Maxent <a href="https://biodiversityinformatics.amnh.org/open_source/maxent/" target="_blank">here</a>, and locate `maxent.jar`, which is the Maxent program itself, in the downloaded folder. You can find the directory path to `dismo/java` by running `system.file('java', package="dismo")` at the R console. Simply copy `maxent.jar` and paste it into this folder. If you try to run Maxent in *Wallace* without the file in place, you will get a warning message in the log window and Maxent will not run.

### Potential Issues

Expand Down
2 changes: 2 additions & 0 deletions inst/module_skeleton/skeleton.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

# LOAD INTO SPP ####

# REFERENCES ####

# METADATA ####
})

Expand Down
2 changes: 1 addition & 1 deletion inst/shiny/Rmd/text_about.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ output: html_document

<img src="logo.png" alt="logo" style="width: 150px; float:right; padding:10px;"/>

Welcome to *Wallace*, a flexible application for reproducible ecological modeling, built for community expansion. The current version of *Wallace* (v2.1.3) 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* (v2.2.0) 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 <a href="https://CRAN.R-project.org/package=wallace" target="_blank">CRAN</a>, and the development version on <a href="https://github.com/wallaceEcoMod/wallace" target="_blank">Github</a>. We also maintain a *Wallace* <a href="https://wallaceecomod.github.io/" target="_blank">website</a> that has some basic info, links, and will be updated with tutorial materials in the near future.

Expand Down
2 changes: 1 addition & 1 deletion inst/shiny/Rmd/text_intro_tab.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ output: html_document

#### WORKFLOW

*Wallace* (v2.1.3) 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* (v2.2.0) 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:**

Expand Down
2 changes: 1 addition & 1 deletion inst/shiny/Rmd/userReport_intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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* v2.1.3 session.
Please find below the R code history from your *Wallace* v2.2.0 session.

You can reproduce your session results by running this R Markdown file in RStudio.

Expand Down
4 changes: 2 additions & 2 deletions inst/shiny/modules/envs_userEnvs.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Users will need to know what the original CRS of their rasters is, then look up

*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.
A warning message will appear if your layers have NA values for pixels that are not consistent among all of the layers. You can continue using them, but some downstream analyses may not be functional. Alternatively, before uploading rasters to Wallace, you can assign values in a GIS program or mask the rasters in R to have matching NA values.

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.
Using your own environmental data here will disable the later *Transfer to New Time* module, as it requires WorldClim bioclimatic variables. The later Module: *Transfer to User Environments* is still available.
Loading
Loading