Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove serodata from pre-loaded datasets of the package #107

Merged
merged 6 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/model_comparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#' }
Expand Down
25 changes: 13 additions & 12 deletions R/modelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
#' }
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]]
Expand Down
15 changes: 0 additions & 15 deletions R/serodata.R

This file was deleted.

7 changes: 4 additions & 3 deletions R/seroprevalence_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
53 changes: 28 additions & 25 deletions R/visualisation.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
#' }
Expand Down
12 changes: 5 additions & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ knitr::opts_chunk$set(
)
```

## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data <img src="man/figures/serofoi-logo.png" align="right" width="130"/>
## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data <img src="man/figures/logo.svg" align="right" width="130"/>

<!-- badges: start -->

Expand Down Expand Up @@ -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)
```

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data <img src="man/figures/serofoi-logo.png" align="right" width="130"/>
## *serofoi*: force-of-infection from population based serosurveys with age-disagregated data <img src="man/figures/logo.svg" align="right" width="130"/>

<!-- badges: start -->

Expand Down Expand Up @@ -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
Expand All @@ -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)
```

Expand Down Expand Up @@ -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

Expand Down
Binary file removed data/serodata.RData
Binary file not shown.
4 changes: 2 additions & 2 deletions man/extract_seromodel_summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading