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

Full package review for v0.2.0 #341

Merged
merged 28 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
81bb6d5
Updates to data_from_epireview vignette
joshwlambert Jul 9, 2024
0b29aca
fix ebola delay variable in data_from_epireview
joshwlambert Jul 9, 2024
7c6f9da
clarify subsetting of multi-row entries in data_from_epireview
joshwlambert Jul 9, 2024
e9002b9
clarify wording on missing probability distribution in data_from_epir…
joshwlambert Jul 9, 2024
9d25944
add info on summary stat conversion in data_from_epireview
joshwlambert Jul 9, 2024
7e5fbdf
remove empty limitations section from data_from_epireview
joshwlambert Jul 9, 2024
588b8dd
Update URL in inst/CITATION
joshwlambert Jul 9, 2024
f38eca0
Return directly from switch() in as.function.epidist()
joshwlambert Jul 9, 2024
94f2433
Return directly from data.frame() in as.data.frame.epidist()
joshwlambert Jul 9, 2024
1902b92
Remove dev/ from URL in print.multi_epidist()
joshwlambert Jul 9, 2024
1275ce1
Remove unnecessary sprintf() from format.epidist()
joshwlambert Jul 9, 2024
c68c9ef
Improve wording in README intro
joshwlambert Jul 9, 2024
2f2d9d9
Automatic readme update
actions-user Jul 9, 2024
0e74977
Remove mention of loading {distributional} from epiparameter.Rmd
joshwlambert Jul 9, 2024
3144192
Improve wording on epiparameter library in epiparameter.Rmd
joshwlambert Jul 9, 2024
b9f2e6f
Remove technical note on epidist list printing in epiparameter.Rmd
joshwlambert Jul 9, 2024
646b158
print tail of appended db in epiparameter.Rmd
joshwlambert Jul 9, 2024
be14306
Clarify adding entries to database locally in epiparameter.Rmd
joshwlambert Jul 9, 2024
b0676b6
Improve wording on contributing in epiparameter.Rmd
joshwlambert Jul 9, 2024
30130cf
Remove text on generic functions in extract_convert.Rmd
joshwlambert Jul 9, 2024
be5bab3
add link to database vignette in README
joshwlambert Jul 9, 2024
2af686c
update google sheet link in README
joshwlambert Jul 9, 2024
b6b3787
refactor epiparameter.Rmd by reducing technical information on classe…
joshwlambert Jul 9, 2024
d74c15d
added @seealso tags linking convert_params_to_summary_stats and conve…
joshwlambert Jul 9, 2024
ce20e9c
Automatic readme update
actions-user Jul 9, 2024
1d812e6
updated WORDLIST
joshwlambert Jul 10, 2024
850b716
updated print.multi_epidist snapshots
joshwlambert Jul 10, 2024
e573593
add info on WHO workshop to NEWS.md
joshwlambert Jul 10, 2024
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

The second release of the {epiparameter} R package focuses on interoperability with the [{epireview} R package](https://mrc-ide.github.io/epireview/). Several functions have been refactored and enhanced.

This release benefited from feedback from the participants of an [EpiParameter Community workshop hosted by the World Health Organisation](https://who-collaboratory.github.io/collaboratory-epiparameter-community/#/pages/news).

## New features

* The `as_epidist()` S3 generic has been added to the package for the coercion of other R objects into `<epidist>` objects. The `as_epidist.data.frame()` method is added, as well as the internal functions `is_epireview()` which determines if a `<data.frame>` is from {epireview}, and `epireview_to_epidist()` performs the conversion (#298, #334 & #335)
Expand Down
16 changes: 5 additions & 11 deletions R/coercion.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ as.function.epidist <- function(x,
)
}
epidist <- x
x <- switch(func_type,
# return distribution function
switch(func_type,
density = function(x) density(x = epidist, at = x),
cdf = function(x) epiparameter::cdf(x = epidist, q = x),
generate = function(x) epiparameter::generate(x = epidist, times = x),
quantile = function(x) quantile(x = epidist, p = x)
)

# return distribution function
x
}


Expand All @@ -60,8 +58,7 @@ as.data.frame.epidist <- function(x, ...) {
# check object as could be invalidated by user
validate_epidist(x)

# make data frame
df <- data.frame(
data.frame(
disease = x$disease,
pathogen = x$pathogen,
epi_distribution = x$epi_dist,
Expand All @@ -71,12 +68,9 @@ as.data.frame.epidist <- function(x, ...) {
citation = I(x$citation),
metadata = I(list(metadata = x$metadata)),
method_assess = I(list(method_assess = x$method_assess)),
notes = x$notes
notes = x$notes,
row.names = NULL
)
row.names(df) <- NULL

# return data frame
df
}

#' [as.data.frame()] method for `<multi_epidist>` class
Expand Down
4 changes: 4 additions & 0 deletions R/convert_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#' statistics used to convert to parameter(s). An example is the `mean`
#' and `sd` summary statistics for the lognormal (`lnorm`) distribution.
#'
#' @seealso [convert_params_to_summary_stats()]
#'
#' @return A list of either one or two elements (depending on how many
#' parameters the distribution has).
#' @export
Expand Down Expand Up @@ -154,6 +156,8 @@ convert_summary_stats_to_params.epidist <- function(x, ...) {
#' used to convert to summary statistics. An example is the `meanlog` and
#' `sdlog` parameters of the lognormal (`lnorm`) distribution.
#'
#' @seealso [convert_summary_stats_to_params()]
#'
#' @return A list of eight elements including: mean, median, mode,
#' variance (`var`), standard deviation (`sd`), coefficient of variation (`cv`),
#' skewness, and excess kurtosis (`ex_kurtosis`).
Expand Down
2 changes: 1 addition & 1 deletion R/epidist.R
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ format.epidist <- function(x, header = TRUE, vb = NULL, ...) {
)
writeLines(sprintf(dist_string, family(x)))
} else {
writeLines(sprintf("Parameters: <no parameters>"))
writeLines("Parameters: <no parameters>")
}

if (is.object(x$prob_dist)) {
Expand Down
4 changes: 2 additions & 2 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ print.multi_epidist <- function(x, ..., n = NULL) {
" Use `parameter_tbl()` to see a summary table of the parameters.\n",
"# ", cli::symbol$info, " Explore database online at: ",
cli::style_hyperlink(
text = "https://epiverse-trace.github.io/epiparameter/dev/articles/database.html", # nolint line_length_linter
url = "https://epiverse-trace.github.io/epiparameter/dev/articles/database.html" # nolint line_length_linter
text = "https://epiverse-trace.github.io/epiparameter/articles/database.html", # nolint line_length_linter
url = "https://epiverse-trace.github.io/epiparameter/articles/database.html" # nolint line_length_linter
)
)
)
Expand Down
6 changes: 4 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ knitr::opts_chunk$set(
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11110881.svg)](https://doi.org/10.5281/zenodo.11110881)
<!-- badges: end -->

`{epiparameter}` is an `R` package that contains a library of epidemiological parameters for infectious diseases and a set classes and helper functions to be able to work with the data. It also includes functions to extract and convert parameters from reported summary statistics.
`{epiparameter}` is an `R` package that contains a library of epidemiological parameters for infectious diseases and a set of classes and helper functions to work with the data. It also includes functions to extract and convert parameters from reported summary statistics.

`{epiparameter}` is developed at the [Centre for the Mathematical Modelling of Infectious Diseases](https://www.lshtm.ac.uk/research/centres/centre-mathematical-modelling-infectious-diseases) at the [London School of Hygiene and Tropical Medicine](https://www.lshtm.ac.uk/) as part of [Epiverse-TRACE](https://data.org/initiatives/epiverse/).

Expand Down Expand Up @@ -60,6 +60,8 @@ epidists

This results a list of database entries. Each entry of the library is an `<epidist>` object.

Alternatively, the library of epiparameters can be viewed as a vignette locally (`vignette("database", package = "epiparameter")`) or on the [{epiparameter} website](https://epiverse-trace.github.io/epiparameter/articles/database.html).

The results can be filtered by disease and epidemiological distribution. Here we set `single_epidist = TRUE` as we only want a single database entry returned, and by default (`single_epidist = FALSE`) it will return all database entries that match the disease (`disease`) and epidemiological distribution (`epi_dist`).

```{r load-single-epidist}
Expand Down Expand Up @@ -112,7 +114,7 @@ The parameters of a probability distribution can also be extracted from other su

## Contributing to library of epidemiological parameters

If you would like to contribute to the different epidemiological parameters stored in the `{epiparameter}` package, you can add data to a public [google sheet](https://docs.google.com/spreadsheets/d/1zVpaaKkQ7aeMdRN2r0p-W4d2TtccL5HcIOp_w-lfkEQ/edit?usp=sharing). This spreadsheet contains two example entries as a guide to what fields can accept. We are monitoring this sheet for new entries that will subsequently be included in the package.
If you would like to contribute to the different epidemiological parameters stored in the `{epiparameter}` package, you can add data to a public [google sheet](https://docs.google.com/spreadsheets/d/1eCL3n_woseg5Npu7XD7TcuNoLUIhMBu8ZoLCkVdATUE/edit?usp=sharing). This spreadsheet contains two example entries as a guide to what fields can accept. We are monitoring this sheet for new entries that will subsequently be included in the package.

Alternatively, parameters can be added to the [JSON file holding the data](https://github.com/epiverse-trace/epiparameter/blob/main/inst/extdata/parameters.json) base directly via a Pull Request.

Expand Down
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h
<!-- badges: end -->

`{epiparameter}` is an `R` package that contains a library of
epidemiological parameters for infectious diseases and a set classes and
helper functions to be able to work with the data. It also includes
functions to extract and convert parameters from reported summary
statistics.
epidemiological parameters for infectious diseases and a set of classes
and helper functions to work with the data. It also includes functions
to extract and convert parameters from reported summary statistics.

`{epiparameter}` is developed at the [Centre for the Mathematical
Modelling of Infectious
Expand Down Expand Up @@ -59,9 +58,6 @@ epidists <- epidist_db()
#> Returning 122 results that match the criteria (99 are parameterised).
#> Use subset to filter by entry variables or single_epidist to return a single entry.
#> To retrieve the citation for each use the 'get_citation' function
```

``` r
epidists
#> # List of 122 <epidist> objects
#> Number of diseases: 23
Expand Down Expand Up @@ -113,12 +109,17 @@ epidists
#> # ℹ 119 more elements
#> # ℹ Use `print(n = ...)` to see more elements.
#> # ℹ Use `parameter_tbl()` to see a summary table of the parameters.
#> # ℹ Explore database online at: https://epiverse-trace.github.io/epiparameter/dev/articles/database.html
#> # ℹ Explore database online at: https://epiverse-trace.github.io/epiparameter/articles/database.html
```

This results a list of database entries. Each entry of the library is an
`<epidist>` object.

Alternatively, the library of epiparameters can be viewed as a vignette
locally (`vignette("database", package = "epiparameter")`) or on the
[{epiparameter}
website](https://epiverse-trace.github.io/epiparameter/articles/database.html).

The results can be filtered by disease and epidemiological distribution.
Here we set `single_epidist = TRUE` as we only want a single database
entry returned, and by default (`single_epidist = FALSE`) it will return
Expand All @@ -137,9 +138,6 @@ influenza_incubation <- epidist_db(
#> Virus Infections." _American Journal of Epidemiology_.
#> doi:10.1093/aje/kwv115 <https://doi.org/10.1093/aje/kwv115>..
#> To retrieve the citation use the 'get_citation' function
```

``` r
influenza_incubation
#> Disease: Influenza
#> Pathogen: Influenza-A-H7N9
Expand Down Expand Up @@ -177,9 +175,6 @@ parameter_tbl(epidists)
#> 9 RSV RSV incubation peri… lnorm Lessl… 2009 24
#> 10 Rhinovi… Rhinovi… incubation peri… lnorm Lessl… 2009 28
#> # ℹ 112 more rows
```

``` r
parameter_tbl(
epidists,
epi_dist = "onset to hospitalisation"
Expand Down Expand Up @@ -237,7 +232,7 @@ or the median and range of the data. This can be done for:
If you would like to contribute to the different epidemiological
parameters stored in the `{epiparameter}` package, you can add data to a
public [google
sheet](https://docs.google.com/spreadsheets/d/1zVpaaKkQ7aeMdRN2r0p-W4d2TtccL5HcIOp_w-lfkEQ/edit?usp=sharing).
sheet](https://docs.google.com/spreadsheets/d/1eCL3n_woseg5Npu7XD7TcuNoLUIhMBu8ZoLCkVdATUE/edit?usp=sharing).
This spreadsheet contains two example entries as a guide to what fields
can accept. We are monitoring this sheet for new entries that will
subsequently be included in the package.
Expand Down Expand Up @@ -277,7 +272,7 @@ citation("epiparameter")
#> Epidemiological Parameters with Helper Functions and Classes_.
#> doi:10.5281/zenodo.11110881
#> <https://doi.org/10.5281/zenodo.11110881>,
#> <https://github.com/epiverse-trace/epiparameter/,https://epiverse-trace.github.io/epiparameter/>.
#> <https://epiverse-trace.github.io/epiparameter>.
#>
#> A BibTeX entry for LaTeX users is
#>
Expand All @@ -286,7 +281,6 @@ citation("epiparameter")
#> author = {Joshua W. Lambert and Adam Kucharski and Carmen Tamayo},
#> year = {2024},
#> doi = {10.5281/zenodo.11110881},
#> url = {https://github.com/epiverse-trace/epiparameter/,
#> https://epiverse-trace.github.io/epiparameter/},
#> url = {https://epiverse-trace.github.io/epiparameter},
#> }
```
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ bibentry(
author = author,
year = date,
doi = "10.5281/zenodo.11110881",
url = meta$URL
url = "https://epiverse-trace.github.io/epiparameter"
)
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ distcrete
dplyr
ebola
epidist
EpiParameter
epiparameters
epireview
episoap
Epiverse
Expand Down
3 changes: 3 additions & 0 deletions man/convert_params_to_summary_stats.Rd

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

3 changes: 3 additions & 0 deletions man/convert_summary_stats_to_params.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
# i 119 more elements
# i Use `print(n = ...)` to see more elements.
# i Use `parameter_tbl()` to see a summary table of the parameters.
# i Explore database online at: https://epiverse-trace.github.io/epiparameter/dev/articles/database.html
# i Explore database online at: https://epiverse-trace.github.io/epiparameter/articles/database.html

# epidist_db print method works as expected for <= 5 <epidist>

Expand Down Expand Up @@ -98,5 +98,5 @@
dispersion: 0.170

# i Use `parameter_tbl()` to see a summary table of the parameters.
# i Explore database online at: https://epiverse-trace.github.io/epiparameter/dev/articles/database.html
# i Explore database online at: https://epiverse-trace.github.io/epiparameter/articles/database.html

Loading
Loading