spatially_aggregated_parasite
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.0%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: cwojan
- Language: R
- Default Branch: main
- Size: 201 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 1
Metadata Files
README.md
Modeling Host-Parasite Burdens Across Varying Parasite Spatial Aggregation, Parasite Density, and Host Recovery Rate
Broad Overview
This github repository features code for an agent-based modeling approach to testing the influence of spatial aggregation of environmental parasites on parasite aggregation on hosts.
The key functions are found in the "parasitesimfunctions.R" script. They include:
- A function to generate binary landscape matrices of varying parasite density and parasite spatial aggregation (slow but precise).
- A function to move hosts across a landscape and acquire/lose parasites.
- A function that wraps around the second function above to run simulations of host movement on a list of landscapes generated by the first function above.
To run the model, first use the "saplandscapesetup.qmd" document to generate a suite of landscapes for simulating upon. Then, use the "sapsimulate.qmd" document to run the simulation model on the suite of landscapes you generated. Finally, you can use the sapfigures.qmd" document to summarize and visualize the simulation results.
There are also three supplementary documents:
- "sapnonspatialsupplement.qmd" compares simulation results from the "simulate" document to a non-spatial version of the model.
- "saptimestepsupplement.qmd" runs simulations on a smaller subset of landscape matrices to observe trends in outcome variables across more timestep, to see when things stabilize (or don't).
- "sapbigsim_supplement.qmd" runs simulations with 100 replicates per landscape to corroborate the smaller replicate simulations.
The "oldmiscfiles" folder contains development files and scratch code.
Detailed Description Generated by Github Copilot
This GitHub repository features code for an agent-based modeling approach to testing the influence of spatial aggregation of environmental parasites on parasite aggregation on hosts.
Table of Contents
Overview
The repository contains code to simulate host-parasite interactions across landscapes with varying parasite spatial aggregation, density, and host recovery rates. The aim is to understand how these factors influence parasite burdens on hosts.
Setup
To get started, clone the repository and ensure you have the required R packages installed. The primary scripts are written in R and Quarto Markdown.
Required Libraries
tidyversefurrrapesom.nn
Load the required libraries and source the main functions script:
r
library(tidyverse)
library(furrr)
library(ape)
library(som.nn)
source("parasite_sim_functions.R")
Key Functions
The key functions are found in the parasite_sim_functions.R script. They include:
- Landscape Percolation Function: Generates binary landscape matrices of varying parasite density and spatial aggregation.
- Host Movement Function: Simulates host movement across a landscape and parasite acquisition/loss.
- Simulation Function: Wraps around the host movement function to run simulations on landscapes generated by the percolation function.
Landscape Percolation Function
r
fast_ls_perc <- function(size, prop, cluster) {
# Function to generate landscape matrices
...
}
Host Movement Function
r
move_host_fast <- function(hosts, coords, n_moves, n_reps, p_gain = "both", infec_prob = 0.5, recov_prob = 0) {
# Function to move hosts and simulate parasite acquisition/loss
...
}
Simulation Function
r
parasite_sim <- function(landscape, n_hosts, n_moves, n_reps = 1, movetypes = tibble(type = 0.2, prop = 1), p_gain = "both", infec_prob = 0.5, recov_prob = 0) {
# Function to run simulations on landscapes
...
}
Running the Model
Step 1: Generate Landscapes
Use the sap_landscape_setup.qmd document to generate a suite of landscapes for simulation.
```r
Load required libraries and functions
library(tidyverse) library(furrr) library(ape) library(som.nn) source("parasitesimfunctions.R")
Generate landscapes
props <- rep((1:9)/10, 16) clusters <- rep(0:15, each = 9) plan(multisession) lslist <- futuremap2(props, clusters, ~fastlsperc(size = 48, prop = .x, cluster = .y), .options = furrr_options(seed = TRUE), .progress = TRUE) ```
Step 2: Run Simulations
Use the sap_simulate.qmd document to run the simulation model on the generated landscapes.
```r
Load required libraries and functions
library(tidyverse) library(furrr) library(ape) library(som.nn) source("parasitesimfunctions.R")
Load landscapes
lslist <- readrds("simoutput/lslist20240719091018.rds")
Run simulations
recovs <- rep(c(0.05, 0.15, 0.25), 144) lsrep <- rep(lslist, each = 3) plan(multisession) recovsims <- futuremap2(lsrep, recovs, ~parasitesim(landscape = .x, nhosts = 96, nmoves = 100, nreps = 10, recovprob = .y), .options = furrr_options(seed = TRUE), .progress = TRUE) ```
Step 3: Visualize Results
Use the sap_figures.qmd document to summarize and visualize the simulation results.
```r
Load required libraries and data
library(tidyverse) library(broom) simdata <- readrds("simoutput/recovsimdata20240719092424.rds") lslist <- readrds("simoutput/lslist20240719091018.rds")
Summarize and visualize results
simsummary <- simdata %>% groupby(prop, cluster, moran, repid, recovprob) %>% summarize(...) dispfig <- ggplot(simsummary, aes(...)) + geompoint() + ... ```
Supplementary Documents
- sapnonspatialsupplement.qmd: Compares simulation results to a non-spatial version of the model.
- saptimestepsupplement.qmd: Runs simulations on a subset of landscape matrices to observe trends over more timesteps.
- sapbigsim_supplement.qmd: Runs simulations with 100 replicates per landscape to corroborate the smaller replicate simulations.
Non-Spatial Model Comparison
```r
Load required library
library(tidyverse)
Define non-spatial model function
nonspatialparasitesim <- function(prop, nhosts = 96, ntimes = 100, infecprob = 0.5, recovprob, n_reps) { ... }
Run non-spatial simulations
densities <- rep((1:9)/10, 3) recovs <- rep(c(0.05, 0.15, 0.25), each = 9) nssimoutput <- map2(densities, recovs, ~nonspatialparasitesim(prop = .x, recovprob = .y, nreps = 10)) %>% bind_rows() ```
Extended Timesteps Simulation
```r
Load required libraries and data
library(tidyverse) library(furrr) library(ape) library(som.nn) library(broom) source("parasitesimfunctions.R")
Load and filter landscapes
lslist <- readrds("simoutput/lslist20240719091018.rds") lssubset <- map(lslist, ~if (.x$lsstats$cluster %in% c(0, 5, 10, 15) & .x$lsstats$prop %in% c(0.1, 0.5, 0.9)) .x else NULL) %>% compact()
Simulate for more timesteps
recovs <- rep(c(0.05, 0.15, 0.25), 12) lsrep <- rep(lssubset, each = 3) plan(multisession) longsims <- futuremap2(lsrep, recovs, ~parasitesim(landscape = .x, nhosts = 96, nmoves = 1000, nreps = 10, recovprob = .y), .options = furrr_options(seed = TRUE), .progress = TRUE) ```
Development Files
The old_misc_files folder contains development files and scratch code.
Contact
For any questions or issues, please open an issue on the repository or contact the author.
Owner
- Name: Chris Wojan
- Login: cwojan
- Kind: user
- Repositories: 1
- Profile: https://github.com/cwojan
Citation (CITATION.cff)
cff-version: 1.1.0 message: "If you use this software, please cite it as below." authors: - family-names: Wojan given-names: Chris title: spatially_aggregated_parasite version: v1.0 doi: 10.5281/zenodo.15360216 date-released: 2025-05-07
GitHub Events
Total
- Release event: 1
- Push event: 11
Last Year
- Release event: 1
- Push event: 11