mrc-ide / epireview

https://mrc-ide.github.io/epireview/
GNU General Public License v3.0
25 stars 2 forks source link

Add a quick start section #30

Closed pratikunterwegs closed 2 months ago

pratikunterwegs commented 5 months ago

This issue is to request a "Quick start" section in the Readme to show users how to get started with accessing and extracting parameters from the database for use in downstream analyses. A small example of conversion to the {epiparameter} class <epidist> is shown here.

library(epireview)
#> Loading required package: epitrix
#> Loading required package: ggplot2
#> Loading required package: ggforce
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

data = load_epidata("ebola")
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> Warning in load_epidata_raw(pathogen, "outbreak"): No data found for ebola
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> Warning in load_epidata("ebola"): No outbreaks information found for ebola
#> Data loaded for ebola

names(data)
#> [1] "articles"  "params"    "models"    "outbreaks"
param_data = data$params

# get all onset to death distribution data
# select high quality with Gamma dist
param_data = filter(
  param_data,
  parameter_type == "Human delay - Symptom Onset/Fever to Death",
  distribution_type == "Gamma",
  article_qa_score > 50
) %>%
  head(1)

# transform to epidist
# NOTE which parameters are used for uncertainty
# this differs between studies/entries
onset_to_death_mean = pull(param_data, parameter_value)
onset_to_death_sd = pull(param_data, distribution_par2_value)

# assume a Gamma distribution?
dist_params = epiparameter::convert_summary_stats_to_params(
  x = "gamma",
  mean = onset_to_death_mean,
  sd = onset_to_death_sd
)

# select one with shape and scale
epidist_ebola_otd = epiparameter::epidist(
  "Ebola virus disease",
  "Ebolavirus",
  epi_dist = "onset_to_death",
  prob_distribution = "gamma",
  prob_distribution_params = unlist(dist_params)
)
#> Citation cannot be created as author, year, journal or title is missing

epidist_ebola_otd
#> Disease: Ebola virus disease
#> Pathogen: Ebolavirus
#> Epi Distribution: onset to death
#> Study: (????). "No citation."
#> Distribution: gamma
#> Parameters:
#>   shape: 4.549
#>   scale: 2.082

Created on 2024-03-27 with reprex v2.0.2

sangeetabhatia03 commented 2 months ago

Thanks for your suggestion Pratik! I have added a Quick Start section to the README. We also plan to add more documentation and vignettes in the near future.

pratikunterwegs commented 2 months ago

Thanks @sangeetabhatia03, happy to help.