The code in this script reruns the decision tree under four alternative sets of assumptions and saves the annotated trees shown on the scenario analyses results page. Each scenario changes one or more parameters and leaves every other parameter at its base-case value.
Each section calls create_tree_diagram_QC() with the changed parameters, then exports the tree to SVG, adds the incremental cost, QALYs and net monetary benefit with add_svg_annotation(), and saves the result to figures/.
Scenario 1: transplants almost never cancelled after a positive screen
p_cancelled = 0.01. Saved as figures/alternative_tree_1_annotated.svg.
Click to show/hide R Code
#Run the base case tree diagram, where organ wastage is nearly eliminatedalternative_tree_1<-create_tree_diagram_QC(p_cancelled =0.01)#Convert the tree diagram to svg, then XML, then add the annotation and saveexport_svg(alternative_tree_1$plot)%>%read_xml()%>%add_svg_annotation(c("Screening vs no screening:",glue("• ΔC = {scales::number(alternative_tree_1$cost_difference, accuracy = 0.01)}"),glue("• ΔQ = {formatC(alternative_tree_1$qaly_difference, format = 'f', digits = 4)}"),glue("• NMB = {scales::number(alternative_tree_1$nmb, accuracy = 0.01)}") ) )%>%write_xml("figures/alternative_tree_1_annotated.svg")
Scenario 2: almost no cancellations and near-universal prophylaxis
p_cancelled = 0.01 and p_prophrate = 0.99. Saved as figures/alternative_tree_2_annotated.svg.
Click to show/hide R Code
#Run the base case tree diagram, where organ wastage is nearly eliminated and near-universal prophylaxis is achievedalternative_tree_2<-create_tree_diagram_QC(p_cancelled =0.01,p_prophrate =0.99)#Convert the tree diagram to svg, then XML, then add the annotation and saveexport_svg(alternative_tree_2$plot)%>%read_xml()%>%add_svg_annotation(c("Screening vs no screening:",glue("• ΔC = {scales::number(alternative_tree_2$cost_difference, accuracy = 0.01)}"),glue("• ΔQ = {formatC(alternative_tree_2$qaly_difference, format = 'f', digits = 4)}"),glue("• NMB = {scales::number(alternative_tree_2$nmb, accuracy = 0.01)}") ) )%>%write_xml("figures/alternative_tree_2_annotated.svg")
Scenario 3: much higher cost of cryptococcal disease
cost_disease = 3,000,000. Saved as figures/alternative_tree_3_annotated.svg.
Click to show/hide R Code
#Run the base case tree diagram, where cost of cryptococcus is $3 millionalternative_tree_3<-create_tree_diagram_QC(cost_disease =3000000)#Convert the tree diagram to svg, then XML, then add the annotation and saveexport_svg(alternative_tree_3$plot)%>%read_xml()%>%add_svg_annotation(c("Screening vs no screening:",glue("• ΔC = {scales::number(alternative_tree_3$cost_difference, accuracy = 0.01)}"),glue("• ΔQ = {formatC(alternative_tree_3$qaly_difference, format = 'f', digits = 4)}"),glue("• NMB = {scales::number(alternative_tree_3$nmb, accuracy = 0.01)}") ) )%>%write_xml("figures/alternative_tree_3_annotated.svg")
Scenario 4: all three changes combined
p_cancelled = 0.01, p_prophrate = 0.99 and cost_disease = 3,000,000. Saved as figures/alternative_tree_4_annotated.svg.
Click to show/hide R Code
#Assume both very high costs of disease as well as near-perfect implementationalternative_tree_4<-create_tree_diagram_QC(p_cancelled =0.01,p_prophrate =0.99,cost_disease =3000000)#Convert the tree diagram to svg, then XML, then add the annotation and saveexport_svg(alternative_tree_4$plot)%>%read_xml()%>%add_svg_annotation(c("Screening vs no screening:",glue("• ΔC = {scales::number(alternative_tree_4$cost_difference, accuracy = 0.01)}"),glue("• ΔQ = {formatC(alternative_tree_4$qaly_difference, format = 'f', digits = 4)}"),glue("• NMB = {scales::number(alternative_tree_4$nmb, accuracy = 0.01)}") ) )%>%write_xml("figures/alternative_tree_4_annotated.svg")#Save the scenario results for the websitescenario_results<-tibble(scenario =1:4,description =c("p_cancelled = 0.01","p_cancelled = 0.01, p_prophrate = 0.99","cost_disease = 3000000","p_cancelled = 0.01, p_prophrate = 0.99, cost_disease = 3000000" ),tree =list(alternative_tree_1, alternative_tree_2, alternative_tree_3, alternative_tree_4))%>%mutate(cost_difference =map_dbl(tree, "cost_difference"),qaly_difference =map_dbl(tree, "qaly_difference"),nmb =map_dbl(tree, "nmb") )%>%select(-tree)write_csv(scenario_results, "output/scenario_results.csv")
---title: "Scenario trees"format: html---The code in this script reruns the decision tree under four alternative sets of assumptions and saves the annotated trees shown on the [scenario analyses](results_scenarios.qmd) results page. Each scenario changes one or more parameters and leaves every other parameter at its base-case value.::: {.Rcode title="Source code"}The full R script is available at:- [`R/scenario_trees.R`](https://github.com/VagishHemmige/Cryptococcus-donor-screening-CEA/blob/master/R/scenario_trees.R)The code sections below are imported directly from that script when this page is rendered.This R script file is itself reliant on the following helper files:- [`R/setup.R`](https://github.com/VagishHemmige/Cryptococcus-donor-screening-CEA/blob/master/R/setup.R)- [`R/functions.R`](https://github.com/VagishHemmige/Cryptococcus-donor-screening-CEA/blob/master/R/functions.R):::```{r}#| label: read-scripts#| include: false#| cache: falseknitr::read_chunk("../R/scenario_trees.R")```Each section calls `create_tree_diagram_QC()` with the changed parameters, then exports the tree to SVG, adds the incremental cost, QALYs and net monetary benefit with `add_svg_annotation()`, and saves the result to `figures/`.## Scenario 1: transplants almost never cancelled after a positive screen`p_cancelled` = 0.01. Saved as `figures/alternative_tree_1_annotated.svg`.```{r}#| label: scenario-1-low-cancellation#| eval: false```## Scenario 2: almost no cancellations and near-universal prophylaxis`p_cancelled` = 0.01 and `p_prophrate` = 0.99. Saved as `figures/alternative_tree_2_annotated.svg`.```{r}#| label: scenario-2-low-cancellation-high-prophylaxis#| eval: false```## Scenario 3: much higher cost of cryptococcal disease`cost_disease` = 3,000,000. Saved as `figures/alternative_tree_3_annotated.svg`.```{r}#| label: scenario-3-high-disease-cost#| eval: false```## Scenario 4: all three changes combined`p_cancelled` = 0.01, `p_prophrate` = 0.99 and `cost_disease` = 3,000,000. Saved as `figures/alternative_tree_4_annotated.svg`.```{r}#| label: scenario-4-combined#| eval: false```