diff --git a/.nojekyll b/.nojekyll index e94381c..c654a92 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -855481b6 \ No newline at end of file +40a0b9c0 \ No newline at end of file diff --git a/CHANGELOG.html b/CHANGELOG.html index 720f1de..a2f8557 100644 --- a/CHANGELOG.html +++ b/CHANGELOG.html @@ -106,7 +106,15 @@
  • - Reproduction + Reproduce Figures 2-4 and in-text results 1-3 +
  • +
  • + + Reproduce Figure 5 +
  • +
  • + + Reproduce supplementary figure
  • diff --git a/CONTRIBUTING.html b/CONTRIBUTING.html index 7d1b43c..be92bc8 100644 --- a/CONTRIBUTING.html +++ b/CONTRIBUTING.html @@ -106,7 +106,15 @@
  • - Reproduction + Reproduce Figures 2-4 and in-text results 1-3 +
  • +
  • + + Reproduce Figure 5 +
  • +
  • + + Reproduce supplementary figure
  • diff --git a/evaluation/artefacts.html b/evaluation/artefacts.html index f41d866..f9c6586 100644 --- a/evaluation/artefacts.html +++ b/evaluation/artefacts.html @@ -126,7 +126,15 @@
  • - Reproduction + Reproduce Figures 2-4 and in-text results 1-3 +
  • +
  • + + Reproduce Figure 5 +
  • +
  • + + Reproduce supplementary figure
  • diff --git a/evaluation/badges.html b/evaluation/badges.html index b0881c8..b511cc4 100644 --- a/evaluation/badges.html +++ b/evaluation/badges.html @@ -160,7 +160,15 @@
  • - Reproduction + Reproduce Figures 2-4 and in-text results 1-3 +
  • +
  • + + Reproduce Figure 5 +
  • +
  • + + Reproduce supplementary figure
  • @@ -258,7 +266,7 @@

    Journal badges

    Caveat: Please note that these criteria are based on available information about each badge online, and that we have likely differences in our procedure (e.g. allowed troubleshooting for execution and reproduction, not under tight time pressure to complete). Moreover, we focus only on reproduction of the discrete-event simulation, and not on other aspects of the article. We cannot guarantee that the badges below would have been awarded in practice by these journals.

    Criteria

    -
    +
    Code
    from IPython.display import display, Markdown
    @@ -391,7 +399,7 @@ 

    Criteria

    Badges

    -
    +
    Code
    # Full badge names
    diff --git a/evaluation/reflections.html b/evaluation/reflections.html
    index ae4b2a4..7d6a9df 100644
    --- a/evaluation/reflections.html
    +++ b/evaluation/reflections.html
    @@ -106,7 +106,15 @@
         
             
  • - Reproduction + Reproduce Figures 2-4 and in-text results 1-3 +
  • +
  • + + Reproduce Figure 5 +
  • +
  • + + Reproduce supplementary figure
  • diff --git a/evaluation/reporting.html b/evaluation/reporting.html index 9cd7a1c..19e45ca 100644 --- a/evaluation/reporting.html +++ b/evaluation/reporting.html @@ -129,7 +129,15 @@
  • - Reproduction + Reproduce Figures 2-4 and in-text results 1-3 +
  • +
  • + + Reproduce Figure 5 +
  • +
  • + + Reproduce supplementary figure
  • @@ -1056,7 +1064,7 @@

    DES c

    - + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    + +
    + + + + +
    + +
    +
    +

    Reproduce Figure 5

    +
    + + + +
    + + + + +
    + + + +
    + + +

    This is run in a separate script from the other figures due to issues with RStudio crashing when all scenarios were run from a single script.

    +

    Run time: 6.165 minutes (will vary between machines)

    +
    +

    Set up

    +
    +
    # Clear environment
    +rm(list=ls())
    +
    +# Start timer
    +start.time <- Sys.time()
    +
    +# Disable scientific notation
    +options(scipen=999)
    +
    +# Get the model and helper functions (but hide loading warnings for each package)
    +suppressMessages(source("model.R"))
    +suppressMessages(source("helpers.R"))
    +
    +
    +
    # Set the seed and default dimensions for figures
    +SEED = 200
    +
    +# Set file paths to save results
    +folder = "../outputs"
    +path_fig5 <- file.path(folder, "fig5.png")
    +
    +
    +
    +

    Run models

    +
    +
    run <- FALSE
    +
    +
    +
    if (isTRUE(run)) {
    +  baseline_f5 <- run_model(seed = SEED, fig5=TRUE)
    +  exclusive_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE)
    +  twoangio_f5 <- run_model(angio_inr = 2, angio_ir=0, seed = SEED, fig5=TRUE)
    +}
    +
    +
    +
    +

    Create figure

    +

    Currently depends on simmer.plot() function that doesn’t work on the imported results from the csv file, so need to allow to run model to produce this plot!

    +
    +
    if (isTRUE(run)) {
    +  # Replace resource (which has been filtered to angioINR) with scenario
    +  baseline_f5$resource <- "Baseline"
    +  exclusive_f5$resource <-"Exclusive-use"
    +  twoangio_f5$resource <- "Two angio INRs"
    +  
    +  # Combine into single object
    +  fig5_df <- dplyr::bind_rows(baseline_f5, exclusive_f5, twoangio_f5)
    +  
    +  # Create figure using simmer's plot
    +  p <- plot(fig5_df, metric="utilization") +
    +    xlab("Scenarios") +
    +    ylab("Utilisation") +
    +    scale_y_continuous(labels = scales::percent, limits=c(0, 0.4)) +
    +    ggtitle("") +
    +    geom_text(aes(label=round(.data$Q50*100)), vjust=-1)
    +  p
    +  
    +  # Save to provided path
    +  ggsave(path_fig5, width=5, height=2.5)
    +}
    +
    +
    +
    +

    Time elapsed

    +
    +
    if (isTRUE(run)) {
    +  end.time <- Sys.time()
    +  elapsed.time <- round((end.time - start.time), 3)
    +  elapsed.time
    +}
    +
    + + +
    + +
    + +
    + + + + + + \ No newline at end of file diff --git a/reproduction/scripts/reproduction_files/figure-html/fig2a_seeds_arrange-1.png b/reproduction/scripts/reproduction_files/figure-html/fig2a_seeds_arrange-1.png deleted file mode 100644 index 8f6f164..0000000 Binary files a/reproduction/scripts/reproduction_files/figure-html/fig2a_seeds_arrange-1.png and /dev/null differ diff --git a/reproduction/scripts/reproduction_supp.html b/reproduction/scripts/reproduction_supp.html new file mode 100644 index 0000000..d670dc4 --- /dev/null +++ b/reproduction/scripts/reproduction_supp.html @@ -0,0 +1,835 @@ + + + + + + + + + +Reproducing Huang et al. 2019 - Reproduce supplementary figure + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    + +
    + + + + +
    + +
    +
    +

    Reproduce supplementary figure

    +
    + + + +
    + + + + +
    + + + +
    + + +

    This is run in a separate script from the other figures due to issues with RStudio crashing when all scenarios were run from a single script.

    +

    If run is TRUE, it will run scenarios with double and triple the number of ECR patients.

    +

    To create the figure, it will use those files, as well as the baseline file created within reproduction.qmd.

    +

    Run time: 4.975 minutes (will vary between machines)

    +
    +

    Set up

    +
    +
    # Clear environment
    +rm(list=ls())
    +
    +# Start timer
    +start.time <- Sys.time()
    +
    +# Disable scientific notation
    +options(scipen=999)
    +
    +# Get the model and helper functions (but hide loading warnings for each package)
    +suppressMessages(source("model.R"))
    +suppressMessages(source("helpers.R"))
    +
    +# Import other required libraries (if not otherwise import in R scripts below)
    +library(ggpubr)
    +library(tidyr, include.only = c("pivot_wider"))
    +
    +
    +
    # Set the seed and default dimensions for figures
    +SEED = 200
    +DEFAULT_WIDTH = 7
    +DEFAULT_HEIGHT = 4
    +
    +# Set file paths to save results
    +folder = "../outputs"
    +
    +path_baseline_f2 <- file.path(folder, "fig2_baseline.csv.gz")
    +path_double_sup <- file.path(folder, "sup_baseline_double.csv.gz")
    +path_triple_sup <- file.path(folder, "sup_baseline_triple.csv.gz")
    +
    +path_supfig <- file.path(folder, "supplementary_figure.png")
    +
    +
    +
    +

    Run models

    +

    Set to true or false, depending on whether you want to run everything.

    +
    +
    run <- FALSE
    +
    +

    Run baseline with double and triple the number of ECR patients, for the supplementary figure.

    +
    +
    if (isTRUE(run)) {
    +  baseline_sup2 <- run_model(seed = SEED, ecr_pt = 58*2)
    +  baseline_sup3 <- run_model(seed = SEED, ecr_pt = 58*3)
    +}
    +
    +
    +
    if (isTRUE(run)) {
    +  # Save results
    +  data.table::fwrite(baseline_sup2, path_double_sup)
    +  data.table::fwrite(baseline_sup3, path_triple_sup)
    +
    +  # Remove the dataframes from environment
    +  rm(baseline_sup2, baseline_sup3)
    +}
    +
    +
    +
    +

    Import results

    +

    Import the results, adding a column to each to indicate the scenario.

    +
    +
    base_f2 <- import_results(path_baseline_f2, "Baseline")
    +base_sup_double <- import_results(path_double_sup, "Baseline (double)")
    +base_sup_triple <- import_results(path_triple_sup, "Baseline (triple)")
    +
    +
    +
    +

    Supplementary figure

    +
    +
    # Create sub-plots
    +p1 <- create_plot(base_f2,
    +                  group="resource",
    +                  title="Baseline",
    +                  ylab="Standardised density of patient in queue")
    +p2 <- create_plot(base_sup_double,
    +                  group="resource",
    +                  title="Doubling ECR patients",
    +                  xlab="Patient wait time (min)",
    +                  xlim=c(0, 300),
    +                  breaks_width=100)
    +p3 <- create_plot(base_sup_triple,
    +                  group="resource",
    +                  title="Tripling ECR patients",
    +                  xlim=c(0, 300))
    +
    +# Arrange in a single figure
    +ggarrange(p1, p2, p3, nrow=1,
    +          common.legend=TRUE, legend="bottom",
    +          labels=c("A", "B", "C"))
    +
    +
    Warning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).
    +Removed 1 row containing non-finite outside the scale range (`stat_density()`).
    +Removed 1 row containing non-finite outside the scale range (`stat_density()`).
    +Removed 1 row containing non-finite outside the scale range (`stat_density()`).
    +
    +
    +
    Warning: Removed 4 rows containing non-finite outside the scale range
    +(`stat_density()`).
    +Removed 4 rows containing non-finite outside the scale range
    +(`stat_density()`).
    +
    +
    +
    Warning: Removed 3 rows containing non-finite outside the scale range
    +(`stat_density()`).
    +Removed 3 rows containing non-finite outside the scale range
    +(`stat_density()`).
    +
    +
    +
    +
    +

    +
    +
    +
    +
    ggsave(path_supfig, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT)
    +
    +
    +
    +

    Time elapsed

    +
    +
    if (isTRUE(run)) {
    +  end.time <- Sys.time()
    +  elapsed.time <- round((end.time - start.time), 3)
    +  elapsed.time
    +}
    +
    + + +
    + +
    + +
    + + + + + + \ No newline at end of file diff --git a/reproduction/scripts/reproduction_files/figure-html/supplementary_figure-1.png b/reproduction/scripts/reproduction_supp_files/figure-html/supplementary_figure-1.png similarity index 100% rename from reproduction/scripts/reproduction_files/figure-html/supplementary_figure-1.png rename to reproduction/scripts/reproduction_supp_files/figure-html/supplementary_figure-1.png diff --git a/search.json b/search.json index 7694e2e..8496067 100644 --- a/search.json +++ b/search.json @@ -447,6 +447,41 @@ "section": "", "text": "This page evaluates the extent to which the original study meets the recommendations from the STARS framework for the sharing of code and associated materials from discrete-event simulation models (Monks, Harper, and Mustafee (2024)).\nOf the 8 essential STARS components:\n\n2 were met fully (✅)\n6 were not met (❌)\n\nOf the 5 optional STARS components:\n\n2 were met fully (✅)\n3 were not met (❌)\n\n\n\n\n\n\n\n\n\n\nComponent\nDescription\nMet by study?\nEvidence/location\n\n\n\n\nEssential components\n\n\n\n\n\nOpen license\nFree and open-source software (FOSS) license (e.g. MIT, GNU Public License (GPL))\n✅ Fully\nGPL-3.0\n\n\nDependency management\nSpecify software libraries, version numbers and sources (e.g. dependency management tools like virtualenv, conda, poetry)\n❌ Not met\n-\n\n\nFOSS model\nCoded in FOSS language (e.g. R, Julia, Python)\n✅ Fully\nR\n\n\nMinimum documentation\nMinimal instructions (e.g. in README) that overview (a) what model does, (b) how to install and run model to obtain results, and (c) how to vary parameters to run new experiments\n❌ Not met\nNo documentation provided\n\n\nORCID\nORCID for each study author\n❌ Not met\n-\n\n\nCitation information\nInstructions on how to cite the research artefact (e.g. CITATION.cff file)\n❌ Not met\n-\n\n\nRemote code repository\nCode available in a remote code repository (e.g. GitHub, GitLab, BitBucket)\n❌ Not met\n-\n\n\nOpen science archive\nCode stored in an open science archive with FORCE11 compliant citation and guaranteed persistance of digital artefacts (e.g. Figshare, Zenodo, the Open Science Framework (OSF), and the Computational Modeling in the Social and Ecological Sciences Network (CoMSES Net))\n❌ Not met\n-\n\n\nOptional components\n\n\n\n\n\nEnhanced documentation\nOpen and high quality documentation on how the model is implemented and works (e.g. via notebooks and markdown files, brought together using software like Quarto and Jupyter Book). Suggested content includes:• Plain english summary of project and model• Clarifying license• Citation instructions• Contribution instructions• Model installation instructions• Structured code walk through of model• Documentation of modelling cycle using TRACE• Annotated simulation reporting guidelines• Clear description of model validation including its intended purpose\n❌ Not met\n-\n\n\nDocumentation hosting\nHost documentation (e.g. with GitHub pages, GitLab pages, BitBucket Cloud, Quarto Pub)\n❌ Not met\n-\n\n\nOnline coding environment\nProvide an online environment where users can run and change code (e.g. BinderHub, Google Colaboratory, Deepnote)\n❌ Not met\n-\n\n\nModel interface\nProvide web application interface to the model so it is accessible to less technical simulation users\n✅ Fully\nShiny application that allows you to modify parameters and produces graphs showing waiting times for each patient type at the angioINR (boxplots grouped into <20, 20-40 and 40+ minutes), and resource utilisation. There is also a linked CLOUDES model of the simulation to aid user understanding.\n\n\nWeb app hosting\nHost web app online (e.g. Streamlit Community Cloud, ShinyApps hosting)\n✅ Fully\nHosted with ShinyApps at https://compneuro.shinyapps.io/desECR11/\n\n\n\n\n\n\n\nReferences\n\nMonks, Thomas, Alison Harper, and Navonil Mustafee. 2024. “Towards Sharing Tools and Artefacts for Reusable Simulations in Healthcare.” Journal of Simulation 0 (0): 1–20. https://doi.org/10.1080/17477778.2024.2347882." }, + { + "objectID": "reproduction/scripts/reproduction_fig5.html", + "href": "reproduction/scripts/reproduction_fig5.html", + "title": "Reproduce Figure 5", + "section": "", + "text": "This is run in a separate script from the other figures due to issues with RStudio crashing when all scenarios were run from a single script.\nRun time: 6.165 minutes (will vary between machines)" + }, + { + "objectID": "reproduction/scripts/reproduction_fig5.html#set-up", + "href": "reproduction/scripts/reproduction_fig5.html#set-up", + "title": "Reproduce Figure 5", + "section": "Set up", + "text": "Set up\n\n# Clear environment\nrm(list=ls())\n\n# Start timer\nstart.time <- Sys.time()\n\n# Disable scientific notation\noptions(scipen=999)\n\n# Get the model and helper functions (but hide loading warnings for each package)\nsuppressMessages(source(\"model.R\"))\nsuppressMessages(source(\"helpers.R\"))\n\n\n# Set the seed and default dimensions for figures\nSEED = 200\n\n# Set file paths to save results\nfolder = \"../outputs\"\npath_fig5 <- file.path(folder, \"fig5.png\")" + }, + { + "objectID": "reproduction/scripts/reproduction_fig5.html#run-models", + "href": "reproduction/scripts/reproduction_fig5.html#run-models", + "title": "Reproduce Figure 5", + "section": "Run models", + "text": "Run models\n\nrun <- FALSE\n\n\nif (isTRUE(run)) {\n baseline_f5 <- run_model(seed = SEED, fig5=TRUE)\n exclusive_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE)\n twoangio_f5 <- run_model(angio_inr = 2, angio_ir=0, seed = SEED, fig5=TRUE)\n}" + }, + { + "objectID": "reproduction/scripts/reproduction_fig5.html#create-figure", + "href": "reproduction/scripts/reproduction_fig5.html#create-figure", + "title": "Reproduce Figure 5", + "section": "Create figure", + "text": "Create figure\nCurrently depends on simmer.plot() function that doesn’t work on the imported results from the csv file, so need to allow to run model to produce this plot!\n\nif (isTRUE(run)) {\n # Replace resource (which has been filtered to angioINR) with scenario\n baseline_f5$resource <- \"Baseline\"\n exclusive_f5$resource <-\"Exclusive-use\"\n twoangio_f5$resource <- \"Two angio INRs\"\n \n # Combine into single object\n fig5_df <- dplyr::bind_rows(baseline_f5, exclusive_f5, twoangio_f5)\n \n # Create figure using simmer's plot\n p <- plot(fig5_df, metric=\"utilization\") +\n xlab(\"Scenarios\") +\n ylab(\"Utilisation\") +\n scale_y_continuous(labels = scales::percent, limits=c(0, 0.4)) +\n ggtitle(\"\") +\n geom_text(aes(label=round(.data$Q50*100)), vjust=-1)\n p\n \n # Save to provided path\n ggsave(path_fig5, width=5, height=2.5)\n}" + }, + { + "objectID": "reproduction/scripts/reproduction_fig5.html#time-elapsed", + "href": "reproduction/scripts/reproduction_fig5.html#time-elapsed", + "title": "Reproduce Figure 5", + "section": "Time elapsed", + "text": "Time elapsed\n\nif (isTRUE(run)) {\n end.time <- Sys.time()\n elapsed.time <- round((end.time - start.time), 3)\n elapsed.time\n}" + }, { "objectID": "quarto_site/study_publication.html", "href": "quarto_site/study_publication.html", @@ -594,80 +629,108 @@ "section": "", "text": "This repository is licensed under the [license].\n\n\n\n\n\n\nView license\n\n\n\n\n\nGNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright © 2007 Free Software Foundation, Inc. http://fsf.org/\nEveryone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.\nPreamble\nThe GNU General Public License is a free, copyleft license for software and other kinds of works.\nThe licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program–to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\nTo protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.\nFor example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.\nDevelopers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.\nFor the developers’ and authors’ protection, the GPL clearly explains that there is no warranty for this free software. For both users’ and authors’ sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.\nSome devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users’ freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.\nFinally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.\nThe precise terms and conditions for copying, distribution and modification follow.\nTERMS AND CONDITIONS\n\nDefinitions.\n\n“This License” refers to version 3 of the GNU General Public License.\n“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.\n“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.\nTo “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.\nA “covered work” means either the unmodified Program or a work based on the Program.\nTo “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.\nTo “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.\nAn interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.\n\nSource Code. The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.\n\nA “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.\nThe “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.\nThe “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work’s System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.\nThe Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.\nThe Corresponding Source for a work in source code form is that same work.\n\nBasic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.\n\nYou may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.\nConveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.\n\nProtecting Users’ Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.\n\nWhen you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work’s users, your or third parties’ legal rights to forbid circumvention of technological measures.\n\nConveying Verbatim Copies. You may convey verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.\n\nYou may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.\n\nConveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:\n\n\nThe work must carry prominent notices stating that you modified it, and giving a relevant date.\nThe work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.\nYou must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.\nIf the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.\n\nA compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation’s users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.\n\nConveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:\n\n\nConvey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.\nConvey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.\nConvey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.\nConvey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.\nConvey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.\n\nA separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.\nA “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.\n“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.\nIf you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).\nThe requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.\nCorresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.\n\nAdditional Terms. “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.\n\nWhen you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.\nNotwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:\n\nDisclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or\nRequiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or\nProhibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or\nLimiting the use for publicity purposes of names of licensors or authors of the material; or\nDeclining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or\nRequiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.\n\nAll other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.\nIf you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.\nAdditional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.\n\nTermination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).\n\nHowever, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.\nMoreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.\nTermination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.\n\nAcceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.\nAutomatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.\n\nAn “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party’s predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.\nYou may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.\n\nPatents. A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor’s “contributor version”.\n\nA contributor’s “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.\nEach contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor’s essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.\nIn the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.\nIf you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient’s use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.\nIf, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.\nA patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.\nNothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.\n\nNo Surrender of Others’ Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.\nUse with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.\nRevised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.\nIf the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Program.\nLater license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.\n\nDisclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\nLimitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\nInterpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.\n\nEND OF TERMS AND CONDITIONS\nHow to Apply These Terms to Your New Programs\nIf you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.\nTo do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.\n<one line to give the program’s name and a brief idea of what it does.> Copyright (C) \nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.\nAlso add information on how to contact you by electronic and paper mail.\nIf the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:\n Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type show w'. This is free software, and you are welcome to redistribute it under certain conditions; typeshow c’ for details.\nThe hypothetical commands show w' andshow c’ should show the appropriate parts of the General Public License. Of course, your program’s commands might be different; for a GUI interface, you would use an “about box”.\nYou should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see http://www.gnu.org/licenses/.\nThe GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read http://www.gnu.org/philosophy/why-not-lgpl.html.\n\n\n\n\nThis is aligned with the original study, who shared their code under [license].\n\n\n\n\n\n\nView license\n\n\n\n\n\n\n[Embedded license]\n\n\n\n\nThe original study was published in the journal “[Journal name]”. They distributed the article under [Add more details about license]\n\n\n\n\n\n\nView copyright statement from journal" }, + { + "objectID": "reproduction/scripts/reproduction_supp.html", + "href": "reproduction/scripts/reproduction_supp.html", + "title": "Reproduce supplementary figure", + "section": "", + "text": "This is run in a separate script from the other figures due to issues with RStudio crashing when all scenarios were run from a single script.\nIf run is TRUE, it will run scenarios with double and triple the number of ECR patients.\nTo create the figure, it will use those files, as well as the baseline file created within reproduction.qmd.\nRun time: 4.975 minutes (will vary between machines)" + }, + { + "objectID": "reproduction/scripts/reproduction_supp.html#set-up", + "href": "reproduction/scripts/reproduction_supp.html#set-up", + "title": "Reproduce supplementary figure", + "section": "Set up", + "text": "Set up\n\n# Clear environment\nrm(list=ls())\n\n# Start timer\nstart.time <- Sys.time()\n\n# Disable scientific notation\noptions(scipen=999)\n\n# Get the model and helper functions (but hide loading warnings for each package)\nsuppressMessages(source(\"model.R\"))\nsuppressMessages(source(\"helpers.R\"))\n\n# Import other required libraries (if not otherwise import in R scripts below)\nlibrary(ggpubr)\nlibrary(tidyr, include.only = c(\"pivot_wider\"))\n\n\n# Set the seed and default dimensions for figures\nSEED = 200\nDEFAULT_WIDTH = 7\nDEFAULT_HEIGHT = 4\n\n# Set file paths to save results\nfolder = \"../outputs\"\n\npath_baseline_f2 <- file.path(folder, \"fig2_baseline.csv.gz\")\npath_double_sup <- file.path(folder, \"sup_baseline_double.csv.gz\")\npath_triple_sup <- file.path(folder, \"sup_baseline_triple.csv.gz\")\n\npath_supfig <- file.path(folder, \"supplementary_figure.png\")" + }, + { + "objectID": "reproduction/scripts/reproduction_supp.html#run-models", + "href": "reproduction/scripts/reproduction_supp.html#run-models", + "title": "Reproduce supplementary figure", + "section": "Run models", + "text": "Run models\nSet to true or false, depending on whether you want to run everything.\n\nrun <- FALSE\n\nRun baseline with double and triple the number of ECR patients, for the supplementary figure.\n\nif (isTRUE(run)) {\n baseline_sup2 <- run_model(seed = SEED, ecr_pt = 58*2)\n baseline_sup3 <- run_model(seed = SEED, ecr_pt = 58*3)\n}\n\n\nif (isTRUE(run)) {\n # Save results\n data.table::fwrite(baseline_sup2, path_double_sup)\n data.table::fwrite(baseline_sup3, path_triple_sup)\n\n # Remove the dataframes from environment\n rm(baseline_sup2, baseline_sup3)\n}" + }, + { + "objectID": "reproduction/scripts/reproduction_supp.html#import-results", + "href": "reproduction/scripts/reproduction_supp.html#import-results", + "title": "Reproduce supplementary figure", + "section": "Import results", + "text": "Import results\nImport the results, adding a column to each to indicate the scenario.\n\nbase_f2 <- import_results(path_baseline_f2, \"Baseline\")\nbase_sup_double <- import_results(path_double_sup, \"Baseline (double)\")\nbase_sup_triple <- import_results(path_triple_sup, \"Baseline (triple)\")" + }, + { + "objectID": "reproduction/scripts/reproduction_supp.html#supplementary-figure", + "href": "reproduction/scripts/reproduction_supp.html#supplementary-figure", + "title": "Reproduce supplementary figure", + "section": "Supplementary figure", + "text": "Supplementary figure\n\n# Create sub-plots\np1 <- create_plot(base_f2,\n group=\"resource\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\np2 <- create_plot(base_sup_double,\n group=\"resource\",\n title=\"Doubling ECR patients\",\n xlab=\"Patient wait time (min)\",\n xlim=c(0, 300),\n breaks_width=100)\np3 <- create_plot(base_sup_triple,\n group=\"resource\",\n title=\"Tripling ECR patients\",\n xlim=c(0, 300))\n\n# Arrange in a single figure\nggarrange(p1, p2, p3, nrow=1,\n common.legend=TRUE, legend=\"bottom\",\n labels=c(\"A\", \"B\", \"C\"))\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n\nWarning: Removed 4 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 4 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\nWarning: Removed 3 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 3 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\n\n\n\n\n\n\nggsave(path_supfig, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT)" + }, + { + "objectID": "reproduction/scripts/reproduction_supp.html#time-elapsed", + "href": "reproduction/scripts/reproduction_supp.html#time-elapsed", + "title": "Reproduce supplementary figure", + "section": "Time elapsed", + "text": "Time elapsed\n\nif (isTRUE(run)) {\n end.time <- Sys.time()\n elapsed.time <- round((end.time - start.time), 3)\n elapsed.time\n}" + }, { "objectID": "reproduction/scripts/reproduction.html", "href": "reproduction/scripts/reproduction.html", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "", - "text": "# Clear environment\nrm(list=ls())\n\n# Start timer\nstart.time <- Sys.time()\n\n# Disable scientific notation\noptions(scipen=999)\n\n# Import required libraries (if not otherwise import in model.R)\nlibrary(ggplot2)\nlibrary(data.table)\nlibrary(ggpubr)\nlibrary(tidyr, include.only = c(\"pivot_wider\"))\n\n# Get the model and helper functiosn (but hide loading warnings for each package)\nsuppressMessages(source(\"model.R\"))\nsource(\"helpers.R\")\n\n\n# Set the seed\nSEED = 200\n\n# Set default dimensions for figures\nDEFAULT_WIDTH = 7\nDEFAULT_HEIGHT = 4\n\n# Set file paths to save results\n\nfolder = \"../outputs\"\n\npath_baseline_f2 <- file.path(folder, \"fig2_baseline.csv.gz\")\npath_exclusive_f2 <- file.path(folder, \"fig2_exclusive.csv.gz\")\npath_twoangio_f2 <- file.path(folder, \"fig2_twoangio.csv.gz\")\n\npath_baseline_f3 <- file.path(folder, \"fig3_baseline.csv.gz\")\npath_exclusive_f3 <- file.path(folder, \"fig3_exclusive.csv.gz\")\npath_twoangio_f3 <- file.path(folder, \"fig3_twoangio.csv.gz\")\npath_baseline_f3_seed500 <- file.path(folder, \"fig3_baseline_seed500.csv.gz\")\npath_baseline_f3_seed700 <- file.path(folder, \"fig3_baseline_seed700.csv.gz\")\npath_twoangio_f3_seed500 <- file.path(folder, \"fig3_twoangio_seed500.csv.gz\")\npath_twoangio_f3_seed700 <- file.path(folder, \"fig3_twoangio_seed700.csv.gz\")\n\npath_baseline_f5 <- file.path(folder, \"fig5_baseline.csv.gz\")\npath_exclusive_f5 <- file.path(folder, \"fig5_exclusive.csv.gz\")\npath_twoangio_f5 <- file.path(folder, \"fig5_twoangio.csv.gz\")\n\npath_double_sup <- file.path(folder, \"sup_baseline_double.csv.gz\")\npath_triple_sup <- file.path(folder, \"sup_baseline_triple.csv.gz\")\n\npath_txt2 <- file.path(folder, \"txt2.csv\")\npath_txt3 <- file.path(folder, \"txt3.csv\")\npath_txt3_seeds <- file.path(folder, \"txt3_seeds.csv\")\npath_fig2 <- file.path(folder, \"fig2.png\")\npath_fig2a_seeds <- file.path(folder, \"fig2a_seeds.png\")\npath_fig3 <- file.path(folder, \"fig3.png\")\npath_fig4 <- file.path(folder, \"fig4.png\")\npath_fig5 <- file.path(folder, \"fig5.png\")\npath_supfig <- file.path(folder, \"supplementary_figure.png\")" + "text": "The majority of the items in the model scope are reproduced in this file, but Figure 5 and the supplementary figure are created in seperate .qmd files.\nThis decision was primarily due to issues with RStudio crashing when running all scenarios from a single .Rmd file.\nRun time: 18.024 minutes (will vary between machines)" }, { "objectID": "reproduction/scripts/reproduction.html#set-up", "href": "reproduction/scripts/reproduction.html#set-up", - "title": "Reproduction", - "section": "", - "text": "# Clear environment\nrm(list=ls())\n\n# Start timer\nstart.time <- Sys.time()\n\n# Disable scientific notation\noptions(scipen=999)\n\n# Import required libraries (if not otherwise import in model.R)\nlibrary(ggplot2)\nlibrary(data.table)\nlibrary(ggpubr)\nlibrary(tidyr, include.only = c(\"pivot_wider\"))\n\n# Get the model and helper functiosn (but hide loading warnings for each package)\nsuppressMessages(source(\"model.R\"))\nsource(\"helpers.R\")\n\n\n# Set the seed\nSEED = 200\n\n# Set default dimensions for figures\nDEFAULT_WIDTH = 7\nDEFAULT_HEIGHT = 4\n\n# Set file paths to save results\n\nfolder = \"../outputs\"\n\npath_baseline_f2 <- file.path(folder, \"fig2_baseline.csv.gz\")\npath_exclusive_f2 <- file.path(folder, \"fig2_exclusive.csv.gz\")\npath_twoangio_f2 <- file.path(folder, \"fig2_twoangio.csv.gz\")\n\npath_baseline_f3 <- file.path(folder, \"fig3_baseline.csv.gz\")\npath_exclusive_f3 <- file.path(folder, \"fig3_exclusive.csv.gz\")\npath_twoangio_f3 <- file.path(folder, \"fig3_twoangio.csv.gz\")\npath_baseline_f3_seed500 <- file.path(folder, \"fig3_baseline_seed500.csv.gz\")\npath_baseline_f3_seed700 <- file.path(folder, \"fig3_baseline_seed700.csv.gz\")\npath_twoangio_f3_seed500 <- file.path(folder, \"fig3_twoangio_seed500.csv.gz\")\npath_twoangio_f3_seed700 <- file.path(folder, \"fig3_twoangio_seed700.csv.gz\")\n\npath_baseline_f5 <- file.path(folder, \"fig5_baseline.csv.gz\")\npath_exclusive_f5 <- file.path(folder, \"fig5_exclusive.csv.gz\")\npath_twoangio_f5 <- file.path(folder, \"fig5_twoangio.csv.gz\")\n\npath_double_sup <- file.path(folder, \"sup_baseline_double.csv.gz\")\npath_triple_sup <- file.path(folder, \"sup_baseline_triple.csv.gz\")\n\npath_txt2 <- file.path(folder, \"txt2.csv\")\npath_txt3 <- file.path(folder, \"txt3.csv\")\npath_txt3_seeds <- file.path(folder, \"txt3_seeds.csv\")\npath_fig2 <- file.path(folder, \"fig2.png\")\npath_fig2a_seeds <- file.path(folder, \"fig2a_seeds.png\")\npath_fig3 <- file.path(folder, \"fig3.png\")\npath_fig4 <- file.path(folder, \"fig4.png\")\npath_fig5 <- file.path(folder, \"fig5.png\")\npath_supfig <- file.path(folder, \"supplementary_figure.png\")" + "title": "Reproduce Figures 2-4 and in-text results 1-3", + "section": "Set up", + "text": "Set up\n\n# Clear environment\nrm(list=ls())\n\n# Start timer\nstart.time <- Sys.time()\n\n# Disable scientific notation\noptions(scipen=999)\n\n# Import required libraries (if not otherwise import in R scripts below)\nlibrary(ggpubr)\n\nLoading required package: ggplot2\n\nlibrary(tidyr, include.only = c(\"pivot_wider\"))\n\n# Get the model and helper functions (but hide loading warnings for each package)\nsuppressMessages(source(\"model.R\"))\nsuppressMessages(source(\"helpers.R\"))\n\n\n# Set the seed and default dimensions for figures\nSEED = 200\nDEFAULT_WIDTH = 7\nDEFAULT_HEIGHT = 4\n\n# Set file paths to save results\n\nfolder = \"../outputs\"\n\npath_baseline_f2 <- file.path(folder, \"fig2_baseline.csv.gz\")\npath_exclusive_f2 <- file.path(folder, \"fig2_exclusive.csv.gz\")\npath_twoangio_f2 <- file.path(folder, \"fig2_twoangio.csv.gz\")\n\npath_baseline_f3 <- file.path(folder, \"fig3_baseline.csv.gz\")\npath_exclusive_f3 <- file.path(folder, \"fig3_exclusive.csv.gz\")\npath_twoangio_f3 <- file.path(folder, \"fig3_twoangio.csv.gz\")\n\npath_txt2 <- file.path(folder, \"txt2.csv\") # Used for results 1 and 2\npath_txt3 <- file.path(folder, \"txt3.csv\")\npath_fig2 <- file.path(folder, \"fig2.png\")\npath_fig3 <- file.path(folder, \"fig3.png\")\npath_fig4 <- file.path(folder, \"fig4.png\")" }, { "objectID": "reproduction/scripts/reproduction.html#run-models", "href": "reproduction/scripts/reproduction.html#run-models", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "Run models", - "text": "Run models\nRun model scenarios.\n\nif (isTRUE(run)) {\n # Run model\n baseline <- run_model(seed = SEED)\n baseline_6pm <- run_model(shifts = c(8,18), seed = SEED)\n baseline_7pm <- run_model(shifts = c(8,19), seed = SEED)\n\n exclusive <- run_model(exclusive_use = TRUE, seed = SEED)\n exclusive_6pm <- run_model(shifts = c(8,18), exclusive_use = TRUE, seed = SEED)\n exclusive_7pm <- run_model(shifts = c(8,19), exclusive_use = TRUE, seed = SEED)\n\n twoangio <- run_model(angio_inr = 2, angio_ir=0, seed = SEED)\n twoangio_6pm <- run_model(shifts = c(8,18), angio_inr = 2, angio_ir=0, seed = SEED)\n twoangio_7pm <- run_model(shifts = c(8,19), angio_inr = 2, angio_ir=0, seed = SEED)\n}\n\n\n# (in seperate cell to above as otherwise seemed to crash)\nif (isTRUE(run)) {\n # Save results for Figure 2\n data.table::fwrite(baseline, path_baseline_f2)\n data.table::fwrite(exclusive, path_exclusive_f2)\n data.table::fwrite(twoangio, path_twoangio_f2)\n\n # Process and save results for Figure 3\n process_f3_data(baseline, baseline_6pm, baseline_7pm, path_baseline_f3)\n process_f3_data(exclusive, exclusive_6pm, exclusive_7pm, path_exclusive_f3)\n process_f3_data(twoangio, twoangio_6pm, twoangio_7pm, path_twoangio_f3)\n}\n\nRe-run models but return different output from standard hours for use in Figure 5\n\nif (isTRUE(run)) {\n baseline_f5 <- run_model(seed = SEED, fig5=TRUE)\n exclusive_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE)\n twoangio_f5 <- run_model(angio_inr = 2, angio_ir=0, seed = SEED, fig5=TRUE)\n}\n\n\nif (isTRUE(run)) {\n data.table::fwrite(baseline_f5, path_baseline_f5)\n data.table::fwrite(exclusive_f5, path_exclusive_f5)\n data.table::fwrite(twoangio_f5, path_twoangio_f5)\n}\n\nRun baseline with double and triple the number of ECR patients, for the supplementary figure.\n\nif (isTRUE(run)) {\n baseline_sup2 <- run_model(seed = SEED, ecr_pt = 58*2)\n baseline_sup3 <- run_model(seed = SEED, ecr_pt = 58*3)\n}\n\n\nif (isTRUE(run)) {\n data.table::fwrite(baseline_sup2, path_double_sup)\n data.table::fwrite(baseline_sup3, path_triple_sup)\n}\n\nRun baseline and double angioINR with varying hours and seeds.\n\nif (isTRUE(run)) {\n # Baseline with varying hours and seed 500\n s500_baseline <- run_model(seed = 500)\n s500_baseline_6pm <- run_model(shifts = c(8,18), seed = 500)\n s500_baseline_7pm <- run_model(shifts = c(8,19), seed = 500)\n\n # Baseline with varying hours and seed 700\n s700_baseline <- run_model(seed = 700)\n s700_baseline_6pm <- run_model(shifts = c(8,18), seed = 700)\n s700_baseline_7pm <- run_model(shifts = c(8,19), seed = 700)\n\n # Double AngioINR with varying hours and seed 500\n s500_twoangio <- run_model(angio_inr = 2, angio_ir=0, seed = 500)\n s500_twoangio_6pm <- run_model(shifts = c(8,18), angio_inr = 2, angio_ir=0, seed = 500)\n s500_twoangio_7pm <- run_model(shifts = c(8,19), angio_inr = 2, angio_ir=0, seed = 500)\n\n # Double AngioINR with varying hours and seed 700\n s700_twoangio <- run_model(angio_inr = 2, angio_ir=0, seed = 700)\n s700_twoangio_6pm <- run_model(shifts = c(8,18), angio_inr = 2, angio_ir=0, seed = 700)\n s700_twoangio_7pm <- run_model(shifts = c(8,19), angio_inr = 2, angio_ir=0, seed = 700)\n}\n\n\n# Save results (in seperate cell to above as otherwise seemed to crash)\nif (isTRUE(run)) {\n process_f3_data(s500_baseline, s500_baseline_6pm, s500_baseline_7pm,\n path_baseline_f3_seed500)\n process_f3_data(s700_baseline, s700_baseline_6pm, s700_baseline_7pm,\n path_baseline_f3_seed700)\n process_f3_data(s500_twoangio, s500_twoangio_6pm, s500_twoangio_7pm,\n path_twoangio_f3_seed500)\n process_f3_data(s700_twoangio, s700_twoangio_6pm, s700_twoangio_7pm,\n path_twoangio_f3_seed700)\n}\n\nRun baseline with several different seeds\n\nbaseline_seeds <- function(seed, run, folder) {\n #' Run baseline model with different seeds\n #' \n #' @param seed integer, starting seed for replications\n #' @param run boolean, whether to run model\n #' @param folder string, folder to store results in\n if (isTRUE(run)) {\n seed_baseline <- run_model(seed = seed)\n seed_path <- file.path(folder, paste(\n \"fig2_baseline_seed\", seed, \".csv.gz\", sep=\"\"))\n data.table::fwrite(seed_baseline, seed_path)\n }\n}\n\nbaseline_seeds(0, run, folder)\nbaseline_seeds(50, run, folder)\nbaseline_seeds(100, run, folder)\nbaseline_seeds(150, run, folder)\nbaseline_seeds(450, run, folder)\nbaseline_seeds(700, run, folder)\nbaseline_seeds(750, run, folder)" + "text": "Run models\nSet to true or false, depending on whether you want to run everything.\n\nrun <- FALSE\n\nRun model scenarios.\n\nif (isTRUE(run)) {\n # Run model\n baseline <- run_model(seed = SEED)\n baseline_6pm <- run_model(shifts = c(8,18), seed = SEED)\n baseline_7pm <- run_model(shifts = c(8,19), seed = SEED)\n\n exclusive <- run_model(exclusive_use = TRUE, seed = SEED)\n exclusive_6pm <- run_model(shifts = c(8,18), exclusive_use = TRUE, seed = SEED)\n exclusive_7pm <- run_model(shifts = c(8,19), exclusive_use = TRUE, seed = SEED)\n\n twoangio <- run_model(angio_inr = 2, angio_ir=0, seed = SEED)\n twoangio_6pm <- run_model(shifts = c(8,18), angio_inr = 2, angio_ir=0, seed = SEED)\n twoangio_7pm <- run_model(shifts = c(8,19), angio_inr = 2, angio_ir=0, seed = SEED)\n}\n\n\n# (in seperate cell to above as otherwise seemed to crash)\nif (isTRUE(run)) {\n # Save results for Figure 2\n data.table::fwrite(baseline, path_baseline_f2)\n data.table::fwrite(exclusive, path_exclusive_f2)\n data.table::fwrite(twoangio, path_twoangio_f2)\n\n # Process and save results for Figure 3\n process_f3_data(baseline, baseline_6pm, baseline_7pm, path_baseline_f3)\n process_f3_data(exclusive, exclusive_6pm, exclusive_7pm, path_exclusive_f3)\n process_f3_data(twoangio, twoangio_6pm, twoangio_7pm, path_twoangio_f3)\n\n # Remove the dataframes from environment\n rm(baseline, baseline_6pm, baseline_7pm,\n exclusive, exclusive_6pm, exclusive_7pm,\n twoangio, twoangio_6pm, twoangio_7pm)\n}" }, { "objectID": "reproduction/scripts/reproduction.html#import-results", "href": "reproduction/scripts/reproduction.html#import-results", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "Import results", - "text": "Import results\nImport the results, adding a column to each to indicate the scenario.\n\nbase_f2 <- import_results(path_baseline_f2,\n \"Baseline\")\nexc_f2 <- import_results(path_exclusive_f2,\n \"Exclusive use\")\ntwo_f2 <- import_results(path_twoangio_f2,\n \"Two AngioINRs\")\n\nbase_f3 <- import_results(path_baseline_f3,\n \"Baseline\")\nexc_f3 <- import_results(path_exclusive_f3,\n \"Exclusive use\")\ntwo_f3 <- import_results(path_twoangio_f3,\n \"Two AngioINRs\")\n\nbase_f3_s500 <- import_results(path_baseline_f3_seed500,\n \"Baseline (seed 500)\")\nbase_f3_s700 <- import_results(path_baseline_f3_seed700,\n \"Baseline (seed 700)\")\ntwo_f3_s500 <- import_results(path_twoangio_f3_seed500,\n \"Two AngioINRs (seed 500)\")\ntwo_f3_s700 <- import_results(path_twoangio_f3_seed700,\n \"Two AngioINRs (seed 700)\")\n\nbase_f5 <- data.table::fread(path_baseline_f5)\nexc_f5 <- data.table::fread(path_exclusive_f5)\ntwo_f5 <- data.table::fread(path_twoangio_f5)\n\nbase_sup_double <- import_results(path_double_sup, \"Baseline (double)\")\nbase_sup_triple <- import_results(path_triple_sup, \"Baseline (triple)\")" + "text": "Import results\nImport the results, adding a column to each to indicate the scenario.\n\nbase_f2 <- import_results(path_baseline_f2,\n \"Baseline\")\nexc_f2 <- import_results(path_exclusive_f2,\n \"Exclusive use\")\ntwo_f2 <- import_results(path_twoangio_f2,\n \"Two AngioINRs\")\n\nbase_f3 <- import_results(path_baseline_f3,\n \"Baseline\")\nexc_f3 <- import_results(path_exclusive_f3,\n \"Exclusive use\")\ntwo_f3 <- import_results(path_twoangio_f3,\n \"Two AngioINRs\")" }, { "objectID": "reproduction/scripts/reproduction.html#in-text-results", "href": "reproduction/scripts/reproduction.html#in-text-results", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "In-text results", - "text": "In-text results\nIn-text results 1 and 2\n\ntxt2 <- dplyr::bind_rows(base_f2, exc_f2, two_f2) %>%\n filter(resource==\"angio_inr\") %>%\n group_by(scenario) %>%\n summarize(mean = mean(wait_time)) %>%\n mutate(diff_from_baseline = round(mean - mean[1], 2))\n\n# Save and display result\ndata.table::fwrite(txt2, path_txt2)\ntxt2\n\n# A tibble: 3 × 3\n scenario mean diff_from_baseline\n <chr> <dbl> <dbl>\n1 Baseline 14.0 0 \n2 Exclusive use 8.12 -5.84\n3 Two AngioINRs 9.62 -4.34\n\n\nIn-text result 3\n\ntxt3 <- dplyr::bind_rows(base_f3, exc_f3, two_f3) %>%\n filter(resource==\"angio_inr\") %>%\n group_by(scenario, shift) %>%\n summarize(mean = mean(wait_time)) %>%\n mutate(diff_from_5pm = round(mean - mean[1], 2))\n\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n\n# Save and display result\ndata.table::fwrite(txt3, path_txt3)\ntxt3\n\n# A tibble: 9 × 4\n# Groups: scenario [3]\n scenario shift mean diff_from_5pm\n <chr> <chr> <dbl> <dbl>\n1 Baseline 5pm 14.0 0 \n2 Baseline 6pm 12.5 -1.47\n3 Baseline 7pm 12.5 -1.47\n4 Exclusive use 5pm 8.12 0 \n5 Exclusive use 6pm 7.80 -0.31\n6 Exclusive use 7pm 6.43 -1.69\n7 Two AngioINRs 5pm 9.62 0 \n8 Two AngioINRs 6pm 9.22 -0.4 \n9 Two AngioINRs 7pm 8.70 -0.92\n\n\n\nDemonstrate variation between model runs\nWe can see the importance of seed control here. For example, with seed 700, we see a broader range of results, with the result for 6pm (13.32) is much higher than for the other two seeds and, compared with their 5pm results, we would’ve seen less of a reduction. Similarly, if we compared the 5pm seed 700 result with the 6pm seed 500 result, we would see a much greater reduction.\nThe same applies to the prior scenarios for Figure 2. I’ve held the seeds still between them, so the only change is the scenario.\nHowever, as we are not sure, it is also reasonable to assume that a seed might have been used for the paper, but just not mentioned in the article or included in the code.\n\n# Dataframes to analyse\nvar_list <- c(list(base_f3, base_f3_s500, base_f3_s700),\n list(two_f3, two_f3_s500, two_f3_s700))\n\n# For loop through those two lists\ndf_seeds_list <- list()\ni <- 0\nfor (l in var_list) {\n i <- i + 1\n\n # Process results\n df_seeds <- dplyr::bind_rows(l) %>%\n filter(resource==\"angio_inr\") %>%\n group_by(scenario, shift) %>%\n summarize(mean = round(mean(wait_time),2)) %>%\n ungroup()\n \n # Convert to wide format and display\n df_seeds_list[[i]] <- pivot_wider(df_seeds, id_cols=\"scenario\",\n values_from=c(\"mean\"), names_from=\"shift\")\n}\n\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n\n# Combine into single dataframe, save and display\ncombined_seeds <- dplyr::bind_rows(df_seeds_list)\ndata.table::fwrite(combined_seeds, path_txt3_seeds)\ncombined_seeds\n\n# A tibble: 6 × 4\n scenario `5pm` `6pm` `7pm`\n <chr> <dbl> <dbl> <dbl>\n1 Baseline 14.0 12.5 12.5 \n2 Baseline (seed 500) 14.0 12.2 12.2 \n3 Baseline (seed 700) 15.5 13.3 12.3 \n4 Two AngioINRs 9.62 9.22 8.7 \n5 Two AngioINRs (seed 500) 11.2 10.6 10.1 \n6 Two AngioINRs (seed 700) 10.4 9.96 9.63" + "text": "In-text results\nIn-text results 1 and 2\n\ntxt2 <- dplyr::bind_rows(base_f2, exc_f2, two_f2) %>%\n filter(resource==\"angio_inr\") %>%\n group_by(scenario) %>%\n summarize(mean = mean(wait_time)) %>%\n mutate(diff_from_baseline = round(mean - mean[1], 2))\n\n# Save and display result\ndata.table::fwrite(txt2, path_txt2)\ntxt2\n\n# A tibble: 3 × 3\n scenario mean diff_from_baseline\n <chr> <dbl> <dbl>\n1 Baseline 14.0 0 \n2 Exclusive use 8.12 -5.84\n3 Two AngioINRs 9.62 -4.34\n\n\nIn-text result 3\n\ntxt3 <- dplyr::bind_rows(base_f3, exc_f3, two_f3) %>%\n filter(resource==\"angio_inr\") %>%\n group_by(scenario, shift) %>%\n summarize(mean = mean(wait_time)) %>%\n mutate(diff_from_5pm = round(mean - mean[1], 2))\n\n`summarise()` has grouped output by 'scenario'. You can override using the\n`.groups` argument.\n\n# Save and display result\ndata.table::fwrite(txt3, path_txt3)\ntxt3\n\n# A tibble: 9 × 4\n# Groups: scenario [3]\n scenario shift mean diff_from_5pm\n <chr> <chr> <dbl> <dbl>\n1 Baseline 5pm 14.0 0 \n2 Baseline 6pm 12.5 -1.47\n3 Baseline 7pm 12.5 -1.47\n4 Exclusive use 5pm 8.12 0 \n5 Exclusive use 6pm 7.80 -0.31\n6 Exclusive use 7pm 6.43 -1.69\n7 Two AngioINRs 5pm 9.62 0 \n8 Two AngioINRs 6pm 9.22 -0.4 \n9 Two AngioINRs 7pm 8.70 -0.92" }, { "objectID": "reproduction/scripts/reproduction.html#figure-2", "href": "reproduction/scripts/reproduction.html#figure-2", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "Figure 2", - "text": "Figure 2\n\n# Create sub-plots\np1 <- create_plot(base_f2,\n group=\"resource\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\np2 <- create_plot(exc_f2,\n group=\"resource\",\n title=\"Exclusive-use\",\n xlab=\"Patient wait time (min)\",\n xlim=c(0, 250))\np3 <- create_plot(two_f2,\n group=\"resource\",\n title=\"Double angio INRs\")\n\n# Arrange in a single figure\nggarrange(p1, p2, p3, nrow=1,\n common.legend=TRUE, legend=\"bottom\",\n labels=c(\"A\", \"B\", \"C\"))\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n\n\n\n\n\n\n\nggsave(path_fig2, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT)\n\n\nDemonstrate that geom_density scaled is scaling against density of 0 wait time\n\n# Create figure as usual\np <- create_plot(base_f2,\n group=\"resource\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\n\n# Get data from the plot\nplot_data <- ggplot_build(p)$data[[1]]\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n# Create dataframe with the densities for when the waitimes are 0\nno_wait <- plot_data %>% filter(x==0) %>% select(colour, density, scaled)\n\n# Loop through each of the colours (which reflect the resource groups)\nfor (c in no_wait$colour) {\n # Filter the plot data to that resource group, then divide the densities by\n # the density from wait time 0\n d <- plot_data %>%\n filter(colour == c) %>%\n mutate(scaled2 = density / no_wait[no_wait$colour==c, \"density\"]) %>%\n ungroup() %>%\n select(scaled, scaled2)\n\n # Find the number of rows where these values match the scaled values\n n_match <- sum(apply(d, 1, function(x) length(unique(x)) == 1))\n n_total <- nrow(d)\n print(sprintf(\"%s out of %s results match\", n_match, n_total))\n}\n\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n\n\n\n\nFigure 2 (baseline only) with various different seeds\nThis imports the files too (as several files)\n\nplot_list <- list()\ni <- 0\nseeds <- c(0, 50, 100, 150, 450, 700, 750)\nfor (s in seeds) {\n i <- i + 1\n seed_path <- file.path(folder, paste(\n \"fig2_baseline_seed\", s, \".csv.gz\", sep=\"\"))\n seed_baseline <- import_results(seed_path, \"Baseline\")\n plot_list[[i]] <- create_plot(seed_baseline, group=\"resource\", title=s)\n}\n\n\nggarrange(plotlist=plot_list, common.legend=TRUE, legend=\"bottom\")\n\nWarning: Removed 4 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 4 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 4 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 4 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n\nWarning: Removed 4 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 4 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\nWarning: Removed 5 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 5 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\n\n\n\n\n\n\nggsave(path_fig2a_seeds, width=13, height=20)" + "text": "Figure 2\n\n# Create sub-plots\np1 <- create_plot(base_f2,\n group=\"resource\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\np2 <- create_plot(exc_f2,\n group=\"resource\",\n title=\"Exclusive-use\",\n xlab=\"Patient wait time (min)\",\n xlim=c(0, 250))\np3 <- create_plot(two_f2,\n group=\"resource\",\n title=\"Double angio INRs\")\n\n# Arrange in a single figure\nggarrange(p1, p2, p3, nrow=1,\n common.legend=TRUE, legend=\"bottom\",\n labels=c(\"A\", \"B\", \"C\"))\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n\n\n\n\n\n\n\nggsave(path_fig2, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT)\n\n\nDemonstrate that geom_density scaled is scaling against density of 0 wait time\n\n# Create figure as usual\np <- create_plot(base_f2,\n group=\"resource\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\n\n# Get data from the plot\nplot_data <- ggplot_build(p)$data[[1]]\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n# Create dataframe with the densities for when the waitimes are 0\nno_wait <- plot_data %>% filter(x==0) %>% select(colour, density, scaled)\n\n# Loop through each of the colours (which reflect the resource groups)\nfor (c in no_wait$colour) {\n # Filter the plot data to that resource group, then divide the densities by\n # the density from wait time 0\n d <- plot_data %>%\n filter(colour == c) %>%\n mutate(scaled2 = density / no_wait[no_wait$colour==c, \"density\"]) %>%\n ungroup() %>%\n select(scaled, scaled2)\n\n # Find the number of rows where these values match the scaled values\n n_match <- sum(apply(d, 1, function(x) length(unique(x)) == 1))\n n_total <- nrow(d)\n print(sprintf(\"%s out of %s results match\", n_match, n_total))\n}\n\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"\n[1] \"512 out of 512 results match\"" }, { "objectID": "reproduction/scripts/reproduction.html#figure-3", "href": "reproduction/scripts/reproduction.html#figure-3", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "Figure 3", "text": "Figure 3\n\n# Create sub-plots\np1 <- create_plot(base_f3,\n group=\"shift\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\np2 <- create_plot(exc_f3,\n group=\"shift\",\n title=\"Exclusive-use\",\n xlab=\"Patient wait time (min)\",\n xlim=c(0, 300),\n breaks_width=100)\np3 <- create_plot(two_f3,\n group=\"shift\",\n title=\"Double angio INRs\",\n xlim=c(0, 250))\n\n# Arrange in a single figure\nggarrange(p1, p2, p3, nrow=1,\n common.legend=TRUE, legend=\"bottom\",\n labels=c(\"A\", \"B\", \"C\"))\n\nWarning: Removed 5 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 5 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 5 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 5 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n\nWarning: Removed 2 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 2 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\n\n\n\n\n\n\nggsave(path_fig3, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT)" }, { "objectID": "reproduction/scripts/reproduction.html#figure-4", "href": "reproduction/scripts/reproduction.html#figure-4", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "Figure 4", "text": "Figure 4\n\n# Get the relevant results from in-text results 1, 2 and 3\n# Then calculate difference from baseline\nfig4 <- dplyr::bind_rows(txt2 %>% select(scenario, mean),\n txt3 %>%\n filter(scenario==\"Exclusive use\", shift==\"6pm\") %>%\n mutate(scenario=\"Exclusive use (+1h)\") %>%\n select(scenario, mean)) %>%\n mutate(diff = mean - mean[1]) %>%\n filter(scenario!=\"Baseline\") %>%\n mutate(dis_free_gain = abs(diff)*4.2)\n\n# Set order of the bars, and give full labels\nfig4_col <- c(\"Exclusive use\", \"Two AngioINRs\", \"Exclusive use (+1h)\")\nfig4_col_l <- c(\"Exclusive-use\", \"Two angio INRs\", \"Exclusive-use and +1hr work\")\nfig4$scenario <- factor(fig4$scenario, levels=fig4_col)\nfig4$scenario_lab <- plyr::mapvalues(fig4$scenario, from=fig4_col, to=fig4_col_l)\n\nggplot(fig4, aes(x=scenario_lab, y=dis_free_gain)) +\n geom_bar(stat=\"identity\") +\n ylim(0, 32) +\n xlab(\"Scenarios\") +\n ylab(\"Mean disability-free life added (days)\")\n\n\n\n\n\n\n\nggsave(path_fig4, width=5, height=3)" }, - { - "objectID": "reproduction/scripts/reproduction.html#figure-5", - "href": "reproduction/scripts/reproduction.html#figure-5", - "title": "Reproduction", - "section": "Figure 5", - "text": "Figure 5\nCurrently depends on simmer.plot() function that doesn’t work on the imported results from the csv file, so need to allow to run model to produce this plot.\n\nif (isTRUE(run)) {\n baseline_f5 <- run_model(seed = SEED, fig5=TRUE)\n exclusive_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE)\n twoangio_f5 <- run_model(angio_inr = 2, angio_ir=0, seed = SEED, fig5=TRUE)\n \n # Replace resource (which has been filtered to angioINR) with scenario\n baseline_f5$resource <- \"Baseline\"\n exclusive_f5$resource <-\"Exclusive-use\"\n twoangio_f5$resource <- \"Two angio INRs\"\n \n # Combine into single object\n fig5_df <- dplyr::bind_rows(baseline_f5, exclusive_f5, twoangio_f5)\n \n # Create figure using simmer's plot\n p <- plot(fig5_df, metric=\"utilization\") +\n xlab(\"Scenarios\") +\n ylab(\"Utilisation\") +\n scale_y_continuous(labels = scales::percent, limits=c(0, 0.4)) +\n ggtitle(\"\") +\n geom_text(aes(label=round(.data$Q50*100)), vjust=-1)\n p\n \n # Save to provided path\n ggsave(path_fig5, width=5, height=2.5)\n}" - }, - { - "objectID": "reproduction/scripts/reproduction.html#supplementary-figure", - "href": "reproduction/scripts/reproduction.html#supplementary-figure", - "title": "Reproduction", - "section": "Supplementary figure", - "text": "Supplementary figure\n\n# Create sub-plots\np1 <- create_plot(base_f2,\n group=\"resource\",\n title=\"Baseline\",\n ylab=\"Standardised density of patient in queue\")\np2 <- create_plot(base_sup_double,\n group=\"resource\",\n title=\"Doubling ECR patients\",\n xlab=\"Patient wait time (min)\",\n xlim=c(0, 300),\n breaks_width=100)\np3 <- create_plot(base_sup_triple,\n group=\"resource\",\n title=\"Tripling ECR patients\",\n xlim=c(0, 300))\n\n# Arrange in a single figure\nggarrange(p1, p2, p3, nrow=1,\n common.legend=TRUE, legend=\"bottom\",\n labels=c(\"A\", \"B\", \"C\"))\n\nWarning: Removed 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\nRemoved 1 row containing non-finite outside the scale range (`stat_density()`).\n\n\nWarning: Removed 4 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 4 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\nWarning: Removed 3 rows containing non-finite outside the scale range\n(`stat_density()`).\nRemoved 3 rows containing non-finite outside the scale range\n(`stat_density()`).\n\n\n\n\n\n\n\n\nggsave(path_supfig, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT)" - }, { "objectID": "reproduction/scripts/reproduction.html#time-elapsed", "href": "reproduction/scripts/reproduction.html#time-elapsed", - "title": "Reproduction", + "title": "Reproduce Figures 2-4 and in-text results 1-3", "section": "Time elapsed", "text": "Time elapsed\n\nif (isTRUE(run)) {\n end.time <- Sys.time()\n elapsed.time <- round((end.time - start.time), 3)\n elapsed.time\n}" }, @@ -963,7 +1026,7 @@ "href": "logbook/posts/2024_07_14/index.html#untimed-research-compendium", "title": "Day 10", "section": "Untimed: Research compendium", - "text": "Untimed: Research compendium\n\nTried adding parallel processing in model.R to speed it up\n\nAdd future.apply to the environment\nplan(multisession, workers=max(availableCores()-5, 1))\nfuture_lapply()\nHowever, it took longer than usual! So I removed it\n\nReorganising\n\nMoved scripts into a scripts/ folder\nMoved help functions from reproduction.Rmd into seperate R script (primarily so can reuse in tests more easily)\n\nSet ggsave() image width as realised it otherwise varied with window size when running" + "text": "Untimed: Research compendium\n\nTried adding parallel processing in model.R to speed it up\n\nAdd future.apply to the environment\nplan(multisession, workers=max(availableCores()-5, 1))\nfuture_lapply()\nHowever, it took longer than usual! So I removed it\n\nReorganising\n\nMoved scripts into a scripts/ folder\nMoved help functions from reproduction.Rmd into seperate R script (primarily so can reuse in tests more easily)\n\nSet ggsave() image width as realised it otherwise varied with window size when running\n\nCreate tests to check model results are consistent\n\nStarted with creating a basic test saving tempfile csv and loading it to compare to another dataframe\nThen made a test with two example models being run for 3 replications and comparing results\nThen, set up with two files, as testthat can run files in parallel, and configured parallel processing. This involved:\n\nAdding Config/testthat/parallel: true to DESCRIPTION\nCreate project-specific environment file with nano reproduction/.Renviron and setting TESTTHAT_CPUS=4\n\nRan testthat::test_dir(\"tests\"), although seemed to just run sequentially. Confirmed by checking testthat::isparallel() which returned FALSE.\nTried adding Config/testthat/start-first: shifts, model to DESCRIPTION and it ignored the order, so it appears the issue is it is not using info from the DESCRIPTION file\nChecked version and it is correct for running in parallel (testthat>=3.0.0)\nTried instead running testthat::test_local(), and moving tests into a folder testthat/, and this returned an error Could not find a root 'DESCRIPTION' file that starts with '^Package' in /home/amy/Documents/stars/stars-reproduce-huang-2019/reproduction.\nChanged DESCRIPTION to add Package and re-run - but this had error that installation of renv failed. Same error occurs if run testthat::test_dir(). It says to Try removing ‘/home/amy/.cache/R/renv/library/reproduction-0912b448/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu/00LOCK-renv’. I deleted this file (navigated there than rm -r 00LOCK-renv) then re-ran. However, this kept getting the same error message with that same file being created.\nTried removing Package from DESCRIPTION and running testthat::test_dir(\"tests/testthat\", load_package=\"none\") - but that ignores the order in DESCRIPTION\nTried testthat::test_dir(\"tests/testthat\", load_package=\"source\") which had error that Field 'Version' not found. Once I had this and re-ran, it ran the tests in the specified order! From Config/testthat/start-first: shifts, model\nI then add in Config/testthat/parallel: true and Config/testthat/edition: 3 but it had the same renv error as before\nThen decided to just run without parallel for now, so removed those lines from DESCRIPTION, deleted the .Renviron file, and put tests in a single file\n\nPackage: huang2019\nVersion: 0.1\nConfig/testthat/start-first: shifts, model\nConfig/testthat/parallel: true\nConfig/testthat/edition: 3\n\nCreated function to simplify testing, then wrote tests fora selection of scenarios (not all scenarios, to minimise run time).\nTest was failing with error of Length mismatch: comparison on first 2 components. I tried changing from expect_equal to using all.equal() and then expect_true(is_true()) on result. But this returned the same error!\nI tried running everything manually in the console so I could inspect the dataframes myself.\n\nfile = \"tests/testthat/expected_results/fig2_baseline.csv.gz\"\nexp <- as.data.frame(data.table::fread(file))\ninputs=list(seed=200)\nresult <- do.call(run_model, inputs)\n\nI realised the issue was that the expected result included a column shift where value throughout was 5pm. This was likely due to changing it at some point but not having re-run the whole script since, so I did that (and timed it!). I removed some of the model variants that aren’t to produce results from the paper (E.g. varying seeds)\n\nIt takes a while to run and, midway through, the R session encountered a fatal error and aborted. Tried again, and it failed again on exclusive_f5 <- run_model(exclusive_use = TRUE, seed = SEED, fig5=TRUE).\nI’m suspecting this might be due to the size of the dataframes produced? So tried removing them from the environment after saving and ran again - but it still crashed, this time on the next run_model() statement\nI considered trying again with parallelisation but, given I hadn’t had much luck with that before, and given that the issue here is with R crashing (and so parallelisation actually may not help), I decided to instead split up reproduction.rmd into a few smaller files.\n\n\nDocker\n\nUsed the RStudio documentation and this tutorial to write a Dockerfile." }, { "objectID": "original_study/desECR/figure_description.html", diff --git a/sitemap.xml b/sitemap.xml index 32c2323..442da88 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -44,6 +44,10 @@ https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/evaluation/artefacts.html 2024-07-12T10:15:58.709Z + + https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/reproduction/scripts/reproduction_fig5.html + 2024-07-16T14:56:22.223Z + https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/quarto_site/study_publication.html 2024-07-04T14:45:18.063Z @@ -64,9 +68,13 @@ https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/quarto_site/license.html 2024-07-03T11:37:23.942Z + + https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/reproduction/scripts/reproduction_supp.html + 2024-07-16T17:24:57.094Z + https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/reproduction/scripts/reproduction.html - 2024-07-16T08:41:53.076Z + 2024-07-16T17:24:52.594Z https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/evaluation/reporting.html @@ -102,7 +110,7 @@ https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/logbook/posts/2024_07_14/index.html - 2024-07-16T08:19:12.554Z + 2024-07-16T14:20:28.264Z https://pythonhealthdatascience.github.io/stars-reproduce-huang-2019/original_study/desECR/figure_description.html