epiverse-trace / epiparameter

R package with library of epidemiological parameters for infectious diseases and functions and classes for working with parameters
https://epiverse-trace.github.io/epiparameter
Other
33 stars 11 forks source link

`as_epidist()` fails for infectious period from {epireview} #327

Closed joshwlambert closed 5 months ago

joshwlambert commented 5 months ago

Issue reported during Epiparameter workshop.

library(epiparameter)
library(epireview)

ebola <- epireview::load_epidata("ebola")
# lassa <- epireview::load_epidata("lassa")

param_name <- "Human delay - infectious period"

ebola$params %>%
  filter( parameter_type == param_name ) -> param_infectiousness

# Get value
param_infectiousness[6,]$parameter_value

# Convert to epidist and output available summary stats
epidist_admission_outcome <- epiparameter::as_epidist( param_infectiousness[6,] )
joshwlambert commented 5 months ago

The code chunk above also requires library(dyplr) for the filter() function.

joshwlambert commented 5 months ago

Reprex of issue:

library(epiparameter)
library(epireview)
#> Loading required package: epitrix
#> Loading required package: ggplot2
#> Loading required package: ggforce
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

ebola <- epireview::load_epidata("ebola")
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> Warning in load_epidata_raw(pathogen, "outbreak"): No data found for ebola
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> Warning in epireview::load_epidata("ebola"): No outbreaks information found for
#> ebola
#> Data loaded for ebola
# lassa <- epireview::load_epidata("lassa")

param_name <- "Human delay - infectious period"

ebola$params %>%
  filter( parameter_type == param_name ) -> param_infectiousness

# Get value
param_infectiousness[6,]$parameter_value
#> [1] 4.05

# Convert to epidist and output available summary stats
epidist_admission_outcome <- epiparameter::as_epidist( param_infectiousness[6,] )
#> Using Lau (2017). "<title not available>." _<journal not available>_. 
#> To retrieve the citation use the 'get_citation' function
#> Warning: Cannot create full citation for epidemiological parameters without bibliographic information 
#>  see ?epireview_to_epidist for help.
#> Error in new_epidist(disease = disease, pathogen = pathogen, epi_dist = epi_dist, : parameters and uncertainty must be named and match

Created on 2024-06-04 with reprex v2.1.0

joshwlambert commented 5 months ago

The distribution type in the parameter entry from {epireview} being converted to an <epidist> object in this example is an exponential distribution which is currently unsupprted by <epidist>. See issue #328 for the feature request to rectify this.

joshwlambert commented 5 months ago

This issue is resolves as of PR #334. Here is a reproducible example using the fix and comparing the {epireview} data frame and the <epidist>.

library(epiparameter)
library(epireview)
#> Loading required package: epitrix
#> Loading required package: ggplot2
#> Loading required package: ggforce
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

ebola <- epireview::load_epidata("ebola")
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> Warning in load_epidata_raw(pathogen, "outbreak"): No data found for ebola
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> Warning in epireview::load_epidata("ebola"): No outbreaks information found for
#> ebola
#> Data loaded for ebola

param_name <- "Human delay - infectious period"

ebola$params %>%
  filter( parameter_type == param_name ) -> param_infectiousness

# Get value
param_infectiousness[6,]$parameter_value
#> [1] 4.05

# Convert to epidist and output available summary stats
infectiousness <- epiparameter::as_epidist( param_infectiousness[6,] )
#> Using Lau (2017). "<title not available>." _<journal not available>_. 
#> To retrieve the citation use the 'get_citation' function
#> Warning: Cannot create full citation for epidemiological parameters without bibliographic information 
#>  see ?as_epidist for help.
infectiousness
#> Disease: Ebola Virus Disease
#> Pathogen: Ebola virus
#> Epi Distribution: human delay   infectious period
#> Study: Lau (2017). "<title not available>." _<journal not available>_.
#> Distribution: exp
#> Parameters:
#>   rate: 0.247

unclass(infectiousness)
#> $disease
#> [1] "Ebola Virus Disease"
#> 
#> $pathogen
#> [1] "Ebola virus"
#> 
#> $epi_dist
#> [1] "Human delay - infectious period"
#> 
#> $prob_dist
#> <distribution[1]>
#> [1] Exp(0.25)
#> 
#> $uncertainty
#> $uncertainty$mean
#> $uncertainty$mean$ci_limits
#> [1] NA
#> 
#> $uncertainty$mean$ci
#> [1] NA NA
#> 
#> $uncertainty$mean$ci_type
#> [1] NA
#> 
#> 
#> 
#> $summary_stats
#> $summary_stats$mean
#> [1] 4.05
#> 
#> $summary_stats$mean_ci_limits
#> [1] 3.53 4.67
#> 
#> $summary_stats$mean_ci
#> [1] 95
#> 
#> $summary_stats$sd
#> [1] NA
#> 
#> $summary_stats$sd_ci_limits
#> [1] NA NA
#> 
#> $summary_stats$sd_ci
#> [1] NA
#> 
#> $summary_stats$median
#> [1] NA
#> 
#> $summary_stats$median_ci_limits
#> [1] NA NA
#> 
#> $summary_stats$median_ci
#> [1] NA
#> 
#> $summary_stats$quantiles
#> [1] NA
#> 
#> $summary_stats$range
#> [1] NA NA
#> 
#> 
#> $citation
#> Lau (2017). "<title not available>." _<journal not available>_.
#> 
#> $metadata
#> $metadata$sample_size
#> [1] 200
#> 
#> $metadata$region
#> [1] "Western Area, Sierra Leone"
#> 
#> $metadata$transmission_mode
#> [1] NA
#> 
#> $metadata$vector
#> [1] NA
#> 
#> $metadata$extrinsic
#> [1] FALSE
#> 
#> $metadata$inference_method
#> [1] "Maximum likelihood"
#> 
#> 
#> $method_assess
#> $method_assess$censored
#> [1] NA
#> 
#> $method_assess$right_truncated
#> [1] NA
#> 
#> $method_assess$phase_bias_adjusted
#> [1] NA
#> 
#> 
#> $notes
#> [1] "No additional notes"
#> 
#> attr(,".epiparameter_namespace")
#> function () 
#> NULL
#> <bytecode: 0x14fcdf438>
#> <environment: namespace:epiparameter>
as.data.frame(param_infectiousness[6, ])
#>                                 id                parameter_data_id
#> 1 1fb060c117ff954fa69e77429a0f9c7e a92dfc5da1285b856a016e71ce2bfbad
#>   covidence_id    pathogen                  parameter_type parameter_value
#> 1         3470 Ebola virus Human delay - infectious period            4.05
#>   exponent parameter_unit parameter_lower_bound parameter_upper_bound
#> 1        0           Days                    NA                    NA
#>   parameter_value_type parameter_uncertainty_single_value
#> 1                 Mean                                 NA
#>   parameter_uncertainty_singe_type parameter_uncertainty_lower_value
#> 1                             <NA>                              3.53
#>   parameter_uncertainty_upper_value parameter_uncertainty_type
#> 1                              4.67                     95% CI
#>   cfr_ifr_numerator cfr_ifr_denominator distribution_type
#> 1                NA                  NA       Exponential
#>   distribution_par1_value distribution_par1_type distribution_par1_uncertainty
#> 1                    4.05                   Mean                         FALSE
#>   distribution_par2_value distribution_par2_type distribution_par2_uncertainty
#> 1                      NA                   <NA>                         FALSE
#>   method_from_supplement method_moment_value cfr_ifr_method method_r
#> 1                   TRUE                <NA>           <NA>     <NA>
#>   method_disaggregated_by method_disaggregated method_disaggregated_only
#> 1                    <NA>                FALSE                     FALSE
#>   riskfactor_outcome riskfactor_name riskfactor_occupation
#> 1               <NA>            <NA>                  <NA>
#>   riskfactor_significant riskfactor_adjusted population_sex
#> 1                   <NA>                <NA>           Both
#>   population_sample_type   population_group population_age_min
#> 1       Population based General population                 NA
#>   population_age_max population_sample_size population_country
#> 1                 NA                    200       Sierra Leone
#>   population_location population_study_start_day population_study_start_month
#> 1        Western Area                         20                          Oct
#>   population_study_start_year population_study_end_day
#> 1                        2014                       30
#>   population_study_end_month population_study_end_year genome_site
#> 1                        Mar                      2015        <NA>
#>   genomic_sequence_available other_delay_start other_delay_end inverse_param
#> 1                      FALSE              <NA>            <NA>         FALSE
#>   parameter_from_figure parameter_class ebola_variant other_delay
#> 1                 FALSE     Human delay   Unspecified        <NA>
#>         delay_short       delay_start other_rf_outcome attack_rate_type
#> 1 Infectious period Infection process             <NA>             <NA>
#>   survey_start_date survey_end_date               survey_date parameter_bounds
#> 1       20 Oct 2014     30 Mar 2015 20 Oct 2014 - 30 Mar 2015             <NA>
#>   comb_uncertainty_type comb_uncertainty article_qa_score              outbreak
#> 1                95% CI      3.53 - 4.67         85.71429 West Africa 2013-2016
#>   ebola_species parameter_type_short first_author_surname year_publication
#> 1         Zaire                 <NA>                  Lau             2017
#>   article_label
#> 1  Lau 2017 (a)

Created on 2024-06-14 with reprex v2.1.0

joshwlambert commented 5 months ago

PR #334 is now merged, closing this issue.