Skip to content

Commit

Permalink
Merge pull request #8 from SABS-R3-Epidemiology/anita_testing
Browse files Browse the repository at this point in the history
Updated Coverage files and README
  • Loading branch information
anitaapplegarth authored Feb 28, 2025
2 parents ddf1ecf + e76bc9d commit 930bcf4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
9 changes: 9 additions & 0 deletions .covrignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Files to ignore
R/zzz.R
R/simulation_epigeopop.r
R/simulation_toy.r
data
images
man
tests
walk_through
3 changes: 2 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "Coverage"
on:
push:
branches:
- main
- '**'
pull_request:
branches:
- '**'
Expand Down Expand Up @@ -62,3 +62,4 @@ jobs:
run: |
covr::codecov()
shell: Rscript {0}

1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Suggests: tinytest
Imports:
ggplot2,
here,
testthat,
tidyr,
reticulate (>= 1.14)
Depends: R (>= 3.3.0)
Expand Down
37 changes: 20 additions & 17 deletions R/simulation_epigeopop.r
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
source("R/wrapper.R")
# Example usage:
# Run complete simulation
run_complete_simulation <- function(country="Andorra",
run_complete_simulation <- function(country = "Andorra",
output_file = "output.csv",
sir_plot_file = "SIR_plot.png",
rt_plot_file = "Rt_plot.png",
si_plot_file = "SerialInterval_plot.png",
simulation_duration = 60,
initial_infected = 100) {
initial_infected = 100) {
output_dir <- paste0("data/", country, "/simulation_outputs")

# Initialize environment
Expand Down Expand Up @@ -51,17 +51,17 @@ run_complete_simulation <- function(country="Andorra",
generation_time_output = TRUE,
serial_interval_output = TRUE
)


# Use Andorra population data
population <- create_epigeopop_population(pe,
paste0("data/", country, "/inputs/", country,
"_microcells.csv"))
population <- create_epigeopop_population(pe,

Check warning on line 56 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=56,col=17,[object_usage_linter] no visible global function definition for 'create_epigeopop_population'
paste0("data/", country, "/inputs/", country, "_microcells.csv")
)

# Run simulation
sim <- run_geopop_sim(pe, sim_params,
file_params, dem_file_params, population,
inf_history_params, seed)
sim <- run_geopop_sim(pe, sim_params,

Check warning on line 61 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=61,col=10,[object_usage_linter] no visible global function definition for 'run_geopop_sim'
file_params, dem_file_params, population,
inf_history_params, seed
)

# Process data
df_long <- process_simulation_data(file.path(output_dir, output_file))

Check warning on line 67 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=67,col=14,[object_usage_linter] no visible global function definition for 'process_simulation_data'
Expand All @@ -74,16 +74,19 @@ run_complete_simulation <- function(country="Andorra",
save_sir_plot(sir_plot, file.path(output_dir, sir_plot_file))

Check warning on line 74 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=74,col=3,[object_usage_linter] no visible global function definition for 'save_sir_plot'

# Generate Rt plot
rt_plot <- plot_rt_curves(file.path(output_dir, "secondary_infections.csv"),
location = file.path(output_dir, rt_plot_file))
rt_plot <- plot_rt_curves(file.path(output_dir, "secondary_infections.csv"),

Check warning on line 77 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=77,col=14,[object_usage_linter] no visible global function definition for 'plot_rt_curves'
location = file.path(output_dir, rt_plot_file)
)

# Generate Serial Interval plot
si_plot <- create_serial_interval_plot(file.path(output_dir,
"serial_intervals.csv"), display = TRUE,
location = file.path(output_dir, si_plot_file))

return(list(simulation = sim, data = df_long,
sir_plot = sir_plot, rt_plot = rt_plot, si_plot = si_plot))
si_plot <- create_serial_interval_plot(file.path

Check warning on line 82 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=82,col=14,[object_usage_linter] no visible global function definition for 'create_serial_interval_plot'

Check warning on line 82 in R/simulation_epigeopop.r

View workflow job for this annotation

GitHub Actions / lint

file=R/simulation_epigeopop.r,line=82,col=42,[function_left_parentheses_linter] Left parenthesis should be on the same line as the function's symbol.
(output_dir, "serial_intervals.csv"), display = TRUE,
location = file.path(output_dir, si_plot_file)
)

return(list(simulation = sim, data = df_long, sir_plot = sir_plot,
rt_plot = rt_plot, si_plot = si_plot)
)
}

results <- run_complete_simulation()
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![codecov](https://codecov.io/gh/SABS-R3-Epidemiology/rEpiabm/graph/badge.svg?token=YXS3D0IDBV)](https://codecov.io/gh/SABS-R3-Epidemiology/rEpiabm)
ADD BADGES
# rEpiabm
rEpiabm enables users familiar with R to use [Epiabm](https://github.com/SABS-R3-Epidemiology/epiabm). Epiabm is a simulation tool that models the progress of an epidemic across a specified region of interest within a specific timeframe. It has been developed in python (PyEpiabm) for small-scale implementations and C++ (cEpiabm) for fast, large-scale simulations. PyEpiabm has a modular design, with many options to configure specific requirements.
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(rEpiabm)

test_check("rEpiabm") # Run all tests in the testthat directory
File renamed without changes.

0 comments on commit 930bcf4

Please sign in to comment.