mrc-ide / epireview

https://mrc-ide.github.io/epireview/
GNU General Public License v3.0
25 stars 2 forks source link

reorder_studies function is dropping rows #73

Closed thomrawson closed 2 weeks ago

thomrawson commented 1 month ago

When we feed parameters into a forest_plot, it automatically runs them through "reorder_studies" to plot them from highest to lowest. However, it also does this by country. If a parameter has NA for country, it currently cuts that parameter. (drops that row). We don't want this happen.

Rather, we want it to include all by default, and have users say if they want to order by country, and then have a way to make sure NAs aren't removed still.

ebola_df <- load_epidata('ebola')
ebola_params <- ebola_df[["params"]]

forest_plot_infectious_period(ebola_params)

ebola_params <- ebola_params[ebola_params$parameter_type %in% c("Human delay - infectious period",
                                                   "Human delay - infectious period  (inverse parameter)"), ]
#So, seven params, but only six got plotted above, we're missing a 21.6 estimate

ebola_params <- reparam_gamma(ebola_params) |>
  invert_inverse_params() |>
  delays_to_days() |>
  param_pm_uncertainty()

#Now, enforce the bug, set Yang (2015) (the first one)
ebola_params$population_country[1] <- NA
#We have 25 rows...
forest_plot_infectious_period(ebola_params)
#Yang has gone missing!

#THis is because of reorder_studies:
ebola_params <- reorder_studies(ebola_params)
thomrawson commented 2 weeks ago

Issue now fixed!