sparrpowR

Power Analysis to Detect Spatial Relative Clusters in R

https://github.com/machiela-lab/sparrpowr

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 5 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    2 of 5 committers (40.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.8%) to scientific vocabulary

Keywords from Contributors

niche-modeling species-distribution-modeling point-pattern-analysis spatial-analysis cran-r ecological-niche ecological-niche-modelling geospatial-analysis kernel-density-estimation non-euclidean-spaces
Last synced: 7 months ago · JSON representation

Repository

Power Analysis to Detect Spatial Relative Clusters in R

Basic Info
  • Host: GitHub
  • Owner: machiela-lab
  • License: apache-2.0
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 19.9 MB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • Open Issues: 0
  • Releases: 11
Created almost 6 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

sparrpowR: Power analysis to detect spatial relative clusters

R-CMD-check CRAN status CRAN version CRAN RStudio mirror downloads total CRAN RStudio mirror downloads monthly License GitHub last commit <!-- badges: end -->

Date repository last updated: August 28, 2025

Overview

The sparrpowR package is a suite of R functions to calculate the statistical power to detect clusters using the kernel-based spatial relative risk function that is estimated using the sparr package. Basic visualization is also supported.

Installation

To install the release version from CRAN:

install.packages("sparrpowR")

To install the development version from GitHub:

devtools::install_github("machiela-lab/sparrpowR")

Available functions

Function Description
spatialpower Main function. Compute the statistical power of a spatial relative risk function using randomly generated data.
spatialdata Generate random bivariate data for a spatial relative risk function.
jitterpower Compute the statistical power of a spatial relative risk function using previously collected data.
spatialplots Easily make multiple plots from spatialpower, spatialdata, and jitterpower outputs.
pvalcorrect Called within spatialpower and jitterpower, calculates various multiple testing corrections for the alpha level.

Authors

  • Ian D. Buller - DLH, LLC (formerly Social & Scientific Systems, Inc.), Bethesda, Maryland (current) - Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland (original) - GitHub - ORCID

  • Derek W. Brown - Integrative Tumor Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland (original) - GitHub - ORCID

See also the list of contributors who participated in this package, including:

  • Tim A. Myers - Laboratory of Genetic Susceptibility, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland - GitHub

Usage

``` r set.seed(1234) # for reproducibility

------------------

Necessary packages

------------------

library(sparrpowR) library(spatstat.geom) library(stats)

-----------------

Run spatial_power

-----------------

Circular window with radius 0.5

Uniform case sampling within a disc of radius of 0.1 at the center of the window

Complete Spatial Randomness control sampling

20% prevalence (n = 300 total locations)

Statistical power to detect both case and control relative clustering

100 simulations (more recommended for power calculation)

unit.circle <- spatstat.geom::disc(radius = 0.5, centre = c(0.5,0.5))

foo <- sparrpowR::spatialpower(win = unit.circle, simtotal = 100, xcase = 0.5, ycase = 0.5, sampcase = "uniform", sampcontrol = "CSR", rcase = 0.1, ncase = 50, n_control = 250)

-----------------------

Outputs from iterations

-----------------------

Mean and standard deviation of simulated sample sizes and bandwidth

stats::mean(foo$ncon); stats::sd(foo$ncon) # controls stats::mean(foo$ncas); stats::sd(foo$ncas) # cases stats::mean(foo$bandw); stats::sd(foo$bandw) # bandwidth of case density (if fixed, same for control density)

Global Test Statistics

Global maximum relative risk: Null hypothesis is mu = 1

stats::t.test(x = foo$s_obs, mu = 0, alternative = "two.sided")

Integral of log relative risk: Null hypothesis is mu = 0

stats::t.test(x = foo$t_obs, mu = 1, alternative = "two.sided")

-----------------

Run spatial_plots

-----------------

Statistical power for case-only clustering (one-tailed test)

sparrpowR::spatial_plots(foo) ```

```

Statistical power for case clustering and control

clustering (two-tailed test)

Only showing second and third plot

sparrpowR::spatial_plots(foo, cascon = TRUE) ```

```

---------------------------

Multiple Testing Correction

---------------------------

Same parameters as above

Apply a conservative Bonferroni correction

set.seed(1234) # reset RNG

Run spatial_power()

foo <- sparrpowR::spatialpower(win = unit.circle, simtotal = 100, xcase = 0.5, ycase = 0.5, sampcase = "uniform", sampcontrol = "CSR", rcase = 0.1, ncase = 50, ncontrol = 250, alpha = 0.05, pcorrect = "Bonferroni")

median(foo$alpha) # critical p-value of 3e-6

Run spatial_plots() for case-only clustering

Only showing third plot

sparrpowR::spatial_plots(foo, cascon = TRUE) ```

Funding

This package was developed while the authors were originally postdoctoral fellows supported by the Cancer Prevention Fellowship Program at the National Cancer Institute. Any modifications since December 05, 2022 were made while the author I.D.B. was an employee of DLH, LLC (formerly Social & Scientific Systems, Inc.).

Acknowledgments

When citing this package for publication, please follow:

citation("sparrpowR")

Questions? Feedback?

For questions about the package please contact the maintainer Dr. Ian D. Buller or submit a new issue.

Owner

  • Name: Machiela Lab
  • Login: machiela-lab
  • Kind: organization
  • Location: Rockville, MD

Developing tools for investigating the genetic epidemiology of cancer

GitHub Events

Total
  • Push event: 4
Last Year
  • Push event: 4

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 229
  • Total Committers: 5
  • Avg Commits per committer: 45.8
  • Development Distribution Score (DDS): 0.463
Past Year
  • Commits: 4
  • Committers: 2
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.25
Top Committers
Name Email Commits
Ian Buller, PhD, MA i****r@n****v 123
Tim t****s@g****m 97
Ian D Buller i****r@g****m 4
derekbrown12 d****n@n****v 4
rubak r****k@m****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 2 years ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 days
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • rubak (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 311 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 12
  • Total maintainers: 1
cran.r-project.org: sparrpowR

Power Analysis to Detect Spatial Relative Risk Clusters

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 311 Last month
Rankings
Forks count: 17.1%
Dependent repos count: 24.0%
Stargazers count: 27.8%
Average: 28.5%
Dependent packages count: 28.8%
Downloads: 44.9%
Maintainers (1)
Last synced: 7 months ago

Dependencies

DESCRIPTION cran
.github/workflows/R-CMD-check.yaml actions
.github/workflows/rhub.yaml actions