Skip to content

Commit

Permalink
Prepare for CRAN v0.2.8 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
idblr committed Jan 23, 2024
1 parent 690dcc0 commit b12fda0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 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.7
Date: 2023-02-01
Version: 0.2.8
Date: 2024-01-23
Authors@R:
c(person(given = "Ian D.",
family = "Buller",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# sparrpowR (development version)

## sparrpowR v0.2.8
* Fixed bug in calculation of False Discovery Rate in internal `pval_correct()` function
* Fixed 'Moved Permanently' content by replacing the old URL with the new URL

## sparrpowR v0.2.7
* Migrated R-spatial dependency
* Replaced `raster` and `sp` in Imports with `terra` because of imminent package retirement
Expand Down
20 changes: 4 additions & 16 deletions R/pval_correct.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Calculate p-value corrections
#' Calculate p-value corrections for multiple testing
#'
#' Internal function to calculate various p-value corrections for use within the \code{\link{spatial_power}} and \code{\link{jitter_power}} functions.
#'
Expand All @@ -24,22 +24,10 @@ pval_correct <- function(input,
type = c("FDR", "Sidak", "Bonferroni"),
alpha = 0.05,
nbc = NULL) {

# False Discovery Rate
if (type == "FDR") {
sort_pvals <- sort(as.vector(input$P$v), 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))
}

# False Discovery Rate (Benjamini & Hochberg)
if (type == "FDR") {
sort_pvals <- sort(as.vector(input$P$v))
out_alpha <- fdr(sort_pvals, alpha)
return(out_alpha)
}
Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ progBar <- function(kk, N, per = 1) {
if (kk == N) cat("\r")
}
}

# 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]))
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ sparrpowR: Power analysis to detect spatial relative clusters <img src="man/figu
[![CRAN version](https://www.r-pkg.org/badges/version-ago/sparrpowR)](https://cran.r-project.org/package=sparrpowR)
[![CRAN RStudio mirror downloads total](https://cranlogs.r-pkg.org/badges/grand-total/sparrpowR?color=blue)](https://r-pkg.org/pkg/sparrpowR)
[![CRAN RStudio mirror downloads monthly ](http://cranlogs.r-pkg.org/badges/sparrpowR)](https://www.r-pkg.org:443/pkg/sparrpowR)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0/)
![GitHub last commit](https://img.shields.io/github/last-commit/machiela-lab/sparrpowR)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5347997.svg)](https://doi.org/10.5281/zenodo.5347997)
<!-- badges: end -->

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

<h2 id="overview">

Expand Down
9 changes: 3 additions & 6 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
## This is the eleventh resubmission
## This is the twelth resubmission

* Actions taken since previous submission:
* Migrated R-spatial dependency
* Replaced `raster` and `sp` in Imports with `terra` because of imminent package retirement
* `geojsonsf`, `ggmap`, `ggplot2`, `sf`, `tidyterra` are now Suggests because they are used in the vignette
* Updated vignette and documentation throughout
* Updated citation style for CITATION file
* Fixed bug in calculation of False Discovery Rate in internal `pval_correct()` function
* Fixed 'Moved Permanently' content by replacing the old URL with the new URL

* Documentation for `pval_correct()` references a doi <https://doi.org/10.2307/2283989> that throws a NOTE but is a valid URL

Expand Down
2 changes: 1 addition & 1 deletion man/pval_correct.Rd

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

0 comments on commit b12fda0

Please sign in to comment.