Add a multi-reference version of the existing one-to-one indicator comparison report - #7
Add a multi-reference version of the existing one-to-one indicator comparison report#7jingjtang wants to merge 5 commits into
Conversation
JavierMtzRdz
left a comment
There was a problem hiding this comment.
Thanks for this! It improves almost all sections. Since it doesn't conflict with anything, we can merge once you add some instructions on how to use this to the READMEs and address the suggestions and issues. Those marked as minor suggestions (most of my comments) are more open recommendations. Then, eventually, we could replace indicator_correlation.qmdwith this.
If you also include the processing that uses only the necessary parameter depending on the indicator source and handle edge cases with either one location or many candidates, I'm happy to replace indicator_correlation.qmd with this, but that is not necessary. We can leave the full replacement for later.
| candidate_source: doctor-visits | ||
| candidate_indicator: smoothed_adj_cli | ||
| candidate_name: "Doctor Visits: Smoothed Adj CLI" | ||
| candidate_csv: !expr "NULL" | ||
| # Reference Indicators | ||
| reference_sources: !expr 'c("quidel", "hospital-admissions", "chng", "chng")' | ||
| reference_indicators: !expr 'c("covid_ag_smoothed_pct_positive", "smoothed_covid19_from_claims", "7dav_inpatient_covid", "7dav_outpatient_covid")' | ||
| reference_names: !expr 'c("Quidel: Smoothed % Positive COVID Antigen", "Hospital Admissions: Smoothed COVID-19 from Claims", "CHNG: 7-day Avg Inpatient COVID", "CHNG: 7-day Avg Outpatient COVID")' |
There was a problem hiding this comment.
suggestion: I'm inclined to leave these parameters empty to ensure the user provides all the information required for the indicator they are interested in. However, the required indicators vary depending on whether the user is calling an indicator from the V5 API, the new API, or providing a CSV file. The last version of the correlation notebook has some of this.
There was a problem hiding this comment.
Agreed. I now left the YAML params empty.
| overlap_metric = factor(overlap_metric, levels = c("Rows loaded", "Locations loaded", "Overlap rows", "Overlap locations", "Overlap dates", "Overlap percent")) | ||
| ) | ||
|
|
||
| p_overlap <- ggplot(overlap_long, aes(x = overlap_metric, y = reference_label)) + |
There was a problem hiding this comment.
question: Is there a reason to prefer a plot over a table for this information?
There was a problem hiding this comment.
I changed the overlap metrics from a plot to a table and kept only the date-span plot.
There was a problem hiding this comment.
I'm aiming to keep the rendered files separate from the notebooks and code. Alternatively, you could include the rendering codes in the script/{post/pre}_render.R scripts to generate the output and then add it to the gh branch.
There was a problem hiding this comment.
Before merging into main, delete this file and include the code to generate it within the pre_render script and the YAML. I am adding an action to handle this rendering when a notebook is modified.
There was a problem hiding this comment.
Done. I removed the rendered HTML from the PR and added the report generation to scripts/pre_render.R and _quarto.yml.
There was a problem hiding this comment.
Thanks for this. It looks great!
|
I've also added you to the repo, so there's no need to create forks. |
There was a problem hiding this comment.
Thank you for addressing my comments. I have added a few minor points.
Before merging, please remove the rendered example, merge main into this branch to avoid conflicts, add code to render it in script/pre_render.R, add documentation on how to use it in 'indicator_analysis/README.md, and mention it in the main README.md`.
|
|
||
| wrap_legend_label <- function(x, width = 26) { | ||
| stringr::str_wrap(x, width = width) | ||
| wrap_legend_label <- function(x) { |
There was a problem hiding this comment.
Suggestion: It looks like the function now does the opposite of what it did before. I'd rename it accordingly.
There was a problem hiding this comment.
Good point. I renamed the helper to clean_legend_label()
There was a problem hiding this comment.
Before merging into main, delete this file and include the code to generate it within the pre_render script and the YAML. I am adding an action to handle this rendering when a notebook is modified.
| theme(axis.text.x = element_text(angle = 35, hjust = 1)) | ||
| ``` | ||
|
|
||
| ### Quantile Trends |
There was a problem hiding this comment.
Instead of just breaking or printing a message, I'd recommend implementing dynamic metadata sections. This allows you to manage the visibility of sections using rules, but it's not essential.
| ggplot(coverage, aes(x = time_value, y = locations, color = availability)) + | ||
| geom_step(direction = "mid", linewidth = 0.5) + | ||
| facet_wrap(~wrap_reference(reference_name), ncol = 1) + | ||
| facet_wrap(~stringr::str_wrap(reference_name, width = 30), ncol = 1) + |
There was a problem hiding this comment.
minor suggestion: use scale = "free_y"
| #| fig-height: 5.5 | ||
| knitr::opts_current$set(fig.height = scaled_fig_height(n_distinct(lag_summary$reference_label), base = 3.5, per_item = 0.55, min_height = 5.5, max_height = 13)) | ||
|
|
||
| ggplot(lag_summary, aes(x = lag, y = reference_label, fill = mean_cor)) + |
There was a problem hiding this comment.
issue: This plot and the map indicate that the maximum correlation for the empty indicator is -21.
There was a problem hiding this comment.
Good catch. I now filter to finite correlations before selecting the optimal lag, so empty references should no longer produce invalid values.
The new report evaluates one candidate indicator against multiple reference indicators in a single render. Each diagnostic remains pairwise.
Preview
Rendered HTML preview
Main Changes
indicator_comparison.qmdfor:Validation
Rendered successfully with: