Skip to content

Commit

Permalink
Merge pull request #405 from bjohnso005/rgeosDEV
Browse files Browse the repository at this point in the history
[v2.1.0] removed rgeos
  • Loading branch information
gepinillab authored Sep 25, 2023
2 parents 24e2da2 + 662452f commit 299ec0a
Show file tree
Hide file tree
Showing 26 changed files with 142 additions and 89 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wallace
Version: 2.0.6
Date: 2023-09-05
Version: 2.1.0
Date: 2023-09-25
Title: A Modular Platform for Reproducible Modeling of Species Niches
and Distributions
Description: The 'shiny' application Wallace is a modular platform for
Expand Down Expand Up @@ -45,7 +45,6 @@ Imports:
magrittr,
methods,
RColorBrewer,
rgeos,
rJava,
rlang,
rmarkdown,
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
wallace 2.1.0
=============
- Removed `rgeos` (package expiring)
- Updated team bios
- Added clarification to occs_queryDb guidance text
- Added error msgs to xfer_time

wallace 2.0.6
=============
- Removed `paleobioDB` (package off CRAN)
Expand Down
25 changes: 18 additions & 7 deletions R/penvs_bgExtent.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' occs$occID <- 1:nrow(occs)
#' bgExt <- penvs_bgExtent(occs, bgSel = 'bounding box', bgBuf = 0.5)
#'
#' @return A SpatialPolygonsDataFrame object that contains all occurrences from occs
#' @return A SpatialPolygons object that contains all occurrences from occs
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
# @note
Expand All @@ -51,6 +51,10 @@ penvs_bgExtent <- function(occs, bgSel, bgBuf, logger = NULL, spN = NULL) {
# make spatial pts object of original occs and preserve origID
occs.sp <- sp::SpatialPointsDataFrame(occs.xy, data = occs['occID'])

# make an sf obj
occs.sf <- sf::st_as_sf(occs.xy, coords = c("longitude", "latitude"))
occs.sf <- sf::st_union(occs.sf, by_feature = FALSE)

# generate background extent - one grid cell is added to perimeter of each shape
# to ensure cells of points on border are included
if (bgSel == 'bounding box') {
Expand All @@ -70,22 +74,29 @@ penvs_bgExtent <- function(occs, bgSel, bgBuf, logger = NULL, spN = NULL) {
bgExt <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(as.matrix(xy.bord))), 1)))
msg <- "Study extent: minimum convex polygon."
} else if (bgSel == 'point buffers') {
if (bgBuf == 0) {
if (bgBuf <= 0) {
logger %>%
writeLog(type = 'error',
'Change buffer distance to positive or negative value.')
'Change buffer distance to a positive value.')
return()
}
bgExt <- rgeos::gBuffer(occs.sp, width = bgBuf)
bgExt <- sf::st_buffer(occs.sf, dist = bgBuf)
msg <- paste0("Study extent: buffered points. Buffered by ", bgBuf, " degrees.")
}

if (bgBuf > 0 & bgSel != 'point buffers') {
bgExt <- rgeos::gBuffer(bgExt, width = bgBuf)
if (bgBuf >= 0 & bgSel != 'point buffers') {
bgExt <- sf::st_as_sf(bgExt)
bgExt <- sf::st_buffer(bgExt, dist = bgBuf)
logger %>% writeLog(hlSpp(spN), msg, ' Buffered by ', bgBuf, ' degrees.')
} else if (bgBuf < 0 & bgSel != 'point buffers') {
logger %>%
writeLog(type = 'error',
'All localities must be included within extent.
Change buffer distance to a positive value.')
return()
} else {
logger %>% writeLog(hlSpp(spN), msg)
}
bgExt <- methods::as(bgExt, "SpatialPolygonsDataFrame")
bgExt <- sf::as_Spatial(bgExt)
return(bgExt)
}
12 changes: 7 additions & 5 deletions R/penvs_drawBgExtent.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#' ncol = 2)
#' drawBgBf <- penvs_drawBgExtent(polyExtXY = expertDrawPoly, polyExtID = 1,
#' drawBgBuf = 0.5, occs)
#' @return This functions returns a SpatialPolygonsDataFrame based on the user
#' specified coordinates (drawn on map). This SpatialPolygonsDataFrame may be
#' larger than specified if drawBgBuf > 0. The SpatialPolygonsDataFrame will
#' @return This functions returns a SpatialPolygons object based on the user
#' specified coordinates (drawn on map). This SpatialPolygons object may be
#' larger than specified if drawBgBuf > 0. The SpatialPolygons object will
#' include all occurrences.

#' @author Jamie Kass <jamie.m.kass@@gmail.com>
Expand All @@ -56,10 +56,12 @@ penvs_drawBgExtent <- function(polyExtXY, polyExtID, drawBgBuf, occs,
newPoly <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(polyExtXY)),
ID = polyExtID)))
intersect <- sp::over(pts, newPoly)
newPoly.sf <- sf::st_as_sf(newPoly)

ptRem <- ifelse(all(!is.na(intersect)), 0, as.numeric(which(is.na(intersect))))
if (ptRem == 0) {
bgExt <- rgeos::gBuffer(newPoly, width = drawBgBuf)
bgExt <- methods::as(bgExt, "SpatialPolygonsDataFrame")
bgExt <- sf::st_buffer(newPoly.sf, dist = drawBgBuf)
bgExt <- sf::as_Spatial(bgExt)
if (drawBgBuf == 0) {
logger %>% writeLog(hlSpp(spN), 'Draw polygon without buffer.')
} else {
Expand Down
11 changes: 8 additions & 3 deletions R/penvs_userBgExtent.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' userBgBuf = 0.2, occs = occs)
#'
#' @return This function returns a SpatialPolygons object with the user
#' provided shape (+ a buffer is userBgBuf >0). The polygon will be at least
#' provided shape (+ a buffer if userBgBuf >0). The polygon will be at least
#' large enough to contain all occurrences.
#' @author Jamie Kass <jamie.m.kass@@gmail.com>
#' @author Gonzalo E. Pinilla-Buitrago <gepinillab@@gmail.com>
Expand Down Expand Up @@ -79,8 +79,13 @@ penvs_userBgExtent <- function(bgShp_path, bgShp_name, userBgBuf, occs,
}

if (userBgBuf >= 0) {
bgExt <- rgeos::gBuffer(bgExt, width = userBgBuf)
bgExt <- methods::as(bgExt, "SpatialPolygonsDataFrame")
bgExt <- sf::st_as_sf(bgExt)
bgExt <- sf::st_buffer(bgExt, dist = userBgBuf)
bgExt <- sf::as_Spatial(bgExt)
} else {
bgExt <- sf::st_as_sf(bgExt)
bgExt <- sf::st_buffer(bgExt, dist = userBgBuf)
bgExt <- sf::as_Spatial(bgExt)
}

### Points outside polygon
Expand Down
7 changes: 4 additions & 3 deletions R/xfer_draw.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' polygonTest <- xfer_draw(polyXfXY = userDrawPoly, polyXfID,
#' drawXfBuf)
#'
#' @return This functions returns a SpatialPolygonsDataFrame based on the user
#' @return This functions returns a SpatialPolygons object based on the user
#' specified coordinates (drawn on map). This SpatialPolygonsDataFrame may be
#' larger than specified if drawBgBuf > 0.

Expand All @@ -41,8 +41,9 @@
xfer_draw <- function(polyXfXY, polyXfID, drawXfBuf, logger = NULL, spN = NULL) {
newPoly <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(polyXfXY)),
ID = polyXfID)))
bgExt <- rgeos::gBuffer(newPoly, width = drawXfBuf)
bgExt <- methods::as(bgExt, "SpatialPolygonsDataFrame")
newPoly.sf <- sf::st_as_sf(newPoly)
bgExt <- sf::st_buffer(newPoly.sf, dist = drawXfBuf)
bgExt <- sf::as_Spatial(bgExt)
if (drawXfBuf == 0) {
logger %>% writeLog(hlSpp(spN), 'Draw polygon without buffer.')
} else {
Expand Down
12 changes: 8 additions & 4 deletions R/xfer_userExtent.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,19 @@ xfer_userExtent <- function(bgShp_path, bgShp_name, userBgBuf,
return()
}

if (userBgBuf >= 0) {
bgExt <- rgeos::gBuffer(bgExt, width = userBgBuf)
bgExt <- methods::as(bgExt, "SpatialPolygonsDataFrame")
}
if (userBgBuf > 0) {
bgExt <- sf::st_as_sf(bgExt)
bgExt <- sf::st_buffer(bgExt, dist = userBgBuf)
bgExt <- sf::as_Spatial(bgExt)
logger %>% writeLog(
hlSpp(spN),
'Transferring extent user-defined polygon buffered by ',
userBgBuf, ' degrees.')
} else if (userBgBuf < 0) {
logger %>%
writeLog(type = 'error',
'Change buffer distance to a positive value.')
return()
} else {
logger %>% writeLog(
hlSpp(spN),
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.0.6)
# Wallace (v2.1.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.0.6 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.1.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: 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.0.6) 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.1.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.0.6) 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.1.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
13 changes: 8 additions & 5 deletions inst/shiny/Rmd/text_team.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ output: html_document

<img src="img/gonzalo.png" alt="gonzalo" style="width: 100px;"/>

<a href="https://scholar.google.no/citations?user=xlxAr_EAAAAJ&hl=en" target="_blank">Gonzalo E. Pinilla-Buitrago</a> (co-lead developer) is a PhD candidate at the CUNY Graduate Center and City College of New York.
<a href="https://scholar.google.no/citations?user=xlxAr_EAAAAJ&hl=en" target="_blank">Gonzalo E. Pinilla-Buitrago</a> (co-lead developer) received his PhD from the CUNY Graduate Center and City College of New York. He is currently a Postdoctoral Researcher at Yale University.
<br>

<img src="img/andrea.png" alt="andrea" style="width: 100px;"/>

<a href="https://andrepazv.github.io" target="_blank">Andrea Paz</a> (developer) received her PhD at CUNY Graduate Center and City College of New York and is now a Postdoctoral Researcher at the Crowther Lab in ETH Zürich.
<a href="https://andrepazv.github.io" target="_blank">Andrea Paz</a> (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.
<br>

<img src="img/bethany.jpg" alt="bethany" style="width: 100px;"/>

<a href="https://github.com/bjohnso005" target="_blank">Bethany A. Johnson</a> (developer) is a Master's student at the City College of New York.
<a href="https://github.com/bjohnso005" target="_blank">Bethany A. Johnson</a> (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.
<br>

<a href="https://www.amnh.org/research/staff-directory/daniel-lopez-lozano" target="_blank">Daniel López Lozano</a> (developer) is a Biodiversity Informatics Specialist at the American Museum of Natural History's Center for Biodiversity & Conservation.
<br>

<img src="img/valentina.png" alt="valentina" style="width: 100px;"/>
Expand Down Expand Up @@ -57,7 +60,7 @@ output: html_document

<img src="img/mary.png" alt="mary" style="width: 100px;"/>

<a href="https://www.amnh.org/research/staff-directory/mary-e-blair" target="_blank">Mary E. Blair</a> (co-manager) is the Director of Biodiversity Informatics Research at the Center for Biodiversity and Conservation at the American Museum of Natural History.
<a href="https://www.amnh.org/research/staff-directory/mary-e-blair" target="_blank">Mary E. Blair</a> (co-manager) is the Director of Biodiversity Informatics Research at the Center for Biodiversity & Conservation at the American Museum of Natural History.
<br>

## Contributors
Expand All @@ -74,7 +77,7 @@ Sarah Meenan (contributor) completed her undergraduate degree from the City Coll

<img src="img/peteG.jpg" alt="peteG" style="width: 100px;"/>

<a href="https://www.amnh.org/research/staff-directory/peter-galante" target="_blank">Peter J. Galante</a> (contributor) was a Biodiversity Informatics Scientist at the Center for Biodiversity and Conservation at the American Museum of Natural History and now works as a Project Manager for Storke, LLC, a renewable energy company.
<a href="https://www.amnh.org/research/staff-directory/peter-galante" target="_blank">Peter J. Galante</a> (contributor) was formerly a Biodiversity Informatics Scientist at the Center for Biodiversity & Conservation at the American Museum of Natural History and now works as a Project Manager for Storke, LLC, a renewable energy company.
<br>

<img src="img/brianM.jpeg" alt="brianM" style="width: 100px;"/>
Expand Down
4 changes: 2 additions & 2 deletions 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.0.6 session.
Please find below the R code history from your *Wallace* v2.1.0 session.

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

Expand All @@ -25,7 +25,7 @@ Wallace uses the following R packages that must be installed and loaded before s
library(spocc)
library(spThin)
library(dismo)
library(rgeos)
library(sf)
library(ENMeval)
library(wallace)
```
Expand Down
Loading

0 comments on commit 299ec0a

Please sign in to comment.