Skip to content

Commit

Permalink
Prepare for CRAN v0.2.5 Release (cont.)
Browse files Browse the repository at this point in the history
* `spatstat (>=2.0-0)` is no longer Suggests
* Fixed annotation typos in the `pval_correct()` function
*  Updated packages in code rendering hexsticker
  • Loading branch information
Ian Buller, PhD, MA committed Feb 4, 2022
1 parent c3fb23a commit f102d90
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 43 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -56,7 +56,6 @@ Imports:
stats
Suggests:
spatstat.data,
spatstat (>= 2.0-0),
testthat,
spelling,
R.rsp
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions R/pval_correct.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://doi.org/10.2307/2283989> 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
Expand Down
39 changes: 21 additions & 18 deletions dev/hexSticker_sparrpowR.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 -------------------- #

# -------------------- END OF CODE -------------------- #
6 changes: 3 additions & 3 deletions man/pval_correct.Rd

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

2 changes: 0 additions & 2 deletions vignettes/.gitignore

This file was deleted.

0 comments on commit f102d90

Please sign in to comment.