Skip to content

Commit

Permalink
Prepare for CRAN v0.1.18 release
Browse files Browse the repository at this point in the history
  • Loading branch information
idblr committed Jan 23, 2024
1 parent aef46e1 commit 08a2fd7
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 34 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: envi
Type: Package
Title: Environmental Interpolation using Spatial Kernel Density Estimation
Version: 0.1.17
Date: 2023-02-01
Version: 0.1.18
Date: 2024-01-22
Authors@R:
c(person(given = "Ian D.",
family = "Buller",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# envi (development version)

## envi v0.1.18
* Fixed bug in calculation of False Discovery Rate in internal `pval_correct()` function
* Fixed test for `plot_perturb()` function that was presenting a warning by specifying `cref0`
* Argument `plot_cols` correctly renamed `cols` in `div_plot()` and `seq_plot()` functions

## envi v0.1.17
* Fixed broken link in CITATION

Expand Down
2 changes: 1 addition & 1 deletion R/div_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Internal function to convert 'im' object or 'SpatRaster' object to values readable by \code{\link[fields]{image.plot}} function within the \code{\link{plot_obs}}, \code{\link{plot_predict}}, and \code{\link{plot_perturb}} functions.
#'
#' @param input An object of class 'im' or 'SpatRaster' from the \code{\link{lrren}} function.
#' @param plot_cols Character string of length three (3) specifying the colors for plotting: 1) presence, 2) neither, and 3) absence from the \code{\link{plot_obs}} function.
#' @param cols Character string of length three (3) specifying the colors for plotting: 1) presence, 2) neither, and 3) absence from the \code{\link{plot_obs}} function.
#' @param midpoint Numeric. The value to center the diverging color palette.
#' @param thresh_up Numeric. The upper value to concatenate the color key. The default (NULL) uses the maximum value from \code{input}.
#' @param thresh_low Numeric. The lower value to concatenate the color key. The default (NULL) uses the minimum value from \code{input}.
Expand Down
24 changes: 6 additions & 18 deletions R/pval_correct.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,15 @@ pval_correct <- function(input,
type = c("FDR", "Sidak", "Bonferroni"),
alpha = 0.05,
nbc = NULL) {

# False Discovery Rate
if (type == "FDR") {
sort_pvals <- sort(input, decreasing = TRUE)

fdr <- function(pvals, alpha) {
m <- length(pvals)
for (i in 1:length(pvals)) {
if (pvals[i] <= (i/m) * alpha) {
pcrit <- pvals[i]
return(pcrit)
}
}
max(pcrit, min(pvals, na.rm = TRUE))
}

out_alpha <- fdr(sort_pvals, alpha)
return(out_alpha)
# False Discovery Rate (Benjamini & Hochberg)
if (type == "FDR") {
sort_pvals <- sort(input)
out_alpha <- fdr(sort_pvals, alpha)
return(out_alpha)
}

# Bonferroni correction
# Sidak correction
if (type == "Sidak") {
out_alpha <- 1 - (1 - alpha) ^ (1 / length(input) )
return(out_alpha)
Expand Down
2 changes: 1 addition & 1 deletion R/seq_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Internal function to convert 'im' object or 'SpatRaster' object to values readable by \code{\link[fields]{image.plot}} function within the \code{\link{plot_perturb}} function.
#'
#' @param input An object of class 'im' or 'SpatRaster' from the \code{\link{perlrren}} function.
#' @param plot_cols Character string of length three (3) specifying the colors for plotting: 1) presence, 2) neither, and 3) absence from the \code{\link{plot_obs}} function.
#' @param cols Character string of length three (3) specifying the colors for plotting: 1) presence, 2) neither, and 3) absence from the \code{\link{plot_obs}} function.
#' @param thresh_up Numeric. The upper value to concatenate the color key. The default (NULL) uses the maximum value from \code{input}.
#' @param digits Integer. The number of significant digits for the labels using the \code{\link[base]{round}} function (default is 1).
#'
Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,15 @@ as.im.SpatRaster <- function (from, factor.col.name = NULL) {
im <- spatstat.geom::im(val, xcol = xx, yrow = yy)
return(im)
}

# False Discovery Rate (Benjamini & Hochberg)
fdr <- function(pvals, alpha) {
pcrit <- NULL
m <- length(pvals)
for (i in 1:m) {
if (pvals[i] <= (i/m) * alpha) {
pcrit <- pvals[i]
}
}
return(max(pcrit, pvals[1]))
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ envi: Environmental Interpolation using Spatial Kernel Density Estimation <img s
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5347826.svg)](https://doi.org/10.5281/zenodo.5347826)
<!-- badges: end -->

**Date repository last updated**: February 01, 2023
**Date repository last updated**: January 22, 2024

<h2 id="overview">

Expand Down
10 changes: 8 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
## This is the seventeenth resubmission
## This is the eighteenth resubmission

* Updates since previous submission:
* Fixed broken link in CITATION based on v0.1.16 auto-check
* Fixed bug in calculation of False Discovery Rate in internal `pval_correct()` function
* Fixed test for `plot_perturb()` function that was presenting a warning by specifying `cref0`
* Argument `plot_cols` correctly renamed `cols` in `div_plot()` and `seq_plot()` functions

* CRAN Package Check Results 2024-01-22 for 'envi' v0.1.17 in r-patched-linux-x86_64, r-release-macos-arm64, r-release-macos-x86_64:
* NOTE: Package suggested but not available for checking: 'RStoolbox'
* SOLUTION: 'RStoolbox' recently updated 2024-01-17 so will remain as SUGGESTS for 'envi' v0.1.18

* Documentation for "envi-package.Rd", "pval_correct.Rd", DESCRIPTION, and vignette references the following DOIs, which throws a NOTE but are valid URLs:
* <https://doi.org/10.1002/sim.4780090616>
Expand Down
8 changes: 4 additions & 4 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ bibentry(bibtype = "manual",
title = "envi: Environmental Interpolation using Spatial Kernel Density Estimation",
author = as.person("Ian D. Buller"),
publisher = "The Comprehensive R Archive Network",
year = "2023",
number = "0.1.16",
year = "2024",
number = "0.1.18",
doi = "10.5281/zenodo.5347826",
url = "https://cran.r-project.org/package=envi",

textVersion =
paste("Ian D. Buller (2023).",
paste("Ian D. Buller (2024).",
"envi: Environmental Interpolation using Spatial Kernel Density Estimation.",
"The Comprehensive R Archive Network.",
"v0.1.16.",
"v0.1.18.",
"DOI:10.5281/zenodo.5347826",
"Accessed by: https://cran.r-project.org/package=envi"),

Expand Down
4 changes: 2 additions & 2 deletions man/div_plot.Rd

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

4 changes: 2 additions & 2 deletions man/seq_plot.Rd

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

3 changes: 2 additions & 1 deletion tests/testthat/test-plot_perturb.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ test_that("plot_perturb throws error with invalid arguments", {
test_that("plot_obs works", {
skip_on_cran()
expect_silent(
plot_perturb(input = test_perlrren)
plot_perturb(input = test_perlrren,
cref0 = "EPSG:5472")
)

# cref0 = NULL
Expand Down

0 comments on commit 08a2fd7

Please sign in to comment.