Skip to content

Commit

Permalink
* function
Browse files Browse the repository at this point in the history
  - changed function `SESraster()` to allow directly suplying of function with randomization algorithm; also improved method of supplying arguments through FUN_args and alg_args
  - updated `algorithm_metrics()`
  - added `plot_alg_metrics()` to plot site and species difference metrics
 between original and randomized rasters
  • Loading branch information
HemingNM committed Jul 8, 2023
1 parent f2c4e88 commit 9d48335
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 127 deletions.
11 changes: 8 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ Description: Randomization of presence/absence species distribution raster
data with or without including spatial structure for calculating
standardized effect sizes and testing null hypothesis. The
randomization algorithms are based on classical algorithms for
matrices (Gotelli 2000, <doi:10.2307/177478>) implemented for
raster data.
matrices (Gotelli 2000, <doi:10.2307/177478>) implemented for raster
data.
License: GPL (>= 3)
URL: https://github.com/HemingNM/SESraster,
https://hemingnm.github.io/SESraster/
BugReports: https://github.com/HemingNM/SESraster/issues
Depends:
R (>= 2.10)
Imports:
terra
graphics,
methods,
rlang,
stats,
terra,
utils
Suggests:
kableExtra,
knitr,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Generated by roxygen2: do not edit by hand

export(SESraster)
export(algorithm_performance)
export(algorithm_metrics)
export(bootspat_ff)
export(bootspat_naive)
export(bootspat_str)
export(fit.memory)
export(fr2prob)
export(load_ext_data)
export(plot_alg_metrics)
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* bug fixes
- bug fix on attachMSG

* new function
* new functions
- added `SESraster()` to handle aleatorizations
- added `algorithm_performance()` to compare randomized rasters with observed
rasters
- added `algorithm_metrics()` to compare original and randomized rasters
- added `plot_alg_metrics()` to plot site and species difference metrics
between original and randomized rasters

* function changes
- changed function name from .fit.memory() to fit.memory() and added argument "n"
Expand Down
244 changes: 167 additions & 77 deletions R/SESraster.R

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion R/bootspat_ff.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' @inheritParams terra::app
#' @param ... additional parameters for terra::app
#' @seealso \code{\link{bootspat_str}}, \code{\link{bootspat_naive}},
#' \code{\link{SESraster}}, \code{\link{algorithm_performance}}
#' \code{\link{SESraster}}, \code{\link{algorithm_metrics}}
#' @author Neander Marcel Heming
#'
#' @references Connor, E. F., & Simberloff, D. (1979). The Assembly of Species Communities: Chance or Competition? Ecology, 60(6), 1132–1140.
Expand Down
2 changes: 1 addition & 1 deletion R/bootspat_naive.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#' @param ... additional arguments to be passed passed down from a calling function.
#' @return SpatRaster object
#' @seealso \code{\link{bootspat_str}}, \code{\link{bootspat_ff}},
#' \code{\link{SESraster}}, \code{\link{algorithm_performance}}
#' \code{\link{SESraster}}, \code{\link{algorithm_metrics}}
#' @author Neander Marcel Heming and Gabriela Alves-Ferreira
#'
#' @examples
Expand Down
2 changes: 1 addition & 1 deletion R/bootspat_str.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fr2prob <- function(x, rprob=NULL){
#' @inheritParams terra::app
#' @param ... additional parameters for terra::app
#' @seealso \code{\link{bootspat_naive}}, \code{\link{bootspat_ff}},
#' \code{\link{SESraster}}, \code{\link{algorithm_performance}}
#' \code{\link{SESraster}}, \code{\link{algorithm_metrics}}
#'
#' @author Neander Marcel Heming
#'
Expand Down
4 changes: 3 additions & 1 deletion R/memory_check.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ fit.memory <- function(x, n=1){
# x rasters will be generated in this function, let's see if there is enough memory in the user's pc
sink(nullfile()) # suppress output
mi <- terra::mem_info(x, n)[5] != 0 # proc in memory = T TRUE means that it fits in the pc's memory, so you wouldn't have to use temporary files
sink()
names(mi) <- NULL
sink(file = NULL)
# sink(file = NULL)
return(mi)
}
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,33 @@
# SESraster <a href="https://hemingnm.github.io/SESraster/"><img src="man/figures/logo.png" align="right" height="139" alt="SESraster website" /></a>

Randomization of presence/absence species distribution raster data with or without including spatial structure for calculating standardized effect sizes and testing null hypothesis.
The spatially unstructured randomization algorithms are based on classical algorithms for matrices (Gotelli 2000, <doi:10.2307/177478>) but implemented for raster data.

The randomization algorithms are based on classical algorithms for matrices (Gotelli 2000, <doi:10.2307/177478>) implemented for raster data.
### Installation
To install the package, run the following code:
To install the package, run:
```
install.packages("SESraster")
```
The development version of `SESraster` can be installed from the [`SESraster repository`](https://github.com/HemingNM/SESraster) in Github:
The development version can be installed from the [`SESraster repository`](https://github.com/HemingNM/SESraster) in Github:
```
require(devtools)
devtools::load_all()
devtools::install_github("HemingNM/SESraster", build_vignettes = TRUE)
load_all()
install_github("HemingNM/SESraster", build_vignettes = TRUE)
library(SESraster)
```


### Examples
Vignettes can be found at the [package's webpage](https://hemingnm.github.io/SESraster/) or loading:
```
browseVignettes("SESraster")
```

### Citation
If this package is useful to you, please cite it in your publications.
Find more information using:
```
citation("SESraster")
```

### Issues
If you have any question or find any bug, let us know through the topic ["Issues"](https://github.com/HemingNM/SESraster/issues).
36 changes: 24 additions & 12 deletions man/SESraster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions man/algorithm_performance.Rd → man/algorithm_metrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/bootspat_ff.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/bootspat_naive.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/bootspat_str.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions man/plot_alg_metrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9d48335

Please sign in to comment.