https://github.com/avallecam/incidenceflow

https://github.com/avallecam/incidenceflow

Science Score: 13.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
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.4%) to scientific vocabulary

Keywords

incidence outbreaks tidyverse workflow
Last synced: 5 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: avallecam
  • License: gpl-3.0
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 108 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 2
  • Releases: 0
Topics
incidence outbreaks tidyverse workflow
Created over 5 years ago · Last pushed over 4 years ago
Metadata Files
Readme Contributing License Code of conduct Support

README.Rmd

---
output: github_document
editor_options: 
  chunk_output_type: console
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  warning = FALSE,
  message = FALSE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
knitr::opts_chunk$set(fig.width=10, fig.height=4)
options(tidyverse.quiet = TRUE)
```



**Disclaimer** This package is a work in progress. It has been released to get feedback from users that we can incorporate in future releases. # incidenceflow [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/incidenceflow)](https://cran.r-project.org/package=incidenceflow) The goal of `incidenceflow` is to provide tidy workflows using `incidence` and `EpiEstim` with `tidyverse` and `purrr`. ## Installation ``` r if(!require("remotes")) install.packages("remotes") remotes::install_github("avallecam/incidenceflow") ``` ## Example Here are two basic examples which shows you how to solve common problems: ```{r example} library(incidenceflow) ## basic example code ``` ### Workflow 01 - `get_info_tidy`: generates a tibble of `incidence::get_info()`. [click here for more information](https://www.repidemicsconsortium.org/incidence/index.html). - `tidy_incidence`: generates a complete summary tibble from incidence fit paramteter estimates - `glance_incidence`: generates a complete summary tibble from incidence fit model performance ```{r} # packages ---------------------------------------------------------------- if(!require("devtools")) install.packages("devtools") # if(!require("avallecam")) devtools::install_github("avallecam/avallecam") #improvements library(tidyverse) #magrittr and purrr packages library(lubridate) #ymd library(outbreaks) #sample data library(incidence) #core functions # example outbreak -------------------------------------------------------- dat <- ebola_sim$linelist$date_of_onset i.7 <- incidence(dat, interval=7) # plot(i.7) f1 <- fit(i.7[1:20]) f2 <- fit_optim_split(i.7) # broom like functions ---------------------------------------------------- # tidy f1 %>% tidy_incidence() f2 %>% pluck("fit") %>% tidy_incidence() # glance f1 %>% glance_incidence() f2 %>% pluck("fit") %>% glance_incidence() # using purrr ------------------------------------------------------------- # using purrr::map family function allows easy stratification # for gender and could be extrapolated to administrative levels # in country level analysis incidence_purrr <- ebola_sim$linelist %>% as_tibble() %>% #filter observations explicitly before incidence() filter(date_of_onset% #stratify by any group of covariates group_by(gender) %>% nest() %>% mutate(incidence_strata=map(.x = data, .f = ~incidence(.x %>% pull(date_of_onset), interval=7))) %>% mutate(strata_fit=map(.x = incidence_strata, .f = possibly(fit,NA_real_) )) %>% mutate(strata_fit_tidy=map(.x = strata_fit, .f = possibly(tidy_incidence,tibble()))) %>% mutate(strata_fit_glance=map(.x = strata_fit, .f = possibly(glance_incidence,tibble()))) # keep only the tibbles incidence_purrr_tibble <- incidence_purrr %>% select(-data,-incidence_strata,-strata_fit) # tidy_incidence output incidence_purrr_tibble %>% unnest(cols = c(strata_fit_tidy)) # glance_incidence output incidence_purrr_tibble %>% unnest(cols = c(strata_fit_glance)) ``` #### Run this as a `learnr` tutorial ```r # install package if(!require("remotes")) install.packages("remotes") remotes::install_github("avallecam/incidenceflow") # install learner and run tutorial if(!require("learnr")) install.packages("learnr") learnr::run_tutorial(name = "taller",package = "incidenceflow") ``` ### Workflow 02 - `create_nest_dynamics`: estimate Rt per strata - `create_nest_summary`: create figure and tables of incidence and Rt ```{r} linelist_raw <- ebola_sim$linelist %>% as_tibble() %>% #filter observations explicitly before incidence() # filter(date_of_onset% mutate(all="all") dictionary <- linelist_raw %>% count(all,gender) %>% rownames_to_column(var = "code") # linelist_raw %>% # group_by(gender) %>% # skimr::skim() ``` ```{r} time_delay_set = 7 #### execute ------------------------------- nest_dynamics <- create_nest_dynamics(linelist = linelist_raw, dictionary = dictionary, strata_major = all, strata_minor = gender, strata_minor_code = code, # unico para diccionario date_incidence_case = date_of_onset, date_of_analysis_today=FALSE, issue_number_set = 0) nest_dynamics #nest_dynamics %>% glimpse() ``` ```{r} #### nested figures ------------------------------- nest_summary <- create_nest_summary(nest_dynamics = nest_dynamics, time_limit_fig02 = Inf) nest_summary #%>% glimpse() ``` ```{r} #### if a shapefile is available ---------------------- # nest_summary <- create_nest_summary_map(nest_dynamics = nest_dynamics, # geometry = ubigeo_geometria_per2, # strata_major=nm_pais, # strata_minor=nm_depa) ``` ```{r,eval=FALSE,echo=FALSE} #### if you want to write it ------------------------- # rt_write_rds(nest_summary = nest_summary, # rute = "", # name = "admx") ``` ```{r} region_name <- "all" nest_summary %>% filter(strata_major==region_name) %>% pull(fig01) %>% pluck(1) nest_summary %>% filter(strata_major==region_name) %>% pull(fig02) %>% pluck(1) nest_summary %>% filter(strata_major==region_name) %>% pull(fig03) %>% pluck(1) # nest_summary %>% # filter(strata_major==region_name) %>% # pull(fig04) %>% pluck(1) nest_summary %>% filter(strata_major==region_name) %>% pull(tab01) %>% pluck(1) nest_summary %>% filter(strata_major==region_name) %>% pull(tab02) %>% pluck(1) nest_summary %>% filter(strata_major==region_name) %>% pull(tab03) %>% pluck(1) nest_summary %>% filter(strata_major==region_name) %>% pull(tab04) %>% pluck(1) ``` ## Updated approaches - on incidence: https://github.com/reconhub/incidence2 - on time-varying transmission: https://epiforecasts.io/EpiNow2/ ## To do list - Document functions

Owner

  • Name: Andree Valle Campos
  • Login: avallecam
  • Kind: user
  • Location: Lima, Perú

pron: él/he/his, peruano, tusán.

GitHub Events

Total
Last Year

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 2
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 1
  • Total pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • 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
  • avallecam (2)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels