From d5e42e570b150c716801ada143c51e437bacb2e2 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Wed, 15 Nov 2023 14:50:03 +0000 Subject: [PATCH 1/4] updated list_distributions to only convert data and not read data --- R/list_distributions.R | 28 ++++++++-------------------- man/list_distributions.Rd | 23 +++++++++-------------- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/R/list_distributions.R b/R/list_distributions.R index 5384c9907..775823ae7 100644 --- a/R/list_distributions.R +++ b/R/list_distributions.R @@ -13,34 +13,22 @@ #' @inheritParams epidist #' @param multi_epidist Either an `` object or a list of `` #' objects. -#' @param ... [dots] Extra arguments to be passed to [epidist_db()]. #' -#' @author Adam Kucharski, Joshua W. Lambert +#' @author Joshua W. Lambert, Adam Kucharski #' @export #' @examples -#' list_distributions(disease = "COVID-19", epi_dist = "incubation_period") -#' -#' # example using list of `` objects in memory -#' epidist_lst <- epidist_db(disease = "COVID-19") -#' list_distributions(multi_epidist = epidist_lst) +#' epidist_list <- epidist_db(disease = "COVID-19") +#' list_distributions(multi_epidist = epidist_list) #' #' # example filtering an existing list to incubation periods -#' epidist_lst <- epidist_db(disease = "COVID-19") +#' epidist_list <- epidist_db(disease = "COVID-19") #' list_distributions( -#' multi_epidist = epidist_lst, +#' multi_epidist = epidist_list, #' epi_dist = "incubation period" #' ) -list_distributions <- function(disease = "all", - epi_dist = "all", - ..., - multi_epidist) { - # read in data if not given - if (missing(multi_epidist)) { - multi_epidist <- suppressMessages( - epidist_db(disease = disease, epi_dist = epi_dist, ...) - ) - } - +list_distributions <- function(multi_epidist, + disease = "all", + epi_dist = "all") { # wrap in list for apply functions if (is_epidist(multi_epidist)) { multi_epidist <- list(multi_epidist) diff --git a/man/list_distributions.Rd b/man/list_distributions.Rd index c9f4812dc..7021c2ac3 100644 --- a/man/list_distributions.Rd +++ b/man/list_distributions.Rd @@ -4,18 +4,16 @@ \alias{list_distributions} \title{List epidemiological distributions stored in the epiparameter library} \usage{ -list_distributions(disease = "all", epi_dist = "all", ..., multi_epidist) +list_distributions(multi_epidist, disease = "all", epi_dist = "all") } \arguments{ +\item{multi_epidist}{Either an \verb{} object or a list of \verb{} +objects.} + \item{disease}{A \code{character} string with name of the infectious disease.} \item{epi_dist}{A \code{character} string with the name of the epidemiological distribution type.} - -\item{...}{\link{dots} Extra arguments to be passed to \code{\link[=epidist_db]{epidist_db()}}.} - -\item{multi_epidist}{Either an \verb{} object or a list of \verb{} -objects.} } \description{ This function subsets the epidemiological parameter library to @@ -30,19 +28,16 @@ vector columns and some list columns. For example, the \code{author} column is a list as each paper can contain multiple authors. } \examples{ -list_distributions(disease = "COVID-19", epi_dist = "incubation_period") - -# example using list of `` objects in memory -epidist_lst <- epidist_db(disease = "COVID-19") -list_distributions(multi_epidist = epidist_lst) +epidist_list <- epidist_db(disease = "COVID-19") +list_distributions(multi_epidist = epidist_list) # example filtering an existing list to incubation periods -epidist_lst <- epidist_db(disease = "COVID-19") +epidist_list <- epidist_db(disease = "COVID-19") list_distributions( - multi_epidist = epidist_lst, + multi_epidist = epidist_list, epi_dist = "incubation period" ) } \author{ -Adam Kucharski, Joshua W. Lambert +Joshua W. Lambert, Adam Kucharski } From 474fa54322efb7a4a92dd9a46e05c2576910271e Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Wed, 15 Nov 2023 14:50:20 +0000 Subject: [PATCH 2/4] updated list_distributions tests --- tests/testthat/_snaps/list_distributions.md | 414 -------------------- tests/testthat/test-list_distributions.R | 74 +--- 2 files changed, 2 insertions(+), 486 deletions(-) diff --git a/tests/testthat/_snaps/list_distributions.md b/tests/testthat/_snaps/list_distributions.md index c2ee50786..0a20e34a3 100644 --- a/tests/testthat/_snaps/list_distributions.md +++ b/tests/testthat/_snaps/list_distributions.md @@ -242,250 +242,6 @@ 117 Fengying.... 2022 118 Fengying.... 2022 -# list_distributions works as expected without db - - Code - dist_tbl - Output - disease epi_distribution - 1 Adenovirus incubation period - 2 Human Coronavirus incubation period - 3 SARS incubation period - 4 Influenza incubation period - 5 Influenza incubation period - 6 Influenza incubation period - 7 Measles incubation period - 8 Parainfluenza incubation period - 9 RSV incubation period - 10 Rhinovirus incubation period - 11 Influenza incubation period - 12 Influenza incubation period - 13 RSV incubation period - 14 RSV incubation period - 15 Influenza incubation period - 16 Influenza incubation period - 17 Influenza incubation period - 18 Influenza incubation period - 19 Influenza incubation period - 20 Influenza incubation period - 21 Influenza incubation period - 22 Influenza incubation period - 23 Influenza incubation period - 24 Influenza serial interval - 25 Influenza incubation period - 26 Influenza generation time - 27 Marburg Virus Disease incubation period - 28 Marburg Virus Disease incubation period - 29 Marburg Virus Disease serial interval - 30 Marburg Virus Disease onset to death - 31 Marburg Virus Disease serial interval - 32 SARS offspring distribution - 33 SARS offspring distribution - 34 Smallpox offspring distribution - 35 Smallpox offspring distribution - 36 Smallpox offspring distribution - 37 Smallpox offspring distribution - 38 Mpox offspring distribution - 39 Pneumonic Plague offspring distribution - 40 Hantavirus Pulmonary Syndrome offspring distribution - 41 Ebola Virus Disease offspring distribution - 42 Dengue incubation period - 43 Dengue incubation period - 44 Dengue incubation period - 45 Zika Virus Disease incubation period - 46 Chikungunya incubation period - 47 Dengue incubation period - 48 Dengue incubation period - 49 Japanese Encephalitis incubation period - 50 Rift Valley Fever incubation period - 51 West Nile Fever incubation period - 52 West Nile Fever incubation period - 53 West Nile Fever incubation period - 54 Yellow Fever incubation period - 55 Yellow Fever incubation period - 56 Mpox incubation period - 57 Mpox incubation period - 58 Mpox incubation period - 59 Mpox incubation period - 60 Mpox incubation period - 61 Mpox serial interval - 62 Mpox serial interval - 63 Ebola Virus Disease incubation period - 64 Ebola Virus Disease onset to death - 65 Ebola Virus Disease incubation period - 66 Ebola Virus Disease incubation period - 67 Ebola Virus Disease incubation period - 68 Ebola Virus Disease incubation period - 69 Ebola Virus Disease serial interval - 70 Ebola Virus Disease serial interval - 71 Ebola Virus Disease serial interval - 72 Ebola Virus Disease serial interval - 73 Ebola Virus Disease hospitalisation to death - 74 Ebola Virus Disease hospitalisation to discharge - 75 Ebola Virus Disease notification to death - 76 Ebola Virus Disease notification to discharge - 77 Ebola Virus Disease onset to death - 78 Ebola Virus Disease onset to discharge - 79 MERS incubation period - 80 MERS serial interval - 81 MERS onset to hospitalisation - 82 MERS onset to death - 83 MERS onset to ventilation - 84 MERS onset to death - 85 MERS incubation period - 86 MERS serial interval - 87 COVID-19 incubation period - 88 COVID-19 incubation period - 89 COVID-19 incubation period - 90 COVID-19 serial interval - 91 COVID-19 incubation period - 92 COVID-19 incubation period - 93 COVID-19 incubation period - 94 COVID-19 incubation period - 95 COVID-19 incubation period - 96 COVID-19 incubation period - 97 COVID-19 onset to hospitalisation - 98 COVID-19 onset to hospitalisation - 99 COVID-19 onset to death - 100 COVID-19 hospitalisation to death - 101 COVID-19 incubation period - 102 COVID-19 onset to hospitalisation - 103 COVID-19 onset to hospitalisation - 104 COVID-19 onset to death - 105 COVID-19 hospitalisation to death - 106 COVID-19 incubation period - 107 COVID-19 incubation period - 108 COVID-19 incubation period - 109 COVID-19 incubation period - 110 Mpox serial interval - 111 Mpox serial interval - 112 Mpox serial interval - 113 Mpox incubation period - 114 Mpox incubation period - 115 Mpox incubation period - 116 Mpox incubation period - 117 Mpox incubation period - 118 Mpox incubation period - prob_distribution author year - 1 lnorm Justin L.... 2009 - 2 lnorm Justin L.... 2009 - 3 lnorm Justin L.... 2009 - 4 lnorm Justin L.... 2009 - 5 lnorm Justin L.... 2009 - 6 lnorm Justin L.... 2009 - 7 lnorm Justin L.... 2009 - 8 lnorm Justin L.... 2009 - 9 lnorm Justin L.... 2009 - 10 lnorm Justin L.... 2009 - 11 lnorm Nicholas.... 2009 - 12 lnorm Nicholas.... 2009 - 13 lnorm Nicholas.... 2009 - 14 lnorm Nicholas.... 2009 - 15 gamma Hiroshi .... 2011 - 16 weibull Hiroshi .... 2011 - 17 weibull Victor V.... 2015 - 18 gamma Victor V.... 2015 - 19 weibull Victor V.... 2016 - 20 weibull Victor V.... 2016 - 21 weibull Victor V.... 2016 - 22 lnorm Ashleigh.... 2010 - 23 gamma Azra Gha.... 2009 - 24 gamma Azra Gha.... 2009 - 25 lnorm Justin L.... 2009 - 26 weibull Justin L.... 2009 - 27 Boris I..... 2014 - 28 Boris I..... 2014 - 29 Boris I..... 2014 - 30 Robert C.... 2007 - 31 gamma Marco Aj.... 2012 - 32 nbinom J. O. Ll.... 2005 - 33 nbinom J. O. Ll.... 2005 - 34 nbinom J. O. Ll.... 2005 - 35 nbinom J. O. Ll.... 2005 - 36 nbinom J. O. Ll.... 2005 - 37 nbinom J. O. Ll.... 2005 - 38 nbinom J. O. Ll.... 2005 - 39 nbinom J. O. Ll.... 2005 - 40 nbinom J. O. Ll.... 2005 - 41 nbinom J. O. Ll.... 2005 - 42 lnorm Miranda .... 2012 - 43 lnorm Miranda .... 2012 - 44 lnorm Miranda .... 2012 - 45 lnorm Justin L.... 2016 - 46 lnorm Kara E R.... 2014 - 47 lnorm Kara E R.... 2014 - 48 lnorm Kara E R.... 2014 - 49 lnorm Kara E R.... 2014 - 50 lnorm Kara E R.... 2014 - 51 lnorm Kara E R.... 2014 - 52 lnorm Kara E R.... 2014 - 53 lnorm Kara E R.... 2014 - 54 lnorm Kara E R.... 2014 - 55 lnorm Kara E R.... 2014 - 56 lnorm Fuminari.... 2022 - 57 lnorm Kelly Ch.... 2022 - 58 gamma Giorgio .... 2022 - 59 lnorm Zachary .... 2022 - 60 lnorm Zachary .... 2022 - 61 gamma Zachary .... 2022 - 62 gamma Zachary .... 2022 - 63 lnorm Martin E.... 2011 - 64 gamma The-Ebol.... 2018 - 65 gamma WHO-Ebol.... 2015 - 66 gamma WHO-Ebol.... 2015 - 67 gamma WHO-Ebol.... 2015 - 68 gamma WHO-Ebol.... 2015 - 69 gamma WHO-Ebol.... 2015 - 70 gamma WHO-Ebol.... 2015 - 71 gamma WHO-Ebol.... 2015 - 72 gamma WHO-Ebol.... 2015 - 73 gamma WHO-Ebol.... 2015 - 74 gamma WHO-Ebol.... 2015 - 75 gamma WHO-Ebol.... 2015 - 76 gamma WHO-Ebol.... 2015 - 77 gamma WHO-Ebol.... 2015 - 78 gamma WHO-Ebol.... 2015 - 79 lnorm Abdullah.... 2013 - 80 lnorm Abdullah.... 2013 - 81 Abdullah.... 2013 - 82 Abdullah.... 2013 - 83 Abdullah.... 2013 - 84 gamma Kenji Mi.... 2015 - 85 gamma B J Cowl.... 2015 - 86 gamma B J Cowl.... 2015 - 87 Ke Men, .... 2020 - 88 Balram R.... 2022 - 89 Muluneh .... 2021 - 90 Muluneh .... 2021 - 91 Christel.... 2021 - 92 weibull Long V. .... 2020 - 93 lnorm Conor Mc.... 2020 - 94 lnorm Conor Mc.... 2020 - 95 lnorm Natalie .... 2020 - 96 lnorm Natalie .... 2020 - 97 gamma Natalie .... 2020 - 98 gamma Natalie .... 2020 - 99 lnorm Natalie .... 2020 - 100 weibull Natalie .... 2020 - 101 lnorm Natalie .... 2020 - 102 lnorm Natalie .... 2020 - 103 lnorm Natalie .... 2020 - 104 lnorm Natalie .... 2020 - 105 lnorm Natalie .... 2020 - 106 lnorm Stephen .... 2020 - 107 lnorm Stephen .... 2020 - 108 lnorm Stephen .... 2020 - 109 lnorm Stephen .... 2020 - 110 gamma Zihao Gu.... 2022 - 111 Shuqi Wa.... 2022 - 112 Shuqi Wa.... 2022 - 113 Shuqi Wa.... 2022 - 114 Shuqi Wa.... 2022 - 115 Shuqi Wa.... 2022 - 116 Fengying.... 2022 - 117 Fengying.... 2022 - 118 Fengying.... 2022 - # list_distributions works for incubation period with db Code @@ -565,85 +321,6 @@ 71 Mpox incubation period Fengying.... 2022 72 Mpox incubation period Fengying.... 2022 -# list_distributions works for incubation period without db - - Code - incub_tbl - Output - disease epi_distribution prob_distribution author year - 1 Adenovirus incubation period lnorm Justin L.... 2009 - 2 Human Coronavirus incubation period lnorm Justin L.... 2009 - 3 SARS incubation period lnorm Justin L.... 2009 - 4 Influenza incubation period lnorm Justin L.... 2009 - 5 Influenza incubation period lnorm Justin L.... 2009 - 6 Influenza incubation period lnorm Justin L.... 2009 - 7 Measles incubation period lnorm Justin L.... 2009 - 8 Parainfluenza incubation period lnorm Justin L.... 2009 - 9 RSV incubation period lnorm Justin L.... 2009 - 10 Rhinovirus incubation period lnorm Justin L.... 2009 - 11 Influenza incubation period lnorm Nicholas.... 2009 - 12 Influenza incubation period lnorm Nicholas.... 2009 - 13 RSV incubation period lnorm Nicholas.... 2009 - 14 RSV incubation period lnorm Nicholas.... 2009 - 15 Influenza incubation period gamma Hiroshi .... 2011 - 16 Influenza incubation period weibull Hiroshi .... 2011 - 17 Influenza incubation period weibull Victor V.... 2015 - 18 Influenza incubation period gamma Victor V.... 2015 - 19 Influenza incubation period weibull Victor V.... 2016 - 20 Influenza incubation period weibull Victor V.... 2016 - 21 Influenza incubation period weibull Victor V.... 2016 - 22 Influenza incubation period lnorm Ashleigh.... 2010 - 23 Influenza incubation period gamma Azra Gha.... 2009 - 24 Influenza incubation period lnorm Justin L.... 2009 - 25 Marburg Virus Disease incubation period Boris I..... 2014 - 26 Marburg Virus Disease incubation period Boris I..... 2014 - 27 Dengue incubation period lnorm Miranda .... 2012 - 28 Dengue incubation period lnorm Miranda .... 2012 - 29 Dengue incubation period lnorm Miranda .... 2012 - 30 Zika Virus Disease incubation period lnorm Justin L.... 2016 - 31 Chikungunya incubation period lnorm Kara E R.... 2014 - 32 Dengue incubation period lnorm Kara E R.... 2014 - 33 Dengue incubation period lnorm Kara E R.... 2014 - 34 Japanese Encephalitis incubation period lnorm Kara E R.... 2014 - 35 Rift Valley Fever incubation period lnorm Kara E R.... 2014 - 36 West Nile Fever incubation period lnorm Kara E R.... 2014 - 37 West Nile Fever incubation period lnorm Kara E R.... 2014 - 38 West Nile Fever incubation period lnorm Kara E R.... 2014 - 39 Yellow Fever incubation period lnorm Kara E R.... 2014 - 40 Yellow Fever incubation period lnorm Kara E R.... 2014 - 41 Mpox incubation period lnorm Fuminari.... 2022 - 42 Mpox incubation period lnorm Kelly Ch.... 2022 - 43 Mpox incubation period gamma Giorgio .... 2022 - 44 Mpox incubation period lnorm Zachary .... 2022 - 45 Mpox incubation period lnorm Zachary .... 2022 - 46 Ebola Virus Disease incubation period lnorm Martin E.... 2011 - 47 Ebola Virus Disease incubation period gamma WHO-Ebol.... 2015 - 48 Ebola Virus Disease incubation period gamma WHO-Ebol.... 2015 - 49 Ebola Virus Disease incubation period gamma WHO-Ebol.... 2015 - 50 Ebola Virus Disease incubation period gamma WHO-Ebol.... 2015 - 51 MERS incubation period lnorm Abdullah.... 2013 - 52 MERS incubation period gamma B J Cowl.... 2015 - 53 COVID-19 incubation period Ke Men, .... 2020 - 54 COVID-19 incubation period Balram R.... 2022 - 55 COVID-19 incubation period Muluneh .... 2021 - 56 COVID-19 incubation period Christel.... 2021 - 57 COVID-19 incubation period weibull Long V. .... 2020 - 58 COVID-19 incubation period lnorm Conor Mc.... 2020 - 59 COVID-19 incubation period lnorm Conor Mc.... 2020 - 60 COVID-19 incubation period lnorm Natalie .... 2020 - 61 COVID-19 incubation period lnorm Natalie .... 2020 - 62 COVID-19 incubation period lnorm Natalie .... 2020 - 63 COVID-19 incubation period lnorm Stephen .... 2020 - 64 COVID-19 incubation period lnorm Stephen .... 2020 - 65 COVID-19 incubation period lnorm Stephen .... 2020 - 66 COVID-19 incubation period lnorm Stephen .... 2020 - 67 Mpox incubation period Shuqi Wa.... 2022 - 68 Mpox incubation period Shuqi Wa.... 2022 - 69 Mpox incubation period Shuqi Wa.... 2022 - 70 Mpox incubation period Fengying.... 2022 - 71 Mpox incubation period Fengying.... 2022 - 72 Mpox incubation period Fengying.... 2022 - # list_distributions works for different distribution with db Code @@ -666,28 +343,6 @@ 14 Mpox serial interval Shuqi Wa.... 2022 15 Mpox serial interval Shuqi Wa.... 2022 -# list_distributions works for different distribution without db - - Code - serial_tbl - Output - disease epi_distribution prob_distribution author year - 1 Influenza serial interval gamma Azra Gha.... 2009 - 2 Marburg Virus Disease serial interval Boris I..... 2014 - 3 Marburg Virus Disease serial interval gamma Marco Aj.... 2012 - 4 Mpox serial interval gamma Zachary .... 2022 - 5 Mpox serial interval gamma Zachary .... 2022 - 6 Ebola Virus Disease serial interval gamma WHO-Ebol.... 2015 - 7 Ebola Virus Disease serial interval gamma WHO-Ebol.... 2015 - 8 Ebola Virus Disease serial interval gamma WHO-Ebol.... 2015 - 9 Ebola Virus Disease serial interval gamma WHO-Ebol.... 2015 - 10 MERS serial interval lnorm Abdullah.... 2013 - 11 MERS serial interval gamma B J Cowl.... 2015 - 12 COVID-19 serial interval Muluneh .... 2021 - 13 Mpox serial interval gamma Zihao Gu.... 2022 - 14 Mpox serial interval Shuqi Wa.... 2022 - 15 Mpox serial interval Shuqi Wa.... 2022 - # list_distributions works for COVID-19 db Code @@ -718,36 +373,6 @@ 22 COVID-19 incubation period lnorm Stephen .... 2020 23 COVID-19 incubation period lnorm Stephen .... 2020 -# list_distributions works for COVID-19 without db - - Code - incub_tbl - Output - disease epi_distribution prob_distribution author year - 1 COVID-19 incubation period Ke Men, .... 2020 - 2 COVID-19 incubation period Balram R.... 2022 - 3 COVID-19 incubation period Muluneh .... 2021 - 4 COVID-19 serial interval Muluneh .... 2021 - 5 COVID-19 incubation period Christel.... 2021 - 6 COVID-19 incubation period weibull Long V. .... 2020 - 7 COVID-19 incubation period lnorm Conor Mc.... 2020 - 8 COVID-19 incubation period lnorm Conor Mc.... 2020 - 9 COVID-19 incubation period lnorm Natalie .... 2020 - 10 COVID-19 incubation period lnorm Natalie .... 2020 - 11 COVID-19 onset to hospitalisation gamma Natalie .... 2020 - 12 COVID-19 onset to hospitalisation gamma Natalie .... 2020 - 13 COVID-19 onset to death lnorm Natalie .... 2020 - 14 COVID-19 hospitalisation to death weibull Natalie .... 2020 - 15 COVID-19 incubation period lnorm Natalie .... 2020 - 16 COVID-19 onset to hospitalisation lnorm Natalie .... 2020 - 17 COVID-19 onset to hospitalisation lnorm Natalie .... 2020 - 18 COVID-19 onset to death lnorm Natalie .... 2020 - 19 COVID-19 hospitalisation to death lnorm Natalie .... 2020 - 20 COVID-19 incubation period lnorm Stephen .... 2020 - 21 COVID-19 incubation period lnorm Stephen .... 2020 - 22 COVID-19 incubation period lnorm Stephen .... 2020 - 23 COVID-19 incubation period lnorm Stephen .... 2020 - # list_distributions works for disease & epi_dist subset with db Code @@ -769,27 +394,6 @@ 13 COVID-19 incubation period lnorm Stephen .... 2020 14 COVID-19 incubation period lnorm Stephen .... 2020 -# list_distributions works for disease & epi_dist subset without db - - Code - incub_tbl - Output - disease epi_distribution prob_distribution author year - 1 COVID-19 incubation period Ke Men, .... 2020 - 2 COVID-19 incubation period Balram R.... 2022 - 3 COVID-19 incubation period Muluneh .... 2021 - 4 COVID-19 incubation period Christel.... 2021 - 5 COVID-19 incubation period weibull Long V. .... 2020 - 6 COVID-19 incubation period lnorm Conor Mc.... 2020 - 7 COVID-19 incubation period lnorm Conor Mc.... 2020 - 8 COVID-19 incubation period lnorm Natalie .... 2020 - 9 COVID-19 incubation period lnorm Natalie .... 2020 - 10 COVID-19 incubation period lnorm Natalie .... 2020 - 11 COVID-19 incubation period lnorm Stephen .... 2020 - 12 COVID-19 incubation period lnorm Stephen .... 2020 - 13 COVID-19 incubation period lnorm Stephen .... 2020 - 14 COVID-19 incubation period lnorm Stephen .... 2020 - # list_distribution works when supplied a subset db Code @@ -836,21 +440,3 @@ disease epi_distribution prob_distribution author year 1 Ebola serial interval gamma John Smith 2022 -# list_distribution works passing arg to epidist_db - - Code - covid_tbl - Output - disease epi_distribution prob_distribution author year - 1 COVID-19 incubation period lnorm Natalie .... 2020 - 2 COVID-19 incubation period lnorm Natalie .... 2020 - 3 COVID-19 onset to hospitalisation gamma Natalie .... 2020 - 4 COVID-19 onset to hospitalisation gamma Natalie .... 2020 - 5 COVID-19 onset to death lnorm Natalie .... 2020 - 6 COVID-19 hospitalisation to death weibull Natalie .... 2020 - 7 COVID-19 incubation period lnorm Natalie .... 2020 - 8 COVID-19 onset to hospitalisation lnorm Natalie .... 2020 - 9 COVID-19 onset to hospitalisation lnorm Natalie .... 2020 - 10 COVID-19 onset to death lnorm Natalie .... 2020 - 11 COVID-19 hospitalisation to death lnorm Natalie .... 2020 - diff --git a/tests/testthat/test-list_distributions.R b/tests/testthat/test-list_distributions.R index 6aef067c5..5faeeb711 100644 --- a/tests/testthat/test-list_distributions.R +++ b/tests/testthat/test-list_distributions.R @@ -12,17 +12,6 @@ test_that("list_distributions works as expected supplied with db", { expect_snapshot(dist_tbl) }) -test_that("list_distributions works as expected without db", { - dist_tbl <- list_distributions() - expect_s3_class(dist_tbl, "data.frame") - expect_identical(dim(dist_tbl), c(118L, 5L)) - expect_named( - dist_tbl, - c("disease", "epi_distribution", "prob_distribution", "author", "year") - ) - expect_snapshot(dist_tbl) -}) - test_that("list_distributions works for incubation period with db", { incub_tbl <- list_distributions( multi_epidist = edist, @@ -37,18 +26,6 @@ test_that("list_distributions works for incubation period with db", { expect_snapshot(incub_tbl) }) -test_that("list_distributions works for incubation period without db", { - incub_tbl <- list_distributions(epi_dist = "incubation period") - - expect_s3_class(incub_tbl, "data.frame") - expect_identical(dim(incub_tbl), c(72L, 5L)) - expect_named( - incub_tbl, - c("disease", "epi_distribution", "prob_distribution", "author", "year") - ) - expect_snapshot(incub_tbl) -}) - test_that("list_distributions works for different distribution with db", { serial_tbl <- list_distributions( multi_epidist = edist, @@ -63,17 +40,6 @@ test_that("list_distributions works for different distribution with db", { expect_snapshot(serial_tbl) }) -test_that("list_distributions works for different distribution without db", { - serial_tbl <- list_distributions(epi_dist = "serial interval") - expect_s3_class(serial_tbl, "data.frame") - expect_identical(dim(serial_tbl), c(15L, 5L)) - expect_named( - serial_tbl, - c("disease", "epi_distribution", "prob_distribution", "author", "year") - ) - expect_snapshot(serial_tbl) -}) - test_that("list_distributions works for COVID-19 db", { incub_tbl <- list_distributions( multi_epidist = edist, @@ -88,17 +54,6 @@ test_that("list_distributions works for COVID-19 db", { expect_snapshot(incub_tbl) }) -test_that("list_distributions works for COVID-19 without db", { - incub_tbl <- list_distributions(disease = "COVID-19") - expect_s3_class(incub_tbl, "data.frame") - expect_identical(dim(incub_tbl), c(23L, 5L)) - expect_named( - incub_tbl, - c("disease", "epi_distribution", "prob_distribution", "author", "year") - ) - expect_snapshot(incub_tbl) -}) - test_that("list_distributions works for disease & epi_dist subset with db", { incub_tbl <- list_distributions( multi_epidist = edist, @@ -114,20 +69,6 @@ test_that("list_distributions works for disease & epi_dist subset with db", { expect_snapshot(incub_tbl) }) -test_that("list_distributions works for disease & epi_dist subset without db", { - incub_tbl <- list_distributions( - disease = "COVID-19", - epi_dist = "incubation period" - ) - expect_s3_class(incub_tbl, "data.frame") - expect_identical(dim(incub_tbl), c(14L, 5L)) - expect_named( - incub_tbl, - c("disease", "epi_distribution", "prob_distribution", "author", "year") - ) - expect_snapshot(incub_tbl) -}) - test_that("list_distribution works when supplied a subset db", { edist <- suppressMessages(epidist_db(disease = "COVID-19")) covid_tbl <- list_distributions(multi_epidist = edist, disease = "COVID-19") @@ -187,17 +128,6 @@ test_that("list_distribution fails correctly when subsetting a subset db", { ) }) -test_that("list_distribution works passing arg to epidist_db", { - covid_tbl <- list_distributions(disease = "COVID-19", author = "Linton") - expect_s3_class(covid_tbl, "data.frame") - expect_identical(dim(covid_tbl), c(11L, 5L)) - expect_named( - covid_tbl, - c("disease", "epi_distribution", "prob_distribution", "author", "year") - ) - expect_snapshot(covid_tbl) -}) - test_that("list_distributions fails correctly", { # check for incorrect input expect_error( @@ -209,13 +139,13 @@ test_that("list_distributions fails correctly", { ) expect_error( - list_distributions(epi_dist = "random"), + list_distributions(multi_epidist = edist, epi_dist = "random"), regexp = "random distribution not available" ) # check for multiple match input expect_error( - list_distributions(epi_dist = "onset"), + list_distributions(multi_epidist = edist, epi_dist = "onset"), regexp = "onset distribution not available" ) }) From afbb7c4f7da3e36fbf0abcc3c95a88103cd89245 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Wed, 15 Nov 2023 14:50:36 +0000 Subject: [PATCH 3/4] updated list_distributions info in epiparameter vignette --- vignettes/epiparameter.Rmd | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/vignettes/epiparameter.Rmd b/vignettes/epiparameter.Rmd index 3ec79cef6..75bb8ce17 100644 --- a/vignettes/epiparameter.Rmd +++ b/vignettes/epiparameter.Rmd @@ -64,16 +64,10 @@ To see a full list of the diseases and distributions stored in the library use t head(list_distributions(multi_epidist = epi_dist_db)) ``` -If the `list_distributions()` function is not supplied with a list of `` objects it can fetch the entries from the database. - -```{r, list-distribution-read-db} -head(list_distributions()) -``` - -`list_distributions()` can also subset the database, when either supplied to the function (first example) or when the entries are fetched directly from the database (second example). +`list_distributions()` can also subset the database supplied to the function. ```{r, list-distributions-subset} -list_distributions(disease = "Ebola") +list_distributions(multi_epidist = epi_dist_db, disease = "Ebola") ``` More details on the data collation and the library of parameters can be found in From f9f52746bf9eeb3177791721af4e9df58e7e1535 Mon Sep 17 00:00:00 2001 From: Joshua Lambert Date: Wed, 15 Nov 2023 14:50:59 +0000 Subject: [PATCH 4/4] updated list_distributions title in pkgdown reference --- _pkgdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index 0661d1f7e..0124a289c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -44,7 +44,7 @@ reference: contents: - epidist_db - - title: Explore epiparam + - title: Explore epiparameters desc: List epi parameters as table contents: - list_distributions