diff --git a/R/model_comparison.R b/R/model_comparison.R index 3c6dd0ff..c2bb29c9 100644 --- a/R/model_comparison.R +++ b/R/model_comparison.R @@ -6,10 +6,10 @@ #' @return rhats table #' @examples #' \dontrun{ -#' data("serodata") -#' data_test <- prepare_serodata(serodata = serodata) -#' model_constant <- run_seromodel(serodata = data_test, -#' foi_model = "constant", +#' data(chagas2012) +#' data_test <- prepare_serodata(serodata = chagas2012) +#' model_constant <- run_seromodel(serodata = data_test, +#' foi_model = "constant", #' n_iters = 1500) #' get_table_rhats(model_object = model_constant) #' } diff --git a/R/modelling.R b/R/modelling.R index 8558f109..1da29f19 100644 --- a/R/modelling.R +++ b/R/modelling.R @@ -43,9 +43,9 @@ #' @return \code{seromodel_object}. An object containing relevant information about the implementation of the model. For further details refer to \link{fit_seromodel}. #' @examples #' \dontrun{ -#' serodata <- prepare_serodata(serodata) -#' run_seromodel (serodata, -#' foi_model = "constant") +#' serodata <- prepare_serodata(chagas2012) +#' run_seromodel (chagas2012, +#' foi_model = "constant") #' } #' @export run_seromodel <- function(serodata, @@ -114,8 +114,8 @@ run_seromodel <- function(serodata, #' @examples #' \dontrun{ -#' data("serodata") -#' serodata <- prepare_serodata(serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) #' seromodel_fit <- fit_seromodel(serodata = serodata, #' foi_model = "constant") #' } @@ -255,8 +255,8 @@ fit_seromodel <- function(serodata, #' @return \code{exposure_ages}. An atomic vector with the numeration of the exposition years in serodata #' @examples #' \dontrun{ -#' data("serodata") -#' serodata <- prepare_serodata(serodata = serodata, alpha = 0.05) +#' data(chagas2012) +#' serodata <- prepare_serodata(serodata = chagas2012, alpha = 0.05) #' exposure_ages <- get_exposure_ages(serodata) #' } #' @export @@ -271,8 +271,8 @@ get_exposure_ages <- function(serodata) { #' @return \code{exposure_output}. An atomic matrix containing the expositions for each entry of \code{serodata} by year. #' @examples #' \dontrun{ -#' data("serodata") -#' serodata <- prepare_serodata(serodata = serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(serodata = chagas2012) #' exposure_matrix <- get_exposure_matrix(serodata = serodata) #' } #' @export @@ -313,8 +313,8 @@ get_exposure_matrix <- function(serodata) { #' } #' @examples #' \dontrun{ -#' data("serodata") -#' serodata <- prepare_serodata(serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) #' seromodel_object <- run_seromodel(serodata = serodata, #' foi_model = "constant") #' extract_seromodel_summary(seromodel_object) @@ -366,7 +366,8 @@ extract_seromodel_summary <- function(seromodel_object) { #' @return \code{prev_final}. The expanded prevalence data. This is used for plotting purposes in the \code{visualization} module. #' @examples #' \dontrun{ -#' serodata <- prepare_serodata(serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) #' seromodel_object <- run_seromodel(serodata = serodata, #' foi_model = "constant") #' foi <- rstan::extract(seromodel_object$fit, "foi")[[1]] diff --git a/R/serodata.R b/R/serodata.R deleted file mode 100644 index 1404ed4f..00000000 --- a/R/serodata.R +++ /dev/null @@ -1,15 +0,0 @@ -#' Seroprevalence data on serofoi -#' -#' Data from a serological surveys -#' -#' @docType data -#' -#' @usage serodata -#' -#' @format An object of class \code{"cross"}; see \code{\link[qtl]{read.cross}}. -#' -#' @keywords datasets -#' -#' @examples -#' serodata -"serodata" \ No newline at end of file diff --git a/R/seroprevalence_data.R b/R/seroprevalence_data.R index f4168cfe..8c466f26 100644 --- a/R/seroprevalence_data.R +++ b/R/seroprevalence_data.R @@ -30,8 +30,8 @@ #' } #' @examples #'\dontrun{ -#' data("serodata") -#' data_test <- prepare_serodata(serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) #' } #' @export prepare_serodata <- function(serodata = serodata, @@ -91,7 +91,8 @@ prepare_serodata <- function(serodata = serodata, #' @return data set with the binomial confidence intervals #' @examples #'\dontrun{ -#' prepare_bin_data (serodata) +#' data(chagas2012) +#' prepare_bin_data(chagas2012) #' } #' @export prepare_bin_data <- function(serodata) { diff --git a/R/visualisation.R b/R/visualisation.R index 26f7fd81..775b06eb 100644 --- a/R/visualisation.R +++ b/R/visualisation.R @@ -17,9 +17,10 @@ #' @return A ggplot object containing the seropositivity-vs-age graph of the raw data of a given seroprevalence survey with its corresponging binomial confidence interval. #' @examples #' \dontrun{ -#' data_test <- prepare_serodata(serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) #' seromodel_object <- run_seromodel( -#' serodata = data_test, +#' serodata = serodata, #' foi_model = "constant", #' n_iters = 1000 #') @@ -52,9 +53,9 @@ plot_seroprev <- function(serodata, #' @return A ggplot object containing the seropositivity-vs-age graph including the data, the fitted model and their corresponding confindence intervals. #' @examples #' \dontrun{ -#' data("serodata") -#' data_test <- prepare_serodata(serodata) -#' seromodel_object <- run_seromodel(serodata = data_test, +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) +#' seromodel_object <- run_seromodel(serodata = serodata, #' foi_model = "constant", #' n_iters = 1000) #' plot_seroprev_fitted(seromodel_object, size_text = 15) @@ -133,12 +134,13 @@ plot_seroprev_fitted <- function(seromodel_object, #' @return A ggplot2 object containing the Force-of-infection-vs-time including the corresponding confidence interval. #' @examples #' \dontrun{ -#' data_test <- prepare_serodata(serodata) -#' seromodel_object <- run_seromodel( -#' serodata = data_test, +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) +#' seromodel_object <- run_seromodel( +#' serodata = serodata, #' foi_model = "constant", #' n_iters = 1000 -#' ) +#' ) #' plot_foi(seromodel_object, size_text = 15) #' } #' @export @@ -228,14 +230,14 @@ plot_foi <- function(seromodel_object, #' @return The rhats-convergence plot of the selected model. #' @examples #' \dontrun{ -#' data("serodata") -#' data_test <- prepare_serodata(serodata) +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) #' seromodel_object <- run_seromodel( -#' serodata = data_test, +#' serodata = serodata, #' foi_model = "constant", #' n_iters = 1000 -#') -#' plot_rhats(seromodel_object, +#' ) +#' plot_rhats(seromodel_object, #' size_text = 15) #' } #' @export @@ -294,12 +296,13 @@ plot_rhats <- function(seromodel_object, #' @return A ggplot object with a vertical arrange containing the seropositivity, force of infection, and convergence plots. #' @examples #' \dontrun{ -#' data_test <- prepare_serodata(serodata) -#' seromodel_object <- run_seromodel( -#' serodata = data_test, -#' foi_model = "constant", -#' n_iters = 1000 -#') +#' data(chagas2012) +#' serodata <- prepare_serodata(chagas2012) +#' seromodel_object <- run_seromodel( +#' serodata = serodata, +#' foi_model = "constant", +#' n_iters = 1000 +#' ) #' plot_seromodel(seromodel_object, size_text = 15) #' } #' @export @@ -378,12 +381,12 @@ plot_seromodel <- function(seromodel_object, #' @return p the plot for the given table #' @examples #' \dontrun{ -#' data_test <- prepare_serodata(serodata) +#' serodata <- prepare_serodata(chagas2012) #' seromodel_object <- run_seromodel( -#' serodata = data_test, -#' foi_model = "constant", -#' n_iters = 1000 -#') +#' serodata = serodata, +#' foi_model = "constant", +#' n_iters = 1000 +#' ) #' info = t(seromodel_object$model_summary) #' plot_info_table (info, size_text = 15) #' } diff --git a/README.Rmd b/README.Rmd index e15802fb..65fc44b1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,7 +15,7 @@ knitr::opts_chunk$set( ) ``` -## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data +## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data @@ -47,22 +47,20 @@ remotes::install_github("epiverse-trace/serofoi") ```{r cleaning, include = FALSE, echo = TRUE} library(serofoi) -rownames(serodata) <- NULL - ``` ***serofoi*** provides a minimal serosurvey dataset, `serodata`, that can be used to test out the package. ```{r ex, include = TRUE} -# Load example serodata data included with the package -data("serodata") -head(serodata, 5) +# Load example dataset chagas2012 included with the package +data(chagas2012) +head(chagas2012, 5) ``` The function `prepare_serodata` will prepare the entry data for the use of the modelling module; this function computes the sample size, the years of birth and the binomial confidence interval for each age group in the provided dataset. A visualisation of the prepared seroprevalence data can be obtained using the function plot_seroprev: ```{r data_test, include = TRUE, out.fig.height="30%", out.width="50%", fig.align="center", message=FALSE} -serodata_test <- prepare_serodata(serodata) +serodata_test <- prepare_serodata(chagas2012) plot_seroprev(serodata_test, size_text = 15) ``` diff --git a/README.md b/README.md index 5eef2793..0b6a0862 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data +## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data @@ -48,9 +48,9 @@ remotes::install_github("epiverse-trace/serofoi") can be used to test out the package. ``` r -# Load example serodata data included with the package -data("serodata") -head(serodata, 5) +# Load example dataset chagas2012 included with the package +data(chagas2012) +head(chagas2012, 5) #> survey total counts age_min age_max tsur country test antibody #> 1 COL-035-93 34 0 1 1 2012 COL ELISA IgG anti-T.cruzi #> 2 COL-035-93 25 0 2 2 2012 COL ELISA IgG anti-T.cruzi @@ -66,7 +66,7 @@ in the provided dataset. A visualisation of the prepared seroprevalence data can be obtained using the function plot_seroprev: ``` r -serodata_test <- prepare_serodata(serodata) +serodata_test <- prepare_serodata(chagas2012) plot_seroprev(serodata_test, size_text = 15) ``` @@ -97,10 +97,10 @@ More details on how to use ***serofoi*** can be found in the [online documentation](https://epiverse-trace.github.io/serofoi/) as package vignettes, under [**Get Started**](https://epiverse-trace.github.io/serofoi/articles/serofoi.html), -[**FoI +[**An Introduction to FoI Models**](https://epiverse-trace.github.io/serofoi/articles/foi_models.html) -and [**Use -Cases**](https://epiverse-trace.github.io/serofoi/articles/use_cases.html) +and [**Real-life Use Cases for +serofoi**](https://epiverse-trace.github.io/serofoi/articles/use_cases.html) ## Help diff --git a/data/serodata.RData b/data/serodata.RData deleted file mode 100644 index f9570b14..00000000 Binary files a/data/serodata.RData and /dev/null differ diff --git a/man/extract_seromodel_summary.Rd b/man/extract_seromodel_summary.Rd index cd037799..106b1ca7 100644 --- a/man/extract_seromodel_summary.Rd +++ b/man/extract_seromodel_summary.Rd @@ -35,8 +35,8 @@ corresponding standar deviation. } \examples{ \dontrun{ -data("serodata") -serodata <- prepare_serodata(serodata) +data(chagas2012) +serodata <- prepare_serodata(chagas2012) seromodel_object <- run_seromodel(serodata = serodata, foi_model = "constant") extract_seromodel_summary(seromodel_object) diff --git a/man/figures/logo.svg b/man/figures/logo.svg index e6d58887..3ee0a32c 100644 --- a/man/figures/logo.svg +++ b/man/figures/logo.svg @@ -1,577 +1,40877 @@ - - - - - - - - - -