From f102d907dce42533e9ee9fa7ef7d25ca9317160d Mon Sep 17 00:00:00 2001 From: "Ian Buller, PhD, MA" Date: Fri, 4 Feb 2022 10:36:44 -0500 Subject: [PATCH] Prepare for CRAN v0.2.5 Release (cont.) * `spatstat (>=2.0-0)` is no longer Suggests * Fixed annotation typos in the `pval_correct()` function * Updated packages in code rendering hexsticker --- DESCRIPTION | 3 +-- NAMESPACE | 1 - NEWS.md | 15 ++++++++------- R/package.R | 2 +- R/pval_correct.R | 10 +++++----- cran-comments.md | 9 +++++---- dev/hexSticker_sparrpowR.R | 39 ++++++++++++++++++++------------------ man/pval_correct.Rd | 6 +++--- vignettes/.gitignore | 2 -- 9 files changed, 44 insertions(+), 43 deletions(-) delete mode 100644 vignettes/.gitignore diff --git a/DESCRIPTION b/DESCRIPTION index ce90600..14d763e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: sparrpowR Title: Power Analysis to Detect Spatial Relative Risk Clusters Version: 0.2.5 -Date: 2022-02-03 +Date: 2022-02-04 Authors@R: c(person(given = "Ian D.", family = "Buller", @@ -56,7 +56,6 @@ Imports: stats Suggests: spatstat.data, - spatstat (>= 2.0-0), testthat, spelling, R.rsp diff --git a/NAMESPACE b/NAMESPACE index ac881f8..e776170 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,7 +5,6 @@ export(pval_correct) export(spatial_data) export(spatial_plots) export(spatial_power) -import(spatstat.geom) importFrom(doFuture,registerDoFuture) importFrom(doRNG,"%dorng%") importFrom(fields,image.plot) diff --git a/NEWS.md b/NEWS.md index 41921cb..1160a95 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,29 +1,30 @@ # sparrpowR (development version) -# sparrpowR 0.2.5 +# sparrpowR v0.2.5 * Updated dependencies `spatstat.core` and `spatstat.linnet` packages based on feedback from the Spatstat Team (Adrian Baddeley and Ege Rubak). All random generators in `spatstat.core` were moved to a new package `spatstat.random` * `spatstat.geom`, `spatstat.core`, `spatstat.linnet`, and `spatstat (>=2.0-0)` are no longer Depends. * `spatstat.geom` and `spatstat.random` are now Imports - * `spatstat.data` and `spatstat (>= 2.0-0)` are now Suggests. + * `spatstat.data` is now Suggests * [See the GitHub merge pull request](https://github.com/machiela-lab/sparrpowR/commit/4df5d85343dd222c9d4b1ae30f894ed6482bcb52). +* Fixed annotation typos in the `pval_correct()` function -# sparrpowR 0.2.4 +# sparrpowR v0.2.4 * Addressed ERROR on R-devel CRAN environments by setting `parallelly.makeNodePSOCK.setup_strategy = sequential` for all CRAN tests as suggested by the maintainer for the `future` and `parallelly` packages who is actively working on a solution. [See the GitHub issue](https://github.com/HenrikBengtsson/parallelly/issues/65). -# sparrpowR 0.2.3 +# sparrpowR v0.2.3 * Following advice from `future` package maintainer, now `spatial_power()` and `jitter_power()` functions reset future strategy when exiting * Addressed ERROR in MacOS CRAN environments by setting the `parallelly.makeNodePSOCK.setup_strategy = sequential` for MacOS environments running `tcltk` until `parallelly` (>=1.26.1-9002) is on CRAN. This workaround was suggested by the `parallelly` maintainer. [See the GitHub issue](https://github.com/HenrikBengtsson/parallelly/issues/62#issuecomment-880665390). -# sparrpowR 0.2.2 +# sparrpowR v0.2.2 * Removed `LazyData: true` from 'DESCRIPTION' file because the package has no data accessed via a `data()` command and has no `data/` directory (in response to CRAN NOTE: 'LazyData' is specified without a 'data' directory) * Changed hyperlink for Stamen basemap in 'vignette' file with a Hypertext Transfer Protocol Secure destination * Added 'CITATION' file * Deprecation badges in 'jitter_power.Rd' and 'spatial_power.Rd' files now hyperlink to `lifecycle` r-lib.org site -# sparrpowR 0.2.1 +# sparrpowR v0.2.1 * Updated vignette with appropriate hyperlinks -# sparrpowR 0.2.0 +# sparrpowR v0.2.0 * Updates to dependencies * Updated `spatstat` package to new subsetted packages based on feedback from the Spatstat Team (Adrian Baddeley and Ege Rubak). `spatstat.geom` and `spatstat.core` packages replace `spatstat` package in Depends * Imports `lifecycle` package to document deprecated argument `cascon` in `spatial_power()` and `jitter_power()` functions diff --git a/R/package.R b/R/package.R index 15dedb2..5910627 100644 --- a/R/package.R +++ b/R/package.R @@ -49,6 +49,6 @@ NULL #' @importFrom sp coordinates gridded #' @importFrom sparr risk #' @importFrom stats na.omit rnorm sd +#' @importFrom spatstat.geom as.solist disc marks plot.anylist plot.ppp ppp rsyst shift superimpose unit.square #' @importFrom spatstat.random rNeymanScott rpoispp runifdisc runifpoint -#' @import spatstat.geom NULL diff --git a/R/pval_correct.R b/R/pval_correct.R index 38f6275..46dc252 100644 --- a/R/pval_correct.R +++ b/R/pval_correct.R @@ -3,15 +3,15 @@ #' Internal function to calculate various p-value corrections for use within the \code{\link{spatial_power}} and \code{\link{jitter_power}} functions. #' #' @param input An object of class 'rrs' from the \code{\link{spatial_power}} or \code{\link{jitter_power}} function. -#' @param type Character string specifying which correction for multiple comparisons. Options include a False Discovery Rate \code{p_correct = "FDR"}, an independent Sidak correction \code{p_correct = "uncorrelated Sidak"}, and an independent Bonferroni correction \code{p_correct = "uncorrelated Bonferroni"}. +#' @param type Character string specifying which correction for multiple comparisons. Options include a False Discovery Rate \code{p_correct = "FDR"}, a Sidak correction \code{p_correct = "Sidak"}, and a Bonferroni correction \code{p_correct = "Bonferroni"}. #' @param alpha Numeric. The alpha level for significance threshold (default in \code{\link{spatial_power}} and \code{\link{jitter_power}} functions is 0.05). #' #' @details This function provides functionality for multiple testing correction in five ways: #' #' \enumerate{ #' \item Computes a False Discovery Rate by Benjamini and Hochberg \doi{10.1111/j.2517-6161.1995.tb02031.x} (\code{p_correct = "FDR"}) by: 1) sorting the p-values (p_i) of each knot in ascending order (p_1 <= p_2 <= ... <= p_m), 2) starting from p_m find the first p_i for which p_i <= (i/m) * alpha. -#' \item Computes an independent Sidak correction \doi{10.2307/2283989} (\code{p_correct = "uncorrelated Sidak"}) by 1 - (1 - \code{alpha}) ^ (1 / total number of gridded knots across the estimated surface). The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. -#' \item Computes an independent Bonferroni correction (\code{p_correct = "uncorrelated Bonferroni"}) by \code{alpha} / total number of gridded knots across the estimated surface. The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. +#' \item Computes a Sidak correction \doi{10.2307/2283989} (\code{p_correct = "Sidak"}) by 1 - (1 - \code{alpha}) ^ (1 / total number of gridded knots across the estimated surface). The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. +#' \item Computes a Bonferroni correction (\code{p_correct = "Bonferroni"}) by \code{alpha} / total number of gridded knots across the estimated surface. The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. #' } #' #' @return An object of class 'numeric' with the corrected alpha level. @@ -44,13 +44,13 @@ pval_correct <- function(input, return(out_alpha) } - # Uncorrelated Bonferroni correction + # Sidak correction if (type == "Sidak") { out_alpha <- 1 - (1 - alpha) ^ (1 / prod(input$P$dim) ) return(out_alpha) } - # Uncorrelated Bonferroni correction + # Bonferroni correction if (type == "Bonferroni") { out_alpha <- alpha / prod(input$P$dim) return(out_alpha) diff --git a/cran-comments.md b/cran-comments.md index 249112c..cb3b964 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,15 +2,16 @@ * Actions taken since previous submission: * Updated dependencies `spatstat.core` and `spatstat.linnet` packages based on feedback from the Spatstat Team (Adrian Baddeley and Ege Rubak). All random generators in `spatstat.core` were moved to a new package `spatstat.random` - * `spatstat.geom`, `spatstat.core`, `spatstat.linnet`, and `spatstat (>=2.0-0)` are no longer Depends. + * `spatstat.geom`, `spatstat.core`, `spatstat.linnet`, and `spatstat (>=2.0-0)` are no longer Depends * `spatstat.geom` and `spatstat.random` are now Imports - * `spatstat.data` and `spatstat (>= 2.0-0)` are now Suggests. - * [See the GitHub merge pull request](https://github.com/machiela-lab/sparrpowR/commit/4df5d85343dd222c9d4b1ae30f894ed6482bcb52). + * `spatstat.data` is now Suggests + * [See the GitHub merge pull request](https://github.com/machiela-lab/sparrpowR/commit/4df5d85343dd222c9d4b1ae30f894ed6482bcb52) + * Fixed annotation typos in the `pval_correct()` function * Documentation for `pval_correct()` references a doi that throws a NOTE but is a valid URL ## Test environments -* local OS X install, R 4.1.0 +* local OS X install, R 4.1.2 * win-builder, (devel, release, oldrelease) * Rhub * Fedora Linux, R-devel, clang, gfortran diff --git a/dev/hexSticker_sparrpowR.R b/dev/hexSticker_sparrpowR.R index 05b0a8f..0ab95de 100644 --- a/dev/hexSticker_sparrpowR.R +++ b/dev/hexSticker_sparrpowR.R @@ -4,20 +4,22 @@ # Created by: Ian Buller, Ph.D., M.A. (GitHub: @idblr) # Created on: June 4, 2020 # -# Recently modified by: -# Recently modified on: +# Recently modified by: @idblr +# Recently modified on: February 4, 2022 # # Notes: # A) Uses the "hexSticker" pacakge # B) Option 1: Triforce # C) Various color palettes # D) Option 2: Orion's Sword +# E) 2022/04/02: Updated 'spatstat' suite packages # ----------------------------------------------------- # # Option 1: Triforce # Packages -library(spatstat) +library(spatstat.geom) +library(spatstat.random) library(hexSticker) # Settings @@ -33,30 +35,31 @@ x2 <- c(1-0.33, 1.1, 1.25, 1.6, 1.5+0.33, 1-0.33) y2 <- c(1.5, 1, 1.433013, 1, 1.5, 1.5) # Create point patterns -g1 <- rsyst(nx = 20, win = spatstat::owin(poly=list(x=x,y=y))) -g2 <- rsyst(nx = 20, win = spatstat::owin(poly=list(x=rev(x),y=rev(y1)))) -g3 <- spatstat::rpoispp(lambda = 20, win = spatstat::owin(poly=list(x=x2,y=y2))) +g1 <- rsyst(nx = 20, win = spatstat.geom::owin(poly=list(x=x,y=y))) +g2 <- rsyst(nx = 20, win = spatstat.geom::owin(poly=list(x=rev(x),y=rev(y1)))) +g3 <- spatstat.random::rpoispp(lambda = 20, win = spatstat.geom::owin(poly=list(x=x2,y=y2))) # Set marks for point patterns (for colors) -spatstat::marks(g1) <- 1 -spatstat::marks(g2) <- 2 -spatstat::marks(g3) <- 1 +spatstat.geom::marks(g1) <- 1 +spatstat.geom::marks(g2) <- 2 +spatstat.geom::marks(g3) <- 1 # Combine point patterns and set marks to be factors -g4 <- spatstat::superimpose(g1, g2, g3) -spatstat::marks(g4) <- as.factor(spatstat::marks(g4)) -#spatstat::plot.ppp(g4, cols = c("moccasin", "sienna1"), show.all = F) +g4 <- spatstat.geom::superimpose(g1, g2, g3) +spatstat.geom::marks(g4) <- as.factor(spatstat.geom::marks(g4)) +#spatstat.geom::plot.ppp(g4, cols = c("moccasin", "sienna1"), show.all = F) # Create hexSticker ## the Balance Within palette https://www.color-hex.com/color-palette/14625 -s <- hexSticker::sticker(~spatstat::plot.ppp(g4, cols = c("#ee9a00", "#698b69"), - show.all = F, cex = 0.5, - pch = c(8,8)), - package="sparrpowR", p_size = 5, p_color = "#ffe4b5", - s_x=0.7, s_y=0.1, s_width=3.33, s_height=3.33, +s <- hexSticker::sticker(~ spatstat.geom::plot.ppp(g4, cols = c("#ee9a00", "#698b69"), + show.all = F, cex = 0.5, + pch = c(8,8)), + package = "sparrpowR", p_size = 5, p_color = "#ffe4b5", + s_x = 0.9, s_y = 0.35, s_width = 3.33, s_height = 3.33, h_fill = "#344960", h_color = "#8b3a3a", dpi = 1000, filename = "./man/figures/sparrpowR.png", white_around_sticker = T) -# -------------------- END OF CODE -------------------- # \ No newline at end of file + +# -------------------- END OF CODE -------------------- # diff --git a/man/pval_correct.Rd b/man/pval_correct.Rd index 585b8d1..5cf5bf5 100644 --- a/man/pval_correct.Rd +++ b/man/pval_correct.Rd @@ -14,7 +14,7 @@ pval_correct( \arguments{ \item{input}{An object of class 'rrs' from the \code{\link{spatial_power}} or \code{\link{jitter_power}} function.} -\item{type}{Character string specifying which correction for multiple comparisons. Options include a False Discovery Rate \code{p_correct = "FDR"}, an independent Sidak correction \code{p_correct = "uncorrelated Sidak"}, and an independent Bonferroni correction \code{p_correct = "uncorrelated Bonferroni"}.} +\item{type}{Character string specifying which correction for multiple comparisons. Options include a False Discovery Rate \code{p_correct = "FDR"}, a Sidak correction \code{p_correct = "Sidak"}, and a Bonferroni correction \code{p_correct = "Bonferroni"}.} \item{alpha}{Numeric. The alpha level for significance threshold (default in \code{\link{spatial_power}} and \code{\link{jitter_power}} functions is 0.05).} } @@ -29,8 +29,8 @@ This function provides functionality for multiple testing correction in five way \enumerate{ \item Computes a False Discovery Rate by Benjamini and Hochberg \doi{10.1111/j.2517-6161.1995.tb02031.x} (\code{p_correct = "FDR"}) by: 1) sorting the p-values (p_i) of each knot in ascending order (p_1 <= p_2 <= ... <= p_m), 2) starting from p_m find the first p_i for which p_i <= (i/m) * alpha. -\item Computes an independent Sidak correction \doi{10.2307/2283989} (\code{p_correct = "uncorrelated Sidak"}) by 1 - (1 - \code{alpha}) ^ (1 / total number of gridded knots across the estimated surface). The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. -\item Computes an independent Bonferroni correction (\code{p_correct = "uncorrelated Bonferroni"}) by \code{alpha} / total number of gridded knots across the estimated surface. The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. +\item Computes a Sidak correction \doi{10.2307/2283989} (\code{p_correct = "Sidak"}) by 1 - (1 - \code{alpha}) ^ (1 / total number of gridded knots across the estimated surface). The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. +\item Computes a Bonferroni correction (\code{p_correct = "Bonferroni"}) by \code{alpha} / total number of gridded knots across the estimated surface. The default in the \code{\link[sparr]{risk}} function is a resolution of 128 x 128 or n = 16,384 knots and a custom resolution can be specified using the \code{resolution} argument within the \code{\link[sparr]{risk}} function. } } \keyword{internal} diff --git a/vignettes/.gitignore b/vignettes/.gitignore deleted file mode 100644 index 651ccd5..0000000 --- a/vignettes/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -#*.html -*.R