Skip to content

Commit

Permalink
rename class vip_population -> popim_population
Browse files Browse the repository at this point in the history
  • Loading branch information
tinigarske committed Mar 8, 2024
1 parent 7edaf66 commit bfc9627
Show file tree
Hide file tree
Showing 34 changed files with 130 additions and 129 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export(apply_vaccs)
export(calc_pop_immunity)
export(complete_vacc_activities)
export(plot_immunity)
export(popim_population)
export(read_vacc_activities)
export(vacc_from_immunity)
export(vip_pop_from_file)
export(vip_population)
importFrom(rlang,.data)
18 changes: 9 additions & 9 deletions R/apply_vacc.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
##' If the vaccination activity has non-missing entries for both
##' coverage and doses, the coverage is used - there is no test
##' whether the coverage and doses information are consistent with the
##' target population size in the vip_population object to which the
##' target population size in the popim_population object to which the
##' vaccination activity is applied.
##'
##' @param pop_df population dataframe object such as created by
##' function 'vip_population'
##' function 'popim_population'
##' @param region region of the vaccination activity
##' @param year year of the vaccination activity
##' @param age_first age of the youngest age group targeted
Expand Down Expand Up @@ -71,11 +71,11 @@ apply_vacc <- function(pop_df, region, year, age_first = 0, age_last = Inf,
##'
##' Takes the vaccination activities listed in the input object
##' vaccs_df (a data.frame object of class vip_vacc_activities), and
##' applies them to the vip_population object pop_df, then returns
##' applies them to the popim_population object pop_df, then returns
##' that updated object.
##'
##' @param pop_df object of class vip_population such as created by
##' function 'vip_population'
##' @param pop_df object of class popim_population such as created by
##' function 'popim_population'
##' @param vaccs_df object of class 'vip_vacc_activities' such as
##' created by reading from file with function
##' 'read_vacc_activities'
Expand Down Expand Up @@ -106,8 +106,8 @@ apply_vaccs <- function(pop_df, vaccs_df) {
##' given number of doses. The target population is the sum of the
##' population of the targeted age groups in the targeted region(s).
##'
##' @param pop_df object of class vip_population such as created by
##' function `vip_population`
##' @param pop_df object of class popim_population such as created by
##' function `popim_population`
##' @param doses number of vaccine doses available for the vaccination
##' activity
##' @param region region to be targeted
Expand Down Expand Up @@ -158,8 +158,8 @@ coverage_from_doses <- function(pop_df, doses, region, year, age_first = 0,
##' is the sum of the population of the targeted age groups in the
##' targeted region(s).
##'
##' @param pop_df object of class vip_population such as created by
##' function `vip_population`
##' @param pop_df object of class popim_population such as created by
##' function `popim_population`
##' @param coverage proportion of the target population to be covered,
##' 0 <= coverage <= 1
##' @param region region to be targeted
Expand Down
6 changes: 3 additions & 3 deletions R/calc_new_immunity.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ assert_valid_targeting <- function(x, name = deparse(substitute(x))) {
}

##' Calculate the overall population immunity (aggregating over age)
##' from the supplied vip_population object
##' from the supplied popim_population object
##'
##' @param pop vip_population object for which the population size and
##' @param pop popim_population object for which the population size and
##' immunity will be aggregated over age.
##' @return dataframe containing the vip_population aggregated by age.
##' @return dataframe containing the popim_population aggregated by age.
##' @author Tini Garske
##' @export
calc_pop_immunity <- function(pop) {
Expand Down
6 changes: 3 additions & 3 deletions R/is_population.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
##' Test if argument is a valid vip_population object
##' Test if argument is a valid popim_population object
##'
##' This function tests whether the supplied argument is a valid
##' population dataframe such as might be generated by the function
##' "vip_population".
##' "popim_population".
##' @param x argument to be tested if it fulfils the requirements for
##' a population dataframe.
##' @param tol numerical, determines the tolerance when comparing two
##' numbers. Defaults to the square root of machine
##' precision. This is used for checking if the cohort == year -
##' age (as the cohort column is redundant).
##' @return logical: TRUE if the argument is a valid vip_population
##' @return logical: TRUE if the argument is a valid popim_population
##' object, FALSE otherwise.
##' @author Tini Garske
##' @noRd
Expand Down
4 changes: 2 additions & 2 deletions R/util_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ assert_is <- function(x, what, name = deparse(substitute(x))) {
}

assert_population <- function(x, name = deparse(substitute(x))) {
if(!inherits(x, "vip_population"))
stop(sprintf("'%s' must be of class 'vip_population'", name),
if(!inherits(x, "popim_population"))
stop(sprintf("'%s' must be of class 'popim_population'", name),
call. = FALSE)
}

Expand Down
10 changes: 5 additions & 5 deletions R/vacc_from_immunity.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##' Infer vaccination activities from population
##'
##' Given a vip_population object and an assumption of how vaccine is
##' Given a popim_population object and an assumption of how vaccine is
##' targeted in a partially immune population, this function infers
##' the vaccination activities that returns a vip_vacc_activities
##' object that details the vaccination activities that have given
Expand All @@ -26,7 +26,7 @@
##' also never be picked up as this age group will have aged out of
##' the population (i.e., died) before the immunity is updated in the
##' next year.
##' @param pop vip_population object for which vaccination activities
##' @param pop popim_population object for which vaccination activities
##' are to be inferred
##' @param targeting string to determine the assumption of how doses
##' are allocated. Valid options are "random", "correlated",
Expand Down Expand Up @@ -68,10 +68,10 @@ vacc_from_immunity <- function(pop, targeting = "random", n_digits = 10) {
vaccs
}

##' Add the rate of immunity change to a vip_population object
##' Add the rate of immunity change to a popim_population object
##'
##' @param pop vip_population_object
##' @return the input vip_population object with an added column
##' @param pop popim_population_object
##' @return the input popim_population object with an added column
##' `immunity_diff` that holds the difference in immunity between
##' the current and next year.
##' @author Tini Garske
Expand Down
10 changes: 5 additions & 5 deletions R/vip_vacc_activities.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##'
##' The "vip_vacc_activities" object is a dataframe that holds
##' information on vaccination activities that are typically meant to
##' be applied to a "vip_population" object.
##' be applied to a "popim_population" object.
##'
##' The input parameters are the columns of the "vip_vacc_activities"
##' object to be returned, they should be vectors of the same length,
Expand Down Expand Up @@ -118,8 +118,8 @@ validate_vacc_activities <- function(x, name = deparse(substitute(x))) {
##' "vip_vacc_activities" object generated here), these can be
##' converted into each other, when both are given, they may be
##' inconsistent with each other once applied to a specific
##' "vip_population" object. The consistency between these two colums
##' cannot be confirmed in without reference to a vip_population
##' "popim_population" object. The consistency between these two colums
##' cannot be confirmed in without reference to a popim_population
##' object, but this function requires that at least one of these is
##' non-missing in each row.
##'
Expand Down Expand Up @@ -168,13 +168,13 @@ read_vacc_activities <- function(file) {
##'
##' For each line in the "vip_vacc_activities" object the given
##' information of coverage is converted to doses, or vice versa,
##' using the target population size implied by the "vip_population"
##' using the target population size implied by the "popim_population"
##' object supplied. If both coverage and doses are given for any
##' activity, the function checks if they are consistent with the
##' population size, and fails if there are any inconsistencies.
##'
##' @param vaccs vip_vaccination_activities object
##' @param pop_df vip_population object
##' @param pop_df popim_population object
##' @return vip_vaccination_activities object, updated to have both
##' doses and coverage information
##' @author Tini Garske
Expand Down
18 changes: 9 additions & 9 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ knitr::opts_chunk$set(
)
```

# vip
# popim

<!-- badges: start -->
[![R-CMD-check](https://github.com/mrc-ide/vip/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mrc-ide/vip/actions/workflows/R-CMD-check.yaml)
Expand All @@ -29,29 +29,29 @@ target specific age groups.

## Installation

You can install the development version of vip from
You can install the development version of popim from
[GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("mrc-ide/vip")
devtools::install_github("mrc-ide/popim")
```

## Example 1

This package defines an S3 class `vip_population` which is a dataframe
This package defines an S3 class `popim_population` which is a dataframe
with at least the columns year, age, cohort (the year of birth for the
individuals tracked in this row), and immunity (as a proportion of
this cohort). Year, age and cohort are tracked as annual time steps
and age groups.

A basic, totally naive population dataframe can be setup using the
function `vip_population()`:
function `popim_population()`:

```{r example}
library(vip)
library(popim)
pop <- vip_population(region = c("UK", "FRA"), year_min = 2000, year_max = 2010,
pop <- popim_population(region = c("UK", "FRA"), year_min = 2000, year_max = 2010,
age_min = 0, age_max = 10)
dim(pop)
Expand Down Expand Up @@ -112,7 +112,7 @@ diagonal fashion.
## Example 2

A more realistic scenario is to read in some real population data to
set up the vip_population, and then apply some vaccination activities
set up the popim_population, and then apply some vaccination activities
to this. Information on the vaccination activities may be given in
coverage (typical for routine infant vaccination) or doses (typical
for mass vaccination campaigns).
Expand Down Expand Up @@ -198,7 +198,7 @@ ggplot(pop_agg, aes(x = year, y = immunity, col = region)) +
```

Given a `vip_population` object, the vaccination activities that would
Given a `popim_population` object, the vaccination activities that would
be needed to achieve the specified population immunity can be inferred
with the function `vacc_from_immunity()`, given an assumption on the
targeting method of the vaccination activities. Using this function on
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# vip
# popim

<!-- badges: start -->

[![R-CMD-check](https://github.com/mrc-ide/vip/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mrc-ide/vip/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

**Vaccine Immunity Propagation**
Expand All @@ -17,29 +18,29 @@ age groups.

## Installation

You can install the development version of vip from
You can install the development version of popim from
[GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("mrc-ide/vip")
devtools::install_github("mrc-ide/popim")
```

## Example 1

This package defines an S3 class `vip_population` which is a dataframe
This package defines an S3 class `popim_population` which is a dataframe
with at least the columns year, age, cohort (the year of birth for the
individuals tracked in this row), and immunity (as a proportion of this
cohort). Year, age and cohort are tracked as annual time steps and age
groups.

A basic, totally naive population dataframe can be setup using the
function `vip_population()`:
function `popim_population()`:

``` r
library(vip)
library(popim)

pop <- vip_population(region = c("UK", "FRA"), year_min = 2000, year_max = 2010,
pop <- popim_population(region = c("UK", "FRA"), year_min = 2000, year_max = 2010,
age_min = 0, age_max = 10)

dim(pop)
Expand Down Expand Up @@ -115,7 +116,7 @@ fashion.
## Example 2

A more realistic scenario is to read in some real population data to set
up the vip\_population, and then apply some vaccination activities to
up the popim\_population, and then apply some vaccination activities to
this. Information on the vaccination activities may be given in coverage
(typical for routine infant vaccination) or doses (typical for mass
vaccination campaigns).
Expand Down Expand Up @@ -274,7 +275,7 @@ ggplot(pop_agg, aes(x = year, y = immunity, col = region)) +

<img src="man/figures/README-calc_pop_immunity-1.png" width="100%" />

Given a `vip_population` object, the vaccination activities that would
Given a `popim_population` object, the vaccination activities that would
be needed to achieve the specified population immunity can be inferred
with the function `vacc_from_immunity()`, given an assumption on the
targeting method of the vaccination activities. Using this function on
Expand Down
8 changes: 4 additions & 4 deletions man/add_immunity_rate.Rd

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

4 changes: 2 additions & 2 deletions man/apply_vacc.Rd

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

6 changes: 3 additions & 3 deletions man/apply_vaccs.Rd

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

8 changes: 4 additions & 4 deletions man/calc_pop_immunity.Rd

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

Loading

0 comments on commit bfc9627

Please sign in to comment.