diff --git a/.Rbuildignore b/.Rbuildignore index e48569c1..d705a554 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,5 @@ ^\.github$ ^LICENSE\.md$ _\.new\.png$ +^doc$ +^Meta$ diff --git a/.Rprofile b/.Rprofile index 81b960f5..2e9dc1f0 100644 --- a/.Rprofile +++ b/.Rprofile @@ -1 +1,10 @@ source("renv/activate.R") + +options("repos" = c( + "BioCsoft" = "https://bioconductor.org/packages/3.16/bioc", + "BioCann" = "https://bioconductor.org/packages/3.16/data/annotation", + "BioCexp" = "https://bioconductor.org/packages/3.16/data/experiment", + "BioCworkflows" = "https://bioconductor.org/packages/3.16/workflows", + "BioCbooks" = "https://bioconductor.org/packages/3.16/books", + "CRAN" = "https://cloud.r-project.org" +)) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml deleted file mode 100644 index b32be559..00000000 --- a/.github/workflows/R-CMD-check.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: R-CMD-check - -jobs: - R-CMD-check: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check - - - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/check-standard.yaml b/.github/workflows/check-standard.yaml new file mode 100644 index 00000000..14159b77 --- /dev/null +++ b/.github/workflows/check-standard.yaml @@ -0,0 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 381410b2..f60d0479 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -14,7 +14,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: @@ -28,3 +28,5 @@ jobs: - name: Lint run: lintr::lint_package() shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.gitignore b/.gitignore index 4040a210..6d102f8c 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,6 @@ po/*~ # RStudio Connect folder rsconnect/ +inst/doc +/doc/ +/Meta/ diff --git a/.lintr b/.lintr index 61c39305..79f75a18 100644 --- a/.lintr +++ b/.lintr @@ -2,6 +2,7 @@ linters: linters_with_defaults( assignment_linter = NULL, object_name_linter = NULL, line_length_linter = line_length_linter(120), + return_linter = NULL, undesirable_operator_linter = undesirable_operator_linter( modify_defaults( default_undesirable_operators, diff --git a/.renvignore b/.renvignore new file mode 100644 index 00000000..2c9bd9f5 --- /dev/null +++ b/.renvignore @@ -0,0 +1,2 @@ +scripts/create_browser_data.R +inst/app/www/data/ diff --git a/DESCRIPTION b/DESCRIPTION index 12ae5bc8..936ce61e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,16 +9,19 @@ License: MIT + file LICENSE Depends: R (>= 4.0.0) Imports: + bsicons, bslib, data.table, dplyr, fs, ggiraph (>= 0.8.4), ggplot2, + ggtree, glue, htmltools, janitor, magrittr, + markdown, purrr, reactable, readr, @@ -29,11 +32,15 @@ Imports: stringr, tibble Suggests: - ggtree, + knitr, + rmarkdown, shinytest2, testthat, usethis Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 +Remotes: + YuLab-SMU/ggtree@daf3371 +VignetteBuilder: knitr diff --git a/R/app_server.R b/R/app_server.R index 4fbbee71..05e91e31 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -19,10 +19,11 @@ app_server = function(input, output, session) { shiny::observe({ mutation_set = available_mutations(data_dir = data_dir) - shiny::updateSelectInput( + shiny::updateSelectizeInput( session = session, inputId = "mutationChoice", - choices = mutation_set + choices = mutation_set, + server = TRUE ) }) @@ -36,77 +37,54 @@ app_server = function(input, output, session) { # create ggiraph output from saved ggplot2 outputs output$treeview = ggiraph::renderGirafe({ shiny::req(input$widgetChoice) - # define tooltip - tooltip_css = paste0( - "background-color:black;", - "color:grey;", - "padding:14px;", - "border-radius:8px;", - "font-family:\"Courier New\",monospace;" - ) - # set options - if (input$widgetChoice == "tree-mutations.rds") { - girafe_options = list( - ggiraph::opts_selection(css = "fill:red;"), - ggiraph::opts_selection_inv(css = "fill:grey;"), - ggiraph::opts_sizing(rescale = FALSE), - ggiraph::opts_zoom(max = 5), - ggiraph::opts_tooltip( - css = tooltip_css, - use_fill = FALSE - ) - ) + + # set the relative height/width of the ggiraph-based graphs + is_dendrogram = grepl("^tree-", x = input$widgetChoice) + width = shinybrowser::get_width() / 72 + height = if (is_dendrogram) { + (1800 - 40) / 72 } else { - girafe_options = list( - ggiraph::opts_selection(type = "single"), - ggiraph::opts_sizing(rescale = FALSE), - ggiraph::opts_zoom(max = 5), - ggiraph::opts_tooltip( - css = tooltip_css, - use_fill = FALSE - ) - ) + (600 - 40) / 72 } - # set size - w = shinybrowser::get_width() / 72 - h = (1800 - 40) / 72 - # make tree - suppressWarnings( - ggiraph::girafe( - ggobj = imported_ggtree(), - width_svg = w, - height_svg = h, - options = girafe_options - ) + + create_girafe( + ggobj = imported_ggtree(), + widget_choice = input$widgetChoice, + width_svg = width, + height_svg = height, + suppress_warnings = TRUE ) }) %>% shiny::bindCache(input$widgetChoice) - -# Mutation colouring ------------------------------------------------------ + # Mutation colouring ------------------------------------------------------ # disable dropdown unless mutation treeview shiny::observe({ choice = ifelse(input$widgetChoice != "", input$widgetChoice, "") # toggle mutation dropdown - shinyjs::toggleElement(id = "mutationChoice", - condition = choice == "tree-mutations.rds") + shinyjs::toggleElement( + id = "mutationChoice", + condition = choice == "tree-mutations.rds" + ) # toggle sequence dropdown - shinyjs::toggleElement(id = "sequenceChoice", - condition = choice == "tree-sequences.rds") + shinyjs::toggleElement( + id = "sequenceChoice", + condition = choice == "tree-sequences.rds" + ) # select input for sequences if (choice == "tree-sequences.rds") { - avail_seqs = data.table::as.data.table(available_sequences(data_dir)) - names(avail_seqs) = "Sequences" - shiny::updateSelectInput(inputId = "sequenceChoice", - choices = avail_seqs - ) + avail_seqs = available_sequences(data_dir) + shiny::updateSelectizeInput( + inputId = "sequenceChoice", + choices = avail_seqs, + server = TRUE + ) } }) # get selected nodes from mutation choice shiny::observeEvent(input$mutationChoice, { - nodeChoice = selected_mut_nodes(input$mutationChoice, data_dir) # the 'node' column contains integers that define the IDs for graph-nodes in the htmlwidget @@ -124,11 +102,10 @@ app_server = function(input, output, session) { ) }) -# Sequence colouring ------------------------------------------------------ + # Sequence colouring ------------------------------------------------------ # get selected nodes from sequence choice shiny::observeEvent(input$sequenceChoice, { - nodeChoice = selected_seq_nodes(input$sequenceChoice, data_dir) # the 'node' column contains integers that define the IDs for graph-nodes in the htmlwidget @@ -146,15 +123,17 @@ app_server = function(input, output, session) { ) }) -# Get click --------------------------------------------------------------- + # Get click --------------------------------------------------------------- # get selected cluster id based on widget choice selected_cluster_id = shiny::reactive({ shiny::req(input$widgetChoice) shiny::req(input$treeview_selected) - get_selected_cluster_id(widgetChoice = input$widgetChoice, - treeviewSelected = utils::tail(input$treeview_selected, 1), - data_dir = data_dir) + get_selected_cluster_id( + widgetChoice = input$widgetChoice, + treeviewSelected = utils::tail(input$treeview_selected, 1), + data_dir = data_dir + ) }) %>% shiny::bindCache(input$widgetChoice, input$treeview_selected) @@ -169,9 +148,10 @@ app_server = function(input, output, session) { shiny::req(input$widgetChoice) fname = stringr::str_replace(input$widgetChoice, ".rds", ".md") shiny::includeMarkdown(system.file("app", "www", "content", "treeview", - fname, - package = "tfpbrowser", - mustWork = TRUE)) + fname, + package = "tfpbrowser", + mustWork = TRUE + )) }) # Tables Tab -------------------------------------------------------------- @@ -194,5 +174,4 @@ app_server = function(input, output, session) { cluster_choice = selected_cluster_id, data_dir = data_dir ) - } # end server function diff --git a/R/app_ui.R b/R/app_ui.R index a9451f22..988003d7 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -3,103 +3,81 @@ #' @param request Internal parameter for `{shiny}`. #' @noRd app_ui = function(request) { - data_dir <- get_data_dir() + data_dir = get_data_dir() shiny::tagList( - shinyjs::useShinyjs(), shinybrowser::detect(), - shiny::navbarPage( # title title = place_title_logo(), - header = add_ext_resources(data_dir), # theme - theme = bslib::bs_theme(version = 4, - bootswatch = "minty", - bg = "#EBEEEE", - fg = "#002147", - primary = "#003E74", - secondary = "#9D9D9D"), + theme = bslib::bs_theme( + version = 5, + bootswatch = "minty", + bg = "#EBEEEE", + fg = "#002147", + primary = "#003E74", + secondary = "#9D9D9D" + ), # Input widgets shiny::tabPanel( title = "Data", - shiny::fluidRow( - shiny::column(12, - # use details and summary to create expandable section - htmltools::tags$details( - # preview of expandable section - htmltools::tags$summary("Cluster statistics (click to expand)"), - - shiny::br(), - - # text to print choice - shiny::textOutput("select_text"), - shiny::br(), - - # output options - shiny::tabsetPanel(id = "plot_tabs", - - # Tables tab - tablesUI("table1"), - - # Plots tab - plotsUI("plot1"), - - # RDS tab - rdsUI("rds1") - - ) - ) - ) + shiny::column(12, clusterStatsUI(id = NULL)) ), # end fluid row # Bottom row - show tree (static html output from tfpscanner) shiny::fluidRow( shiny::column(12, - id="view-container", - shiny::div(id="view-selection", - htmltools::tags$details( - id="sidebar-toggle", - open="open", - `aria-role`="button", - `aria-label`="Toggle sidebar visibility", - htmltools::tags$summary( - shiny::span(">>"), - shiny::span("<<") - ) - ), - # choose type of treeview - shiny::selectInput(inputId = "widgetChoice", - label = "View", - choices = c("None" = ""), - selectize = FALSE), - - # choose type of mutation - shiny::selectInput(inputId = "mutationChoice", - label = "Mutation", - choices = character(0), - selectize = FALSE), - - # choose type of sequence - shiny::selectInput(inputId = "sequenceChoice", - label = "Sequence", - choices = NULL, - selectize = FALSE), + id = "view-container", + shiny::div( + id = "view-selection", + htmltools::tags$details( + id = "sidebar-toggle", + open = "open", + `aria-role` = "button", + `aria-label` = "Toggle sidebar visibility", + htmltools::tags$summary( + shiny::span(">>"), + shiny::span("<<") + ) + ), + # choose type of treeview + shiny::selectInput( + inputId = "widgetChoice", + label = "View", + choices = c("None" = ""), + selectize = FALSE + ), + + # choose type of mutation + shiny::selectizeInput( + inputId = "mutationChoice", + label = "Mutation", + choices = character(0) + ), + + # choose type of sequence + shiny::selectizeInput( + inputId = "sequenceChoice", + label = "Sequence", + choices = character(0) + ), ), - shiny::div(id="view-graphic", - # markdown files to add description - shiny::uiOutput("tree_md_files"), - - # show treeview widget - shiny::wellPanel( - ggiraph::girafeOutput("treeview"), - style = "background: white; height: 1800px;", - ), - shiny::br() + shiny::div( + id = "view-graphic", + # markdown files to add description + shiny::uiOutput("tree_md_files"), + + # show treeview widget + shiny::wellPanel( + ggiraph::girafeOutput("treeview"), + style = "background: white; height: 1800px;", + ), + shiny::br() ) ) ) # end fluid row @@ -108,12 +86,10 @@ app_ui = function(request) { # about page shiny::tabPanel( title = "About", - shiny::includeMarkdown(system.file("app", "www", "content", "about.md", - package = "tfpbrowser", - mustWork = TRUE)) + shiny::includeMarkdown( + system.file("app", "www", "content", "about.md", package = "tfpbrowser", mustWork = TRUE) + ) ) - ) # end navbar page ) # end tag list - } diff --git a/R/config.R b/R/config.R index 35980394..c9045131 100644 --- a/R/config.R +++ b/R/config.R @@ -7,9 +7,11 @@ #' #' @return Scalar string. The data-directory for use in the app. -get_data_dir <- function() { - Sys.getenv( +get_data_dir = function() { + path = Sys.getenv( "APP_DATA_DIR", system.file("app", "www", "data", package = "tfpbrowser") ) + + normalizePath(path) } diff --git a/R/ggiraph.R b/R/ggiraph.R new file mode 100644 index 00000000..0b49ced8 --- /dev/null +++ b/R/ggiraph.R @@ -0,0 +1,61 @@ +#' Convert a ggplot object into an interactive {ggiraph} object +#' +#' @param ggobj The ggplot2/ggtree object. +#' @param widget_choice Scalar character. Describes the type of plot that is contained in +#' `ggobj`. Typically a file basename that includes the file extension, of the form "tree-XXX.rds" +#' (for `{ggtree}` objects) or "sina-XXX.rds" (for `{ggplot2}` scatter plots). +#' @param width_svg,height_svg Scalar numeric. The width/height of the output plot. +#' @param suppress_warnings Scalar logical. Should warnings from `ggiraph::girafe()` be printed +#' to the console? +create_girafe = function( + ggobj, + widget_choice, + width_svg, + height_svg, + suppress_warnings = FALSE) { + # define tooltip + tooltip_css = paste0( + "background-color:black;", + "color:grey;", + "padding:14px;", + "border-radius:8px;", + "font-family:\"Courier New\",monospace;" + ) + + # set options + common_options = list( + ggiraph::opts_sizing(rescale = FALSE), + ggiraph::opts_zoom(max = 5), + ggiraph::opts_tooltip( + css = tooltip_css, + use_fill = FALSE + ) + ) + + plot_specific_options = if (widget_choice == "tree-mutations.rds") { + list( + ggiraph::opts_selection(css = "fill:red;"), + ggiraph::opts_selection_inv(css = "fill:grey;") + ) + } else { + list(ggiraph::opts_selection(type = "single")) + } + + girafe_options = c(plot_specific_options, common_options) + + create_widget = function() { + ggiraph::girafe( + ggobj = ggobj, + width_svg = width_svg, + height_svg = height_svg, + options = girafe_options + ) + } + + # make tree + if (suppress_warnings) { + suppressWarnings(create_widget()) + } else { + create_widget() + } +} diff --git a/R/module_cluster_stats.R b/R/module_cluster_stats.R new file mode 100644 index 00000000..7a480919 --- /dev/null +++ b/R/module_cluster_stats.R @@ -0,0 +1,42 @@ +clusterStatsUI = function(id) { + ns = shiny::NS(id) + + box_content = shiny::tagList( + shiny::br(), + + # text to print choice + shiny::textOutput(ns("select_text")), + shiny::br(), + + # output options + shiny::tabsetPanel( + id = ns("plot_tabs"), + + # Tabs for "Tables", "Plots" and "RDS" + tablesUI(ns("table1")), + plotsUI(ns("plot1")), + rdsUI(ns("rds1")) + ) + ) + + # Help icon for the cluster-statistics panel + # - Clicking this icon does not lead to the underlying accordion_panel being expanded + help_text = shiny::tags$p( + "The 'Cluster statistics' panel can be used to view or download data about a cluster.", + "First, select a cluster by clicking on a node in one of the tree-views or scatter plots." + ) + help_popover = bsicons::bs_icon("question-circle", size = "1.5em") %>% + bslib::popover(help_text) %>% + htmltools::tagAppendAttributes(`data-bs-toggle` = "collapse", `data-bs-target` = NA) + + # Expandable panel containing the cluster-statistics details + bslib::accordion( + id = "cluster_stats_accordion", + open = FALSE, + bslib::accordion_panel( + title = "Cluster statistics (click to expand)", + box_content, + icon = help_popover + ) + ) +} diff --git a/R/module_plots.R b/R/module_plots.R index 849feace..596332d0 100644 --- a/R/module_plots.R +++ b/R/module_plots.R @@ -6,11 +6,12 @@ plotsUI = function(id) { ns = shiny::NS(id) # Plots tab panel - downloader_tab_panel(title = "Plots", - chooser_id = ns("plot_type"), - download_button_id = ns("download_plot"), - panel = display_panel(shiny::uiOutput(ns("display_plot")))) - + downloader_tab_panel( + title = "Plots", + chooser_id = ns("plot_type"), + download_button_id = ns("download_plot"), + panel = display_panel(shiny::uiOutput(ns("display_plot"))) + ) } #' Plots tab Server @@ -35,17 +36,20 @@ plotsServer = function(id, cluster_choice, data_dir) { # drop down for plots shiny::observeEvent(all_files(), { - all_images = filter_by_filetype(filenames = all_files(), - filetypes = c("png", "PNG")) + all_images = filter_by_filetype( + filenames = all_files(), + filetypes = c("png", "PNG") + ) if (length(all_images) != 0) { shinyjs::enable("plot_type") } else { shinyjs::disable("plot_type") } shiny::updateSelectInput(session, - "plot_type", - label = "Select plot type:", - choices = all_images) + "plot_type", + label = "Select plot type:", + choices = all_images + ) }) # the path to the plot, from the server's perspective @@ -60,7 +64,7 @@ plotsServer = function(id, cluster_choice, data_dir) { plot_url = shiny::reactive({ shiny::req(plot_file()) - plot_subpath <- fs::path_rel(plot_file(), data_dir) + plot_subpath = fs::path_rel(plot_file(), data_dir) glue::glue("data/{plot_subpath}") }) @@ -101,7 +105,5 @@ plotsServer = function(id, cluster_choice, data_dir) { file.copy(plot_file(), file) } ) - }) - } diff --git a/R/module_rds.R b/R/module_rds.R index 438fd544..d2553dc8 100644 --- a/R/module_rds.R +++ b/R/module_rds.R @@ -5,10 +5,12 @@ rdsUI = function(id) { ns = shiny::NS(id) # RDS files tab panel - downloader_tab_panel(title = "RDS Files", - chooser_id = ns("rds_type"), - download_button_id = ns("download_rds"), - panel = display_panel(shiny::uiOutput(ns("display_rds")))) + downloader_tab_panel( + title = "RDS Files", + chooser_id = ns("rds_type"), + download_button_id = ns("download_rds"), + panel = display_panel(shiny::uiOutput(ns("display_rds"))) + ) } #' rds tab Server @@ -33,17 +35,20 @@ rdsServer = function(id, cluster_choice, data_dir) { # drop down for rds shiny::observeEvent(all_files(), { - all_rds = filter_by_filetype(filenames = all_files(), - filetypes = c("rds", "RDS")) + all_rds = filter_by_filetype( + filenames = all_files(), + filetypes = c("rds", "RDS") + ) if (length(all_rds) != 0) { shinyjs::enable("rds_type") } else { shinyjs::disable("rds_type") } shiny::updateSelectInput(session, - "rds_type", - label = "Select RDS file:", - choices = all_rds) + "rds_type", + label = "Select RDS file:", + choices = all_rds + ) }) # get rds file @@ -95,7 +100,5 @@ rdsServer = function(id, cluster_choice, data_dir) { file.copy(rds_file(), file) } ) - }) - } diff --git a/R/module_tables.R b/R/module_tables.R index 063ef6f0..34b72ecb 100644 --- a/R/module_tables.R +++ b/R/module_tables.R @@ -6,10 +6,12 @@ tablesUI = function(id) { ns = shiny::NS(id) # Tables tab panel - downloader_tab_panel(title = "Tables", - chooser_id = ns("table_type"), - download_button_id = ns("download_table"), - panel = display_panel(reactable::reactableOutput(ns("display_table")))) + downloader_tab_panel( + title = "Tables", + chooser_id = ns("table_type"), + download_button_id = ns("download_table"), + panel = display_panel(reactable::reactableOutput(ns("display_table"))) + ) } #' Tables tab Server @@ -34,17 +36,20 @@ tablesServer = function(id, cluster_choice, data_dir) { # drop down for tables shiny::observeEvent(all_files(), { - all_tables = filter_by_filetype(filenames = all_files(), - filetypes = c("csv", "CSV")) + all_tables = filter_by_filetype( + filenames = all_files(), + filetypes = c("csv", "CSV") + ) if (length(all_tables) != 0) { shinyjs::enable("table_type") } else { shinyjs::disable("table_type") } shiny::updateSelectInput(session, - "table_type", - label = "Select table type:", - choices = all_tables) + "table_type", + label = "Select table type:", + choices = all_tables + ) }) # get table file path @@ -72,10 +77,11 @@ tablesServer = function(id, cluster_choice, data_dir) { table_to_display = suppressMessages(readr::read_csv(table_file())) table_to_display_nice = reformat_table(table_to_display) reactable::reactable(table_to_display_nice, - striped = TRUE, - defaultPageSize = 8, - wrap = FALSE, - height = 400) + striped = TRUE, + defaultPageSize = 8, + wrap = FALSE, + height = 400 + ) } else { shiny::p("No tables available.", style = "color: red; text-align: left") } @@ -99,6 +105,5 @@ tablesServer = function(id, cluster_choice, data_dir) { file.copy(table_file(), file) } ) - }) } diff --git a/R/place_title_logo.R b/R/place_title_logo.R index 34863103..b47946db 100644 --- a/R/place_title_logo.R +++ b/R/place_title_logo.R @@ -7,8 +7,10 @@ place_title_logo = function() { shiny::img( src = "www/logo.png", contentType = "image/png", - height = 80, width = 100), - "tpfbrowser") + height = 80, width = 100 + ), + "tfpbrowser" + ) return(title) } diff --git a/R/utils.R b/R/utils.R index a1e145b2..c0f6dd11 100644 --- a/R/utils.R +++ b/R/utils.R @@ -7,9 +7,13 @@ available_treeview = function(data_dir) { file.path(data_dir, "treeview"), pattern = "\\.rds$" ) - all_trees = factor(all_trees, - c(stringr::str_subset(all_trees, "tree"), - stringr::str_subset(all_trees, "sina"))) + all_trees = factor( + all_trees, + c( + stringr::str_subset(all_trees, "tree"), + stringr::str_subset(all_trees, "sina") + ) + ) all_trees = as.character(sort(all_trees)) names(all_trees) = all_trees %>% stringr::str_replace_all("_|-|\\.rds", " ") %>% @@ -73,8 +77,9 @@ get_unique_mutations = function(filename) { get_all_clusters = function(filename) { all_files = list.files(filename) has_no_dot = stringr::str_detect(all_files, - pattern = "\\.", - negate = TRUE) + pattern = "\\.", + negate = TRUE + ) all_clusters = all_files[which(has_no_dot)] return(all_clusters) } @@ -128,7 +133,9 @@ filter_by_filetype = function(filenames, filetypes) { file_names = stringr::str_to_title( stringr::str_replace_all( - gsub("\\..*", "", matching_files), "_", " ")) + gsub("\\..*", "", matching_files), "_", " " + ) + ) names(matching_files) = file_names return(matching_files) @@ -149,14 +156,16 @@ downloader_tab_panel = function(title, shiny::fluidRow( # drop down menu to select dataset shiny::column(3, - align = "center", - shiny::selectInput(chooser_id, - label = "Select type:", - choices = NULL, - selected = NULL), - shiny::br(), - shiny::downloadButton(download_button_id, - label = "Download") + align = "center", + shiny::selectInput(chooser_id, + label = "Select type:", + choices = NULL, + selected = NULL + ), + shiny::br(), + shiny::downloadButton(download_button_id, + label = "Download" + ) ), # display data shiny::column(9, align = "center", panel) @@ -188,7 +197,8 @@ get_selected_cluster_id = function(widgetChoice, filepath = file.path(data_dir, "treeview", "node_lookup", filename) # load look up ids = readr::read_csv(filepath, - col_types = list(readr::col_double(), readr::col_double())) + col_types = list(readr::col_double(), readr::col_double()) + ) selected_cluster = as.numeric(ids[which(ids$data_id == treeviewSelected), 2]) return(selected_cluster) } diff --git a/R/zzz.R b/R/zzz.R index ee0aab51..d198a6b3 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -7,7 +7,9 @@ .onload = function(...) { shiny::addResourcePath( "www", - system.file("www", package = "tfpbrowser", - mustWork = TRUE) + system.file("www", + package = "tfpbrowser", + mustWork = TRUE + ) ) } diff --git a/README.md b/README.md index 6d688f53..8baf7fc9 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,166 @@ # {tfpbrowser} -An R package to build a Shiny application to explore {tfpscanner} outputs. The outputs from {tfpscanner} should be stored in the `inst/app/www/data/` folder. +An R package to build a Shiny application to explore {tfpscanner} outputs. +The outputs from {tfpscanner} can be stored in the `inst/app/www/data/` folder and tfpbrowser will +present data in this directory by default. ## Installation +The recommended way to use this application, is to clone the associated `git` repository and work +within that directory. This can be achieved using `git` from the command line: + +```bash +# Using SSH +git clone git@github.com:mrc-ide/tfpbrowser.git +# Or using HTTPS +git clone https://github.com/mrc-ide/tfpbrowser.git ``` -remotes::install_github("mrc-ide/tfpbrowser") -``` + +Or from inside RStudio (`File -> New Project -> Version Control -> Git` then enter the repository +URL "https://github.com/mrc-ide/tfpbrowser.git"). + +To get the latest version of the code, use the `git pull` command (or the `Git -> Pull` workflow in +RStudio). + +Then open an R session in the directory for the git repository. A simple way to do this is to +open RStudio and use the `File -> Open Project` workflow, navigating to the `tfpbrowser.Rproj` file +in the `tfpbrowser` directory. ## Running the Shiny application +Before running the app, we must ensure that + +- the packages it depends upon are available; and +- a dataset for presentation is in place. + +Note that the bioconductor packages used by `tfpbrowser` are tied to a specific version of R. +As of 2024, you should use R v4.2.x. + +### Activating the environment for the application + +The specific versions of the packages used by the app (the package environment) are declared in an +`renv.lock` file. See the [{renv} documentation](https://rstudio.github.io/renv/) for further +details. `renv` isolates the environment for this app away from the R packages installed elsewhere +on your machine. + +The first time that you open the `tfpbrowser` project in an R session, activating the package +environment may fail. You will need to follow these steps: + +- Install `renv` (`install.packages("renv")`) +- Install the `tfpbrowser` package environment (`renv::restore()`) +- Restart the session (In RStudio `Session -> Restart R`) + +The package environment will be automatically loaded when the project is opened on subsequent +occasions. On successfully loading the environment, `renv` will print out the following comment: + +``` +- Project '~/path/to/tfpbrowser' loaded. [renv 1.0.7] +``` + +The packages defined in the `renv.lock` file may change over time. If you receive a message that +`The project is out-of-sync...` when you load the `tfpbrowser` project, it is likely that the +package environment in `renv.lock` has updated, but your local machine is using an older +environment. Run `renv::restore()` to sync your `tfpbrowser` environment with the current +`renv.lock` file. + +### Directing the app to a dataset + +`tfpbrowser` relies on data preprocessing by [`tfpscanner`](https://github.com/mrc-ide/tfpscanner). +See the section on "Creating a new `tfpbrowser` dataset" + +`tfpscanner` acts upon a directory of data (which must contain a `scanner_output` subdirectory) and +adds `treeview`, `sequences` and `mutations` directories to its input. Content in all four of these +subdirectories is needed for `tfpbrowser` to work. + +So, a dataset for `tfpbrowser` must be structured like this: + +``` +/path/to/my_data +├── mutations +├── scanner_output +├── sequences +└── treeview +``` + +There are two ways to make `tfpbrowser` use such a dataset: + +- Copy the `mutations`, `scanner_output`, `sequences` and `treeview` directories into the + `inst/app/www/data` directory of the `tfpbrowser` repository, then either reinstall `tfpbrowser` + or load the package temporarily in your current session (using + [`pkgload::load_all()`](https://search.r-project.org/CRAN/refmans/pkgload/html/load_all.html)) + +- Configure the app to read data from the dataset directory without moving its contents by setting + the `APP_DATA_DIR` variable to contain the path to that directory. See the section "Configuring + the deployed app". + +### Running + +The most robust way to run the application is to start an R session inside the repository that +houses the source code for {tfpbrowser}. This will ensure that the environment within which the app +runs is activated before the app is started (see section "Activating the environment for the +application"). + +Once the environment is activated, the app can be run using the following R commands: + +```r +# Load the contents of the {tfpbrowser} package +pkgload::load_all() + +# Optionally define the directory that contains the tfpscanner data for presentation +# - Alternative ways to define the data-path are described in "Configuring the app" +Sys.setenv(APP_DATA_DIR = "/path/to/data") + +# Run the app +run_app() +``` + +An alternative way to run the app is by using the `run_app()` function from the installed +{tfpbrowser} package. However, you may find that the tfpscanner data used is incompatible with +tfpbrowser. As such, we recommend generating tfpscanner output using the `create_browser_data.R` +script and running tfpbrowser within it's defined R environment, as described above. + ``` tfpbrowser::run_app() ``` -## Updating with new data +## Creating a new `tfpbrowser` dataset + +In the repository for {tfpbrowser} there is a script `./scripts/create_browser_data.R`. This can be +used to generate a dataset for presentation by {tfpbrowser}. The script contains detailed +instructions for its use. + +Briefly: + +- "create_browser_data.R" runs the `tfpscanner::create_browser_data()` function +- It takes scanner output, and creates a number of tree-views that can be presented in the + {tfpbrowser} app +- Input: + - The user should modify `create_browser_data.R` to point the script to a directory + containing {tfpscanner} input (`/path/to/tfpscanner_input/`) + - That directory contains a `scanner_output/` subdirectory + (`/path/to/tfpscanner_input/scanner_output/`) + - That subdirectory contains a file containing an R environment object + `scanner-env-YYYY-MM-DD.rds` +- Output: + - `create_browser_data.R` appends some files to the `/path/to/tfpscanner_input/` directory + - After running the script, that directory will contain subdirectories `mutations`, + `scanner_output`, `sequences` and `treeview` + +`create_browser_data.R` _must_ run from the repository for {tfpbrowser} because it uses a similar +mechanism to the {tfpbrowser} app to define the versions of R packages used when it runs. This is +important because the 'treeview' outputs that are generated are binary R objects that the +{tfpbrowser} app will import. The R packages used to generate those objects must match those used +when importing them. By running from the {tfpbrowser} directory we can use the environment +definition for the {tfpbrowser} app to precisely specify the packages needed when {tfpscanner} runs. + +Once the data has been appended by `create_browser_data.R`, it can be used by the {tfpbrowser} app. +To do this either: -* See the notes on using `tfpscanner::create_browser_data()` with tfpbrowser in the README for - {tfpscanner} -* Either: - configure {tfpbrowser} to use the output data directory used in `create_browser_data()` (see the next section); or - copy the contents of that directory into `inst/app/www/data/` and re-install {tfpbrowser} -## Configuring the deployed app +### Configuring the app Data presented by the app can be obtained from an arbitrary directory on the server. To configure the data-directory, use the environment variable `APP_DATA_DIR`. @@ -45,3 +182,61 @@ run_app() An alternative way to specify this data directory is to add the line `APP_DATA_DIR="/home/me/tfpdata/"` to a `.Renviron` file in the project root. + +## Deploying the app + +Please see the vignette `deploy` in {tfpbrowser} which provides a walk-through for deploying to +[shinyapps.io](https://www.shinyapps.io/). This is in `./vignettes/deploy.Rmd` in the {tfpbrowser} +repository. + +If working in the tfpbrowser repository, developers may need to build the vignettes: + +```r +# Build the vignette (Optional, if you haven't installed tfpbrowser) +# In the repository for {tfpbrowser} +devtools::build_vignettes() +pkgload::load_all() + +# View the vignette +vignette("deploy", package = "tfpbrowser") +``` + +## Customising formatting and content + +### Treeviews + +The treeviews presented in this app are created by the `create_browser_data()` function in +{tfpscanner}. We recommend using the `scripts/create_browser_data.R` script in {tfpbrowser} +(described above) to run that function. + +`tfpscanner::create_browser_data()` respects all of the formatting arguments respects all of the +formatting arguments for `tfpscanner::treeview()`. See the documentation for +`tfpscanner::treeview()` for up-to-date details of the formatting options. The main options are + +- `dendrogram_colours` - A vector of colour-strings, this controls the branch-colour for the + dendrogram, and ranges (by default) from dark blue to dark red via an intermediate light-grey. +- `heatmap_width` - The width of the heatmap that is presented next to the dendrogram. This is + passed as the `width` argument to `ggtree::gheatmap()`. +- `heatmap_offset` - The distance between the dendrogram and the heatmap. This is passed as the + `offset` argument to `ggtree::gheatmap()`. +- `heatmap_lab_offset` - The offset distance for the genotype labels in the heatmap columns. This is + passed as the `colnames_offset_y` argument to `ggtree::gheatmap()`. +- `heatmap_fill` - A named vector of colours used to indicate the presence and absence of a genotype + in the heatmap. Defaults are FALSE: light-grey (for absence of the genotype), TRUE: dark-grey (for + presence of the genotype). Passed to `ggplot2::scale_fill_manual()` + +Custom values for these arguments can be set by manually editing the `treeview_args` list in +`./scripts/create_browser_data.R` (tfpbrowser), or directly, as arguments to the function +`tfpscanner::create_browser_data()`. + +### Pop-ups + +When a user hovers their mouse over a node in a treeview, a pop-up displaying statistics about that +node is displayed. To modify the information presented in this popup requires modifications to the +source code of {tfpscanner}. See the `tfpscanner::append_interactivity_data()` function. + +### 'About' text + +The text that is presented in the "About" panel of the app can be modified by updating the file +`./inst/app/www/content/about.md` in {tfpbrowser}. This is a markdown document that gets rendered +in HTML by the tfpbrowser application. diff --git a/app.R b/app.R new file mode 100644 index 00000000..839357de --- /dev/null +++ b/app.R @@ -0,0 +1,3 @@ +pkgload::load_all(helpers = FALSE, export_all = FALSE, attach_testthat = FALSE) + +run_app() diff --git a/inst/app/www/content/about.md b/inst/app/www/content/about.md index bf3bbf41..731e728f 100644 --- a/inst/app/www/content/about.md +++ b/inst/app/www/content/about.md @@ -1 +1,97 @@ -This is a page containing some information about the project. +# tfpbrowser + +## About + +The Transmission Fitness Polymorphism Browser (tfpbrowser) is a visualisation tool for output from +the Transmission Fitness Polymorphism Scanner (tfpscanner)[1-3]. Information on the visualisation +options can be found below, while details regarding installation of the tfpbrowser package and the +source code can be found at +[https://github.com/mrc-ide/tfpbrowser](https://github.com/mrc-ide/tfpbrowser). + +Six different visualisations can be accessed by selecting from the ‘View’ dropdown menu on the +left-hand side. If the ‘View’ option is not visible, then the left-hand side menu may need to be +expanded by clicking on the double arrow button. + +### Tree Visualisations + +There are four different tree visualisation options. These are described below, but a number of +characteristics are common to each tree visualisation: + +- The size of the circles (for internal nodes) and triangles (tips) indicates the size of the +cluster that they represent. +- The colour indicates a particular characteristic of the cluster. +- On the right-hand side of each tree visualisation, the colouring of the bars indicates whether a +genotype (for which a key mutation is labelled) is present (true) or absent (false) in the clusters +at the same vertical level. +- Further information on each cluster can be viewed by hovering over it with the mouse cursor. + +The four tree visualisation options in the ‘View’ menu are: + +#### Tree Clock Outlier + +Displays a phylogenetic tree with clusters colour coded (key at the top) according to the value of +the molecular clock outlier (MCO) statistic. This is computed by the tfpscanner as a measure of the +degree to which evolutionary rates differed in the lineage leading to a phylogenetic cluster. +Root-to-tip regression is used to predict the divergence of tips in a cluster and contrasts this +with divergence within an ancestral clade including the given cluster. This predicted divergence is +then compared to the true divergence of the cluster. + +#### Tree Logistic Growth Rate + +Displays a phylogenetic tree with clusters colour coded (key at the top) according to the value of +the logistic growth rate. This is computed in the tfpscanner using one of two different methods +depending on the level of model support calculated using the Akaike Information Criterion (AIC) and +‘relative likelihood’. The first method uses a generalised linear model (GLM) to calculate the log +odds of a sample being from a cluster of interest compared to a geographically and temporally +matched sample weighted by prevalence, and multiplied by the estimated mean generation time to +calculate the relative LGR per generation for each cluster of interest. The second method uses a +generalised additive model (GAM) combined with a Gaussian process model to identify changes in +growth rates over time. + +#### Tree Mutations + +This visualisation has a ‘Mutation’ menu from which to select a particular mutation to be +highlighted in the phylogenetic tree. Clusters containing the mutation selected will be coloured red +in the phylogenetic tree while clusters not containing this mutation will be grey. + +#### Tree Sequences + +This visualisation has a ‘Sequence’ menu from which to select a particular sequence ID. Clusters +containing this sequence will be coloured red in the phylogenetic tree while those not containing it +will be grey. + +### Scatter plots + +The molecular clock outlier and logistic growth rate statistics can also be viewed in scatter plots: + +#### Sina Clock Outlier + +Displays a scatter plot of the molecular clock outlier statistic value for each phylogenetic cluster +on the y-axis and the lineage and/or mutation is stratified along the x-axis. The plot marker +colours indicate the lineage and/or mutation and the size indicates the cluster size, both as per +the legend on the right-hand side of the plot. _See ‘Tree Clock Outlier’ above for details of the +molecular clock outlier statistic_. + +#### Sina Logistic Growth Rate + +Displays a scatter plot of the logistic growth rate value for each phylogenetic cluster on the +y-axis and the lineage and/or mutation is stratified along the x-axis. The circle colours indicate +the lineage and/or mutation and the size indicates the cluster size, both as per the legend on the +right-hand side of the plot. _See ‘Tree Logistic Growth Rate’ above for details of this statistic_. + +### Downloads + +Tables, plots and .rds files can also be downloaded by clicking on the ‘Cluster statistics’ tab and +selecting the relevant option. + +### References + +[1] Volz EM, Boyd O. Transmission Fitness Polymorphism Scanner. Available from: +https://github.com/mrc-ide/tfpscanner + +[2] Volz EM. Fitness, growth and transmissibility of SARS-CoV-2 genetic variants. Nat Rev Genet +2023. https://doi.org/10.1038/s41576-023-00610-z + +[3] Drake KO, Boyd O, Franceschi VB, Colquhoun RM, Ellaby NAF, Volz EM. Phylogenomic early warning +signals for SARS-CoV-2 epidemic waves. eBioMedicine 2024: 100. +https://doi.org/10.1016/j.ebiom.2023.104939 diff --git a/inst/app/www/tfpbrowser-style.css b/inst/app/www/tfpbrowser-style.css index c81da6ea..b9a1188a 100644 --- a/inst/app/www/tfpbrowser-style.css +++ b/inst/app/www/tfpbrowser-style.css @@ -1,9 +1,8 @@ -summary { - background: #d6d6d6; +.accordion-item { padding: 1em; } -details { +.accordion { margin-bottom: 2rem; } diff --git a/man/create_girafe.Rd b/man/create_girafe.Rd new file mode 100644 index 00000000..3776c919 --- /dev/null +++ b/man/create_girafe.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ggiraph.R +\name{create_girafe} +\alias{create_girafe} +\title{Convert a ggplot object into an interactive {ggiraph} object} +\usage{ +create_girafe( + ggobj, + widget_choice, + width_svg, + height_svg, + suppress_warnings = FALSE +) +} +\arguments{ +\item{ggobj}{The ggplot2/ggtree object.} + +\item{widget_choice}{Scalar character. Describes the type of plot that is contained in +\code{ggobj}. Typically a file basename that includes the file extension, of the form "tree-XXX.rds" +(for \code{{ggtree}} objects) or "sina-XXX.rds" (for \code{{ggplot2}} scatter plots).} + +\item{width_svg, height_svg}{Scalar numeric. The width/height of the output plot.} + +\item{suppress_warnings}{Scalar logical. Should warnings from \code{ggiraph::girafe()} be printed +to the console?} +} +\description{ +Convert a ggplot object into an interactive {ggiraph} object +} diff --git a/man/tfpbrowser.Rd b/man/tfpbrowser.Rd index 77e39828..ba256449 100644 --- a/man/tfpbrowser.Rd +++ b/man/tfpbrowser.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/tfpbrowser.R \docType{package} \name{tfpbrowser} -\alias{tfpbrowser} \alias{tfpbrowser-package} +\alias{tfpbrowser} \title{\code{{tfpbrowser}} package} \description{ An R package to build a Shiny application to explore {tfpscanner} outputs. diff --git a/renv.lock b/renv.lock index 2b8eca95..201ef15f 100644 --- a/renv.lock +++ b/renv.lock @@ -1,7 +1,27 @@ { "R": { - "Version": "4.3.2", + "Version": "4.2.3", "Repositories": [ + { + "Name": "BioCsoft", + "URL": "https://bioconductor.org/packages/3.16/bioc" + }, + { + "Name": "BioCann", + "URL": "https://bioconductor.org/packages/3.16/data/annotation" + }, + { + "Name": "BioCexp", + "URL": "https://bioconductor.org/packages/3.16/data/experiment" + }, + { + "Name": "BioCworkflows", + "URL": "https://bioconductor.org/packages/3.16/workflows" + }, + { + "Name": "BioCbooks", + "URL": "https://bioconductor.org/packages/3.16/books" + }, { "Name": "CRAN", "URL": "https://cloud.r-project.org" @@ -9,7 +29,7 @@ ] }, "Bioconductor": { - "Version": "3.17" + "Version": "3.16" }, "Packages": { "AsioHeaders": { @@ -21,32 +41,28 @@ }, "BiocManager": { "Package": "BiocManager", - "Version": "1.30.20", + "Version": "1.30.23", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "utils" ], - "Hash": "a7fca16a50b6ef7771b49d636dd54b57" + "Hash": "47e968dfe563c1b22c2e20a067ec21d5" }, "BiocVersion": { "Package": "BiocVersion", - "Version": "3.17.1", + "Version": "3.16.0", "Source": "Bioconductor", - "git_url": "https://git.bioconductor.org/packages/BiocVersion", - "git_branch": "master", - "git_last_commit": "a2d0c4c", - "git_last_commit_date": "2022-11-02", "Requirements": [ "R" ], - "Hash": "f7c0d5521799b7b0d0a211143ed0bfcb" + "Hash": "44c5824508b9a10e52dbb505c34fa880" }, "MASS": { "Package": "MASS", - "Version": "7.3-60", + "Version": "7.3-58.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "grDevices", @@ -55,13 +71,13 @@ "stats", "utils" ], - "Hash": "a56a6365b3fa73293ea8d084be0d9bb0" + "Hash": "e02d1a0f6122fd3e634b25b433704344" }, "Matrix": { "Package": "Matrix", - "Version": "1.5-4.1", + "Version": "1.5-3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "graphics", @@ -71,7 +87,18 @@ "stats", "utils" ], - "Hash": "38082d362d317745fb932e13956dccbb" + "Hash": "4006dffe49958d2dd591c17e61e60591" + }, + "PKI": { + "Package": "PKI", + "Version": "0.1-14", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "base64enc" + ], + "Hash": "f5b9c6b2f62f1fa3dd53fd1ddccbb241" }, "R6": { "Package": "R6", @@ -95,26 +122,20 @@ }, "Rcpp": { "Package": "Rcpp", - "Version": "1.0.10", + "Version": "1.0.12", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "Rcpp", - "RemoteRef": "Rcpp", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.0.10", + "Repository": "CRAN", "Requirements": [ "methods", "utils" ], - "Hash": "e749cae40fa9ef469b6050959517453c" + "Hash": "5ea2700d21e038ace58269ecdbeb9ec0" }, "ape": { "Package": "ape", - "Version": "5.7-1", + "Version": "5.8", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "Rcpp", @@ -127,14 +148,15 @@ "stats", "utils" ], - "Hash": "10705eec964349f270504754d8fe8ef1" + "Hash": "16b5ff4dff0ead9ea955f62f794b1535" }, "aplot": { "Package": "aplot", - "Version": "0.1.10", + "Version": "0.2.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "R", "ggfun", "ggplot2", "ggplotify", @@ -143,27 +165,27 @@ "patchwork", "utils" ], - "Hash": "e5ce4f3b5fe236bb879712ff8f956f06" + "Hash": "869a35e6d38fe9936eb578e09091842b" }, "askpass": { "Package": "askpass", - "Version": "1.1", + "Version": "1.2.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "sys" ], - "Hash": "e8a22846fff485f0be3770c2da758713" + "Hash": "cad6cf7f1d5f6e906700b9d3e718c796" }, "backports": { "Package": "backports", - "Version": "1.4.1", + "Version": "1.5.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R" ], - "Hash": "c39fbec8a30d23e721980b8afb31984c" + "Hash": "e1e1b9d75c37401117b636b7ae50827a" }, "base64enc": { "Package": "base64enc", @@ -201,80 +223,91 @@ }, "brio": { "Package": "brio", - "Version": "1.1.3", + "Version": "1.1.5", "Source": "Repository", - "Repository": "RSPM", - "Hash": "976cf154dfb043c012d87cddd8bca363" + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "c1ee497a6d999947c2c224ae46799b1a" + }, + "bsicons": { + "Package": "bsicons", + "Version": "0.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "htmltools", + "rlang", + "utils" + ], + "Hash": "d8f892fbd94d0b9b1f6d688b05b8633c" }, "bslib": { "Package": "bslib", - "Version": "0.4.2", + "Version": "0.7.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "base64enc", "cachem", + "fastmap", "grDevices", "htmltools", "jquerylib", "jsonlite", + "lifecycle", "memoise", "mime", "rlang", "sass" ], - "Hash": "a7fbf03946ad741129dc81098722fca1" + "Hash": "8644cc53f43828f19133548195d7e59e" }, "cachem": { "Package": "cachem", - "Version": "1.0.7", + "Version": "1.1.0", "Source": "Repository", - "Repository": "RSPM", - "RemotePkgRef": "cachem@1.0.7", - "RemoteType": "standard", - "RemoteEtag": "\"79ef8991588f9e5aad4cc465e8fa16aa\"", - "RemotePackaged": "TRUE", - "RemoteRef": "cachem", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.0.7", + "Repository": "CRAN", "Requirements": [ "fastmap", "rlang" ], - "Hash": "cda74447c42f529de601fe4d4050daef" + "Hash": "cd9a672193789068eb5a2aad65a0dedf" }, "callr": { "Package": "callr", - "Version": "3.7.3", + "Version": "3.7.6", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", "processx", "utils" ], - "Hash": "9b2191ede20fa29828139b9900922e51" + "Hash": "d7e13f49c19103ece9e58ad2d83a7354" }, "checkmate": { "Package": "checkmate", - "Version": "2.2.0", + "Version": "2.3.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "backports", "utils" ], - "Hash": "ca9c113196136f4a9ca9ce6079c2c99e" + "Hash": "c01cab1cb0f9125211a6fc99d540e315" }, "chromote": { "Package": "chromote", - "Version": "0.1.1", + "Version": "0.2.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R6", "curl", @@ -285,26 +318,21 @@ "processx", "promises", "rlang", + "utils", "websocket" ], - "Hash": "bb5817af24a2d8e6e33e758eb54978be" + "Hash": "3cfaf9cbd331e07055acada321664e12" }, "cli": { "Package": "cli", - "Version": "3.6.1", + "Version": "3.6.2", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "cli", - "RemoteRef": "cli", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "3.6.1", + "Repository": "CRAN", "Requirements": [ "R", "utils" ], - "Hash": "89e6d8219950eac806ae0c489052048a" + "Hash": "1216ac65ac55ec0058a6f75d7ca0fd52" }, "clipr": { "Package": "clipr", @@ -342,17 +370,20 @@ }, "commonmark": { "Package": "commonmark", - "Version": "1.9.0", + "Version": "1.9.1", "Source": "Repository", - "Repository": "RSPM", - "Hash": "d691c61bff84bd63c383874d2d0c3307" + "Repository": "CRAN", + "Hash": "5d8225445acb167abf7797de48b2ee3c" }, "cpp11": { "Package": "cpp11", - "Version": "0.4.3", + "Version": "0.4.7", "Source": "Repository", - "Repository": "RSPM", - "Hash": "ed588261931ee3be2c700d22e94a29ab" + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "5a295d7d963cc5035284dcdbaf334f4e" }, "crayon": { "Package": "crayon", @@ -366,54 +397,39 @@ ], "Hash": "e8a1e41acf02548751f45c718d55aa6a" }, - "credentials": { - "Package": "credentials", - "Version": "1.3.2", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "askpass", - "curl", - "jsonlite", - "openssl", - "sys" - ], - "Hash": "93762d0a34d78e6a025efdbfb5c6bb41" - }, "curl": { "Package": "curl", - "Version": "5.0.0", + "Version": "5.2.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R" ], - "Hash": "e4f97056611e8e6b8b852d13b7400cf1" + "Hash": "411ca2c03b1ce5f548345d2fc2685f7a" }, "data.table": { "Package": "data.table", - "Version": "1.14.8", + "Version": "1.15.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "methods" ], - "Hash": "b4c06e554f33344e044ccd7fdca750a9" + "Hash": "8ee9ac56ef633d0c7cab8b2ca87d683e" }, "desc": { "Package": "desc", - "Version": "1.4.2", + "Version": "1.4.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", "cli", - "rprojroot", "utils" ], - "Hash": "6b9602c7ebbe87101a9c8edb6e8b6d21" + "Hash": "99b79fcbd6c4d1ce087f5c5c758b384f" }, "diffobj": { "Package": "diffobj", @@ -432,20 +448,20 @@ }, "digest": { "Package": "digest", - "Version": "0.6.31", + "Version": "0.6.35", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "utils" ], - "Hash": "8b708f296afd9ae69f450f9640be8990" + "Hash": "698ece7ba5a4fa4559e3d537e7ec3d31" }, "dplyr": { "Package": "dplyr", - "Version": "1.1.2", + "Version": "1.1.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", @@ -462,90 +478,67 @@ "utils", "vctrs" ], - "Hash": "dea6970ff715ca541c387de363ff405e" - }, - "ellipsis": { - "Package": "ellipsis", - "Version": "0.3.2", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "R", - "rlang" - ], - "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" + "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" }, "evaluate": { "Package": "evaluate", - "Version": "0.21", + "Version": "0.23", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "evaluate", - "RemoteRef": "evaluate", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "0.21", + "Repository": "CRAN", "Requirements": [ "R", "methods" ], - "Hash": "d59f3b464e8da1aef82dc04b588b8dfb" + "Hash": "daf4a1246be12c1fa8c7705a0935c1a0" }, "fansi": { "Package": "fansi", - "Version": "1.0.4", + "Version": "1.0.6", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "grDevices", "utils" ], - "Hash": "1d9e7ad3c8312a192dea7d3db0274fde" + "Hash": "962174cf2aeb5b9eea581522286a911f" }, "farver": { "Package": "farver", - "Version": "2.1.1", + "Version": "2.1.2", "Source": "Repository", - "Repository": "RSPM", - "Hash": "8106d78941f34855c440ddb946b8f7a5" + "Repository": "CRAN", + "Hash": "680887028577f3fa2a81e410ed0d6e42" }, "fastmap": { "Package": "fastmap", - "Version": "1.1.0", + "Version": "1.2.0", "Source": "Repository", - "Repository": "RSPM", - "Hash": "77bd60a6157420d4ffa93b27cf6a58b8" + "Repository": "CRAN", + "Hash": "aa5e1cd11c2d15497494c5292d7ffcc8" }, "fontawesome": { "Package": "fontawesome", - "Version": "0.5.1", + "Version": "0.5.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "htmltools", "rlang" ], - "Hash": "1e22b8cabbad1eae951a75e9f8b52378" + "Hash": "c2efdd5f0bcd1ea861c2d4e2a883a67d" }, "fs": { "Package": "fs", - "Version": "1.6.2", + "Version": "1.6.4", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "fs", - "RemoteRef": "fs", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.6.2", + "Repository": "CRAN", "Requirements": [ "R", "methods" ], - "Hash": "94af08e0aa9675a16fadbb3aaaa90d2a" + "Hash": "15aeb8c27f5ea5161f9f6a641fafd93a" }, "generics": { "Package": "generics", @@ -558,49 +551,30 @@ ], "Hash": "15e9634c0fcd294799e9b2e929ed1b86" }, - "gert": { - "Package": "gert", - "Version": "1.9.2", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "askpass", - "credentials", - "openssl", - "rstudioapi", - "sys", - "zip" - ], - "Hash": "9122b3958e749badb5c939f498038b57" - }, "ggfun": { "Package": "ggfun", - "Version": "0.0.9", + "Version": "0.1.5", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "R", + "cli", + "dplyr", "ggplot2", "grid", "rlang", "utils" ], - "Hash": "c970ab268b09d3c8b0f524294050860f" + "Hash": "4fca342cc17bb91af2a279146bc57fef" }, "ggiraph": { "Package": "ggiraph", - "Version": "0.8.4", + "Version": "0.8.10", "Source": "Repository", - "Repository": "RSPM", - "RemotePkgRef": "ggiraph@0.8.4", - "RemoteType": "standard", - "RemoteEtag": "\"7d55b4cd82be7ae8d95b4ddd0a21b336\"", - "RemotePackaged": "TRUE", - "RemoteRef": "ggiraph", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "0.8.4", + "Repository": "CRAN", "Requirements": [ "Rcpp", + "cli", "ggplot2", "grid", "htmltools", @@ -612,21 +586,13 @@ "uuid", "vctrs" ], - "Hash": "98e3965e27dd3c9bda630b377544e92b" + "Hash": "15748f4335af873289fbdd31610c3f96" }, "ggplot2": { "Package": "ggplot2", - "Version": "3.4.0", + "Version": "3.5.1", "Source": "Repository", - "Repository": "RSPM", - "RemotePkgRef": "ggplot2@3.4.0", - "RemoteType": "standard", - "RemoteEtag": "\"bcfaa8d358bfaa987a4aff43c4dfc9da\"", - "RemotePackaged": "TRUE", - "RemoteRef": "ggplot2", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "3.4.0", + "Repository": "CRAN", "Requirements": [ "MASS", "R", @@ -645,13 +611,13 @@ "vctrs", "withr" ], - "Hash": "fd2aab12f54400c6bca43687231e246b" + "Hash": "44c6a2f8202d5b7e878ea274b1092426" }, "ggplotify": { "Package": "ggplotify", - "Version": "0.1.0", + "Version": "0.1.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "ggplot2", @@ -661,17 +627,18 @@ "gridGraphics", "yulab.utils" ], - "Hash": "acbcedf783cdb8710168aa0edba42ac0" + "Hash": "1547863db3b472cf7181973acf649f1a" }, "ggtree": { "Package": "ggtree", - "Version": "3.8.2", - "Source": "Bioconductor", - "Remotes": "GuangchuangYu/treeio", - "git_url": "https://git.bioconductor.org/packages/ggtree", - "git_branch": "RELEASE_3_17", - "git_last_commit": "36ae5e5", - "git_last_commit_date": "2023-07-24", + "Version": "3.13.0.001", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "ggtree", + "RemoteUsername": "YuLab-SMU", + "RemoteRef": "daf3371", + "RemoteSha": "daf3371032abd76645a8a5121913ae06edc90b86", "Requirements": [ "R", "ape", @@ -693,55 +660,29 @@ "utils", "yulab.utils" ], - "Hash": "8959d04f88a175de3f0cd2b46b4c2a65" - }, - "gh": { - "Package": "gh", - "Version": "1.4.0", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "R", - "cli", - "gitcreds", - "httr2", - "ini", - "jsonlite", - "rlang" - ], - "Hash": "03533b1c875028233598f848fda44c4c" - }, - "gitcreds": { - "Package": "gitcreds", - "Version": "0.1.2", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "R" - ], - "Hash": "ab08ac61f3e1be454ae21911eb8bc2fe" + "Hash": "e313a37ca4d92945369633a9d0b5754d" }, "globals": { "Package": "globals", - "Version": "0.16.2", + "Version": "0.16.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "codetools" ], - "Hash": "baa9585ab4ce47a9f4618e671778cc6f" + "Hash": "2580567908cafd4f187c1e5a91e98b7f" }, "glue": { "Package": "glue", - "Version": "1.6.2", + "Version": "1.8.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "methods" ], - "Hash": "4f2596dfb05dac67b9dc558e5c6fba2e" + "Hash": "5899f1eaa825580172bb56c08266f37c" }, "gridGraphics": { "Package": "gridGraphics", @@ -757,9 +698,9 @@ }, "gtable": { "Package": "gtable", - "Version": "0.3.3", + "Version": "0.3.5", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -768,24 +709,18 @@ "lifecycle", "rlang" ], - "Hash": "b44addadb528a0d227794121c00572a0" + "Hash": "e18861963cbc65a27736e02b3cd3c4a0" }, "highr": { "Package": "highr", - "Version": "0.10", + "Version": "0.11", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "highr", - "RemoteRef": "highr", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "0.10", + "Repository": "CRAN", "Requirements": [ "R", "xfun" ], - "Hash": "06230136b2d2b9ba5805e1963fa6e890" + "Hash": "d65ba49117ca223614f71b60d85b8ab7" }, "hms": { "Package": "hms", @@ -803,26 +738,25 @@ }, "htmltools": { "Package": "htmltools", - "Version": "0.5.5", + "Version": "0.5.8.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "base64enc", "digest", - "ellipsis", "fastmap", "grDevices", "rlang", "utils" ], - "Hash": "ba0240784ad50a62165058a27459304a" + "Hash": "81d371a9cc60640e74e4ab6ac46dcedc" }, "htmlwidgets": { "Package": "htmlwidgets", - "Version": "1.6.2", + "Version": "1.6.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "grDevices", "htmltools", @@ -831,13 +765,13 @@ "rmarkdown", "yaml" ], - "Hash": "a865aa85bcb2697f47505bfd70422471" + "Hash": "04291cc45198225444a397606810ac37" }, "httpuv": { "Package": "httpuv", - "Version": "1.6.11", + "Version": "1.6.15", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", @@ -846,13 +780,13 @@ "promises", "utils" ], - "Hash": "838602f54e32c1a0f8cc80708cefcefa" + "Hash": "d55aa087c47a63ead0f6fc10f8fa1ee0" }, "httr": { "Package": "httr", - "Version": "1.4.6", + "Version": "1.4.7", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", @@ -861,33 +795,7 @@ "mime", "openssl" ], - "Hash": "7e5e3cbd2a7bc07880c94e22348fb661" - }, - "httr2": { - "Package": "httr2", - "Version": "0.2.3", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "R", - "R6", - "cli", - "curl", - "glue", - "magrittr", - "openssl", - "rappdirs", - "rlang", - "withr" - ], - "Hash": "193bb297368afbbb42dc85784a46b36e" - }, - "ini": { - "Package": "ini", - "Version": "0.3.1", - "Source": "Repository", - "Repository": "RSPM", - "Hash": "6154ec2223172bce8162d4153cda21f7" + "Hash": "ac107251d9d9fd72f0ca8049988f1d7f" }, "isoband": { "Package": "isoband", @@ -904,13 +812,7 @@ "Package": "janitor", "Version": "2.2.0", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "janitor", - "RemoteRef": "janitor", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "2.2.0", + "Repository": "CRAN", "Requirements": [ "R", "dplyr", @@ -940,19 +842,19 @@ }, "jsonlite": { "Package": "jsonlite", - "Version": "1.8.4", + "Version": "1.8.8", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "methods" ], - "Hash": "a4269a09a9b865579b2635c77e572374" + "Hash": "e1b9c55281c5adc4dd113652d9e26768" }, "knitr": { "Package": "knitr", - "Version": "1.43", + "Version": "1.47", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "evaluate", @@ -962,41 +864,33 @@ "xfun", "yaml" ], - "Hash": "9775eb076713f627c07ce41d8199d8f6" + "Hash": "7c99b2d55584b982717fcc0950378612" }, "labeling": { "Package": "labeling", - "Version": "0.4.2", + "Version": "0.4.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "graphics", "stats" ], - "Hash": "3d5108641f47470611a32d0bdf357a72" + "Hash": "b64ec208ac5bc1852b285f665d6368b3" }, "later": { "Package": "later", - "Version": "1.3.0", + "Version": "1.3.2", "Source": "Repository", - "Repository": "RSPM", - "RemotePkgRef": "later@1.3.0", - "RemoteType": "standard", - "RemoteEtag": "\"d88839554a04c066f8ca978670ee8a9d\"", - "RemotePackaged": "TRUE", - "RemoteRef": "later", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.3.0", + "Repository": "CRAN", "Requirements": [ "Rcpp", "rlang" ], - "Hash": "7e7b457d7766bc47f2a5f21cc2984f8e" + "Hash": "a3e051d405326b8b0012377434c62b37" }, "lattice": { "Package": "lattice", - "Version": "0.21-8", + "Version": "0.20-45", "Source": "Repository", "Repository": "CRAN", "Requirements": [ @@ -1007,7 +901,7 @@ "stats", "utils" ], - "Hash": "0b8a6d63c8770f02a8b5635f3c431e6b" + "Hash": "b64cdbb2b340437c4ee047a1f4c4377b" }, "lazyeval": { "Package": "lazyeval", @@ -1021,29 +915,29 @@ }, "lifecycle": { "Package": "lifecycle", - "Version": "1.0.3", + "Version": "1.0.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", "glue", "rlang" ], - "Hash": "001cecbeac1cff9301bdc3775ee46a86" + "Hash": "b8552d117e1b808b09a832f589b79035" }, "lubridate": { "Package": "lubridate", - "Version": "1.9.2", + "Version": "1.9.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "generics", "methods", "timechange" ], - "Hash": "e25f18436e3efd42c7c590a1c4c15390" + "Hash": "680ad542fbcf801442c83a6ac5a2126c" }, "magrittr": { "Package": "magrittr", @@ -1055,6 +949,19 @@ ], "Hash": "7ce2733a9826b3aeb1775d56fd305472" }, + "markdown": { + "Package": "markdown", + "Version": "1.13", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "commonmark", + "utils", + "xfun" + ], + "Hash": "074efab766a9d6360865ad39512f2a7e" + }, "memoise": { "Package": "memoise", "Version": "2.0.1", @@ -1095,14 +1002,14 @@ }, "munsell": { "Package": "munsell", - "Version": "0.5.0", + "Version": "0.5.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "colorspace", "methods" ], - "Hash": "6dfe8bf774944bd5595785e3229d8771" + "Hash": "4fd8900853b746af55b81fda99da7695" }, "nlme": { "Package": "nlme", @@ -1120,29 +1027,43 @@ }, "openssl": { "Package": "openssl", - "Version": "2.0.6", + "Version": "2.2.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "askpass" ], - "Hash": "0f7cd2962e3044bb940cca4f4b5cecbe" + "Hash": "2bcca3848e4734eb3b16103bc9aa4b8e" + }, + "packrat": { + "Package": "packrat", + "Version": "0.9.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "tools", + "utils" + ], + "Hash": "55ddd2d4a1959535f18393478b0c14a6" }, "patchwork": { "Package": "patchwork", - "Version": "1.1.2", + "Version": "1.2.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "cli", "ggplot2", "grDevices", "graphics", "grid", "gtable", + "rlang", "stats", "utils" ], - "Hash": "63b611e9d909a9ed057639d9c3b77152" + "Hash": "9c8ab14c00ac07e9e04d1664c0b74486" }, "pillar": { "Package": "pillar", @@ -1163,14 +1084,30 @@ }, "pingr": { "Package": "pingr", - "Version": "2.0.2", + "Version": "2.0.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "R", "processx", "utils" ], - "Hash": "b762f8f7d305f7eb0bab96eb1a3c782a" + "Hash": "8d2db1d13f4198a00ebf2f066bf2ab67" + }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.4.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "callr", + "cli", + "desc", + "processx" + ], + "Hash": "a29e8e134a460a01e0ca67a4763c595b" }, "pkgconfig": { "Package": "pkgconfig", @@ -1184,9 +1121,9 @@ }, "pkgload": { "Package": "pkgload", - "Version": "1.3.2", + "Version": "1.3.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -1195,12 +1132,13 @@ "fs", "glue", "methods", + "pkgbuild", "rlang", "rprojroot", "utils", "withr" ], - "Hash": "6b0c222c5071efe0f3baf3dae9aa40e2" + "Hash": "876c618df5ae610be84356d5d7a5d124" }, "praise": { "Package": "praise", @@ -1211,80 +1149,73 @@ }, "prettyunits": { "Package": "prettyunits", - "Version": "1.1.1", + "Version": "1.2.0", "Source": "Repository", - "Repository": "RSPM", - "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "6b01fc98b1e86c4f705ce9dcfd2f57c7" }, "processx": { "Package": "processx", - "Version": "3.8.1", + "Version": "3.8.4", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "processx", - "RemoteRef": "processx", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "3.8.1", + "Repository": "CRAN", "Requirements": [ "R", "R6", "ps", "utils" ], - "Hash": "d75b4059d781336efba24021915902b4" + "Hash": "0c90a7d71988856bad2a2a45dd871bb9" }, "progress": { "Package": "progress", - "Version": "1.2.2", + "Version": "1.2.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "R", "R6", "crayon", "hms", "prettyunits" ], - "Hash": "14dc9f7a3c91ebb14ec5bb9208a07061" + "Hash": "f4625e061cb2865f111b47ff163a5ca6" }, "promises": { "Package": "promises", - "Version": "1.2.0.1", + "Version": "1.2.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R6", "Rcpp", + "fastmap", "later", "magrittr", "rlang", "stats" ], - "Hash": "4ab2c43adb4d4699cf3690acd378d75d" + "Hash": "0d8a15c9d000970ada1ab21405387dee" }, "ps": { "Package": "ps", - "Version": "1.7.5", + "Version": "1.7.6", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "ps", - "RemoteRef": "ps", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.7.5", + "Repository": "CRAN", "Requirements": [ "R", "utils" ], - "Hash": "709d852d33178db54b17c722e5b1e594" + "Hash": "dd2b9319ee0656c8acf45c7f40c59de7" }, "purrr": { "Package": "purrr", - "Version": "1.0.1", + "Version": "1.0.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -1293,7 +1224,7 @@ "rlang", "vctrs" ], - "Hash": "d71c815267c640f17ddbf7f16144b4bb" + "Hash": "1cba04a4e9414bdefc9dcaa99649a8dc" }, "rappdirs": { "Package": "rappdirs", @@ -1307,13 +1238,13 @@ }, "reactR": { "Package": "reactR", - "Version": "0.4.4", + "Version": "0.5.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "htmltools" ], - "Hash": "75389c8091eb14ee21c6bc87a88b3809" + "Hash": "c9014fd1a435b2d790dd506589cb24e5" }, "reactable": { "Package": "reactable", @@ -1332,9 +1263,9 @@ }, "readr": { "Package": "readr", - "Version": "2.1.4", + "Version": "2.1.5", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", @@ -1351,7 +1282,7 @@ "utils", "vroom" ], - "Hash": "b5047343b3825f37ad9d3b5d89aa1078" + "Hash": "9de96463d2117f6ac49980577939dfb3" }, "rematch2": { "Package": "rematch2", @@ -1365,30 +1296,30 @@ }, "renv": { "Package": "renv", - "Version": "0.17.3", + "Version": "1.0.7", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "utils" ], - "Hash": "4543b8cd233ae25c6aba8548be9e747e" + "Hash": "397b7b2a265bc5a7a06852524dabae20" }, "rlang": { "Package": "rlang", - "Version": "1.1.1", + "Version": "1.1.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "utils" ], - "Hash": "a85c767b55f0bf9b7ad16c6d7baee5bb" + "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, "rmarkdown": { "Package": "rmarkdown", - "Version": "2.22", + "Version": "2.27", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "bslib", @@ -1399,45 +1330,59 @@ "jsonlite", "knitr", "methods", - "stringr", "tinytex", "tools", "utils", "xfun", "yaml" ], - "Hash": "75a01be060d800ceb14e32c666cacac9" + "Hash": "27f9502e1cdbfa195f94e03b0f517484" }, "rprojroot": { "Package": "rprojroot", - "Version": "2.0.3", + "Version": "2.0.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R" ], - "Hash": "1de7ab598047a87bba48434ba35d497d" + "Hash": "4c8415e0ec1e29f3f4f6fc108bef0144" + }, + "rsconnect": { + "Package": "rsconnect", + "Version": "1.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "PKI", + "R", + "cli", + "curl", + "digest", + "jsonlite", + "lifecycle", + "openssl", + "packrat", + "renv", + "rlang", + "rstudioapi", + "tools", + "yaml" + ], + "Hash": "90dc9ac04cec50f25657b077d4aaca57" }, "rstudioapi": { "Package": "rstudioapi", - "Version": "0.14", + "Version": "0.17.0", "Source": "Repository", - "Repository": "RSPM", - "Hash": "690bd2acc42a9166ce34845884459320" + "Repository": "CRAN", + "Hash": "fb9f5fce8f609e9b66f0bea5c783f88a" }, "sass": { "Package": "sass", - "Version": "0.4.5", + "Version": "0.4.9", "Source": "Repository", - "Repository": "RSPM", - "RemotePkgRef": "sass@0.4.5", - "RemoteType": "standard", - "RemoteEtag": "\"3cac281329b169253ec2dc4243739459\"", - "RemotePackaged": "TRUE", - "RemoteRef": "sass", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "0.4.5", + "Repository": "CRAN", "Requirements": [ "R6", "fs", @@ -1445,31 +1390,33 @@ "rappdirs", "rlang" ], - "Hash": "2bb4371a4c80115518261866eab6ab11" + "Hash": "d53dbfddf695303ea4ad66f86e99b95d" }, "scales": { "Package": "scales", - "Version": "1.2.1", + "Version": "1.3.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", "RColorBrewer", + "cli", "farver", + "glue", "labeling", "lifecycle", "munsell", "rlang", "viridisLite" ], - "Hash": "906cb23d2f1c5680b8ce439b44c6fa63" + "Hash": "c19df082ba346b0ffa6f833e92de34d1" }, "shiny": { "Package": "shiny", - "Version": "1.7.4", + "Version": "1.8.1.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", @@ -1477,7 +1424,6 @@ "cachem", "commonmark", "crayon", - "ellipsis", "fastmap", "fontawesome", "glue", @@ -1497,19 +1443,13 @@ "withr", "xtable" ], - "Hash": "c2eae3d8c670fa9dfa35a12066f4a1d5" + "Hash": "54b26646816af9960a4c64d8ceec75d6" }, "shinybrowser": { "Package": "shinybrowser", "Version": "1.0.0", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "shinybrowser", - "RemoteRef": "shinybrowser", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.0.0", + "Repository": "CRAN", "Requirements": [ "R", "shiny" @@ -1531,9 +1471,9 @@ }, "shinytest2": { "Package": "shinytest2", - "Version": "0.2.1", + "Version": "0.3.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R6", "callr", @@ -1541,7 +1481,6 @@ "chromote", "cpp11", "crayon", - "ellipsis", "fs", "globals", "httr", @@ -1553,25 +1492,19 @@ "testthat", "withr" ], - "Hash": "da29b51211b28a7180977d94b638127e" + "Hash": "a414c1bb2eb6e2a920742d3ebce84962" }, "snakecase": { "Package": "snakecase", - "Version": "0.11.0", + "Version": "0.11.1", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "snakecase", - "RemoteRef": "snakecase", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "0.11.0", + "Repository": "CRAN", "Requirements": [ "R", "stringi", "stringr" ], - "Hash": "4079070fc210c7901c0832a3aeab894f" + "Hash": "58767e44739b76965332e8a4fe3f91f1" }, "sourcetools": { "Package": "sourcetools", @@ -1585,28 +1518,22 @@ }, "stringi": { "Package": "stringi", - "Version": "1.7.12", + "Version": "1.8.4", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "stringi", - "RemoteRef": "stringi", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "1.7.12", + "Repository": "CRAN", "Requirements": [ "R", "stats", "tools", "utils" ], - "Hash": "ca8bd84263c77310739d2cf64d84d7c9" + "Hash": "39e1144fd75428983dc3f63aa53dfa91" }, "stringr": { "Package": "stringr", - "Version": "1.5.0", + "Version": "1.5.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -1617,7 +1544,7 @@ "stringi", "vctrs" ], - "Hash": "671a4d384ae9d32fc47a14e98bfa3dc8" + "Hash": "960e2ae9e09656611e0b8214ad543207" }, "sys": { "Package": "sys", @@ -1628,20 +1555,21 @@ }, "systemfonts": { "Package": "systemfonts", - "Version": "1.0.4", + "Version": "1.1.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", - "cpp11" + "cpp11", + "lifecycle" ], - "Hash": "90b28393209827327de889f49935140a" + "Hash": "213b6b8ed5afbf934843e6c3b090d418" }, "testthat": { "Package": "testthat", - "Version": "3.1.8", + "Version": "3.2.1.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "R6", @@ -1650,7 +1578,6 @@ "cli", "desc", "digest", - "ellipsis", "evaluate", "jsonlite", "lifecycle", @@ -1665,7 +1592,7 @@ "waldo", "withr" ], - "Hash": "e0eded5dd915510f8e0d6e6277506203" + "Hash": "3f6e7e5e2220856ff865e4834766bf2b" }, "tibble": { "Package": "tibble", @@ -1688,9 +1615,9 @@ }, "tidyr": { "Package": "tidyr", - "Version": "1.3.0", + "Version": "1.3.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -1707,13 +1634,13 @@ "utils", "vctrs" ], - "Hash": "e47debdc7ce599b070c8e78e8ac0cfcf" + "Hash": "915fb7ce036c22a6a33b5a8adb712eb1" }, "tidyselect": { "Package": "tidyselect", - "Version": "1.2.0", + "Version": "1.2.1", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -1723,13 +1650,13 @@ "vctrs", "withr" ], - "Hash": "79540e5fcd9e0435af547d885f184fd5" + "Hash": "829f27b9c4919c16b593794a6344d6c0" }, "tidytree": { "Package": "tidytree", - "Version": "0.4.2", + "Version": "0.4.6", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "ape", @@ -1745,41 +1672,36 @@ "tidyselect", "yulab.utils" ], - "Hash": "6f2eb34d95db945d4dd022b0811e28db" + "Hash": "a700d295c0eff82fbce42eac067bb89d" }, "timechange": { "Package": "timechange", - "Version": "0.2.0", + "Version": "0.3.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "cpp11" ], - "Hash": "8548b44f79a35ba1791308b61e6012d7" + "Hash": "c5f3c201b931cd6474d17d8700ccb1c8" }, "tinytex": { "Package": "tinytex", - "Version": "0.45", + "Version": "0.51", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "xfun" ], - "Hash": "e4e357f28c2edff493936b6cb30c3d65" + "Hash": "d44e2fcd2e4e076f0aac540208559d1d" }, "treeio": { "Package": "treeio", - "Version": "1.24.3", + "Version": "1.22.0", "Source": "Bioconductor", - "git_url": "https://git.bioconductor.org/packages/treeio", - "git_branch": "RELEASE_3_17", - "git_last_commit": "132fb4d", - "git_last_commit_date": "2023-07-24", "Requirements": [ "R", "ape", - "cli", "dplyr", "jsonlite", "magrittr", @@ -1789,7 +1711,7 @@ "tidytree", "utils" ], - "Hash": "c8c8efbcec2f1512d6079af62b0f112b" + "Hash": "79eb206300fb5e5feea1f508a8166eba" }, "tzdb": { "Package": "tzdb", @@ -1802,68 +1724,31 @@ ], "Hash": "f561504ec2897f4d46f0c7657e488ae1" }, - "usethis": { - "Package": "usethis", - "Version": "2.1.6", - "Source": "Repository", - "Repository": "RSPM", - "Requirements": [ - "R", - "cli", - "clipr", - "crayon", - "curl", - "desc", - "fs", - "gert", - "gh", - "glue", - "jsonlite", - "lifecycle", - "purrr", - "rappdirs", - "rlang", - "rprojroot", - "rstudioapi", - "stats", - "utils", - "whisker", - "withr", - "yaml" - ], - "Hash": "a67a22c201832b12c036cc059f1d137d" - }, "utf8": { "Package": "utf8", - "Version": "1.2.3", + "Version": "1.2.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R" ], - "Hash": "1fe17157424bb09c48a8b3b550c753bc" + "Hash": "62b65c52671e6665f803ff02954446e9" }, "uuid": { "Package": "uuid", - "Version": "1.1-0", + "Version": "1.2-0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R" ], - "Hash": "f1cb46c157d080b729159d407be83496" + "Hash": "303c19bfd970bece872f93a824e323d9" }, "vctrs": { "Package": "vctrs", - "Version": "0.6.2", + "Version": "0.6.5", "Source": "Repository", - "Repository": "RSPM", - "RemoteType": "standard", - "RemotePkgRef": "vctrs", - "RemoteRef": "vctrs", - "RemoteRepos": "https://packagemanager.rstudio.com/all/latest", - "RemotePkgPlatform": "source", - "RemoteSha": "0.6.2", + "Repository": "CRAN", "Requirements": [ "R", "cli", @@ -1871,7 +1756,7 @@ "lifecycle", "rlang" ], - "Hash": "a745bda7aff4734c17294bb41d4e4607" + "Hash": "c03fa420630029418f7e6da3667aac4a" }, "viridisLite": { "Package": "viridisLite", @@ -1885,9 +1770,9 @@ }, "vroom": { "Package": "vroom", - "Version": "1.6.3", + "Version": "1.6.5", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "bit64", @@ -1907,14 +1792,15 @@ "vctrs", "withr" ], - "Hash": "8318e64ffb3a70e652494017ec455561" + "Hash": "390f9315bc0025be03012054103d227c" }, "waldo": { "Package": "waldo", - "Version": "0.5.1", + "Version": "0.5.2", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "R", "cli", "diffobj", "fansi", @@ -1924,7 +1810,7 @@ "rlang", "tibble" ], - "Hash": "2c993415154cdb94649d99ae138ff5e5" + "Hash": "c7d3fd6d29ab077cbac8f0e2751449e6" }, "websocket": { "Package": "websocket", @@ -1939,36 +1825,29 @@ ], "Hash": "76e0d400757e318cca33def29ccebbc2" }, - "whisker": { - "Package": "whisker", - "Version": "0.4.1", - "Source": "Repository", - "Repository": "RSPM", - "Hash": "c6abfa47a46d281a7d5159d0a8891e88" - }, "withr": { "Package": "withr", - "Version": "2.5.0", + "Version": "3.0.0", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ "R", "grDevices", - "graphics", - "stats" + "graphics" ], - "Hash": "c0e49a9760983e81e55cdd9be92e7182" + "Hash": "d31b6c62c10dcf11ec530ca6b0dd5d35" }, "xfun": { "Package": "xfun", - "Version": "0.39", + "Version": "0.44", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "grDevices", "stats", "tools" ], - "Hash": "8f56e9acb54fb525e66464d57ab58bcb" + "Hash": "317a0538d32f4a009658bcedb7923f4b" }, "xtable": { "Package": "xtable", @@ -1984,28 +1863,27 @@ }, "yaml": { "Package": "yaml", - "Version": "2.3.7", + "Version": "2.3.8", "Source": "Repository", - "Repository": "RSPM", - "Hash": "0d0056cc5383fbc240ccd0cb584bf436" + "Repository": "CRAN", + "Hash": "29240487a071f535f5e5d5a323b7afbd" }, "yulab.utils": { "Package": "yulab.utils", - "Version": "0.0.6", + "Version": "0.1.4", "Source": "Repository", - "Repository": "RSPM", + "Repository": "CRAN", "Requirements": [ + "cli", + "digest", + "fs", + "memoise", + "rlang", "stats", + "tools", "utils" ], - "Hash": "0d0b7cc6da5efc21f07f6b8d966a9cc1" - }, - "zip": { - "Package": "zip", - "Version": "2.3.0", - "Source": "Repository", - "Repository": "RSPM", - "Hash": "d98c94dacb7e0efcf83b0a133a705504" + "Hash": "60ee2aaa179dc282e9fa7367bad76e89" } } } diff --git a/renv/activate.R b/renv/activate.R index a8fdc320..d13f9932 100644 --- a/renv/activate.R +++ b/renv/activate.R @@ -2,10 +2,28 @@ local({ # the requested version of renv - version <- "0.17.3" + version <- "1.0.7" + attr(version, "sha") <- NULL # the project directory - project <- getwd() + project <- Sys.getenv("RENV_PROJECT") + if (!nzchar(project)) + project <- getwd() + + # use start-up diagnostics if enabled + diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE") + if (diagnostics) { + start <- Sys.time() + profile <- tempfile("renv-startup-", fileext = ".Rprof") + utils::Rprof(profile) + on.exit({ + utils::Rprof(NULL) + elapsed <- signif(difftime(Sys.time(), start, units = "auto"), digits = 2L) + writeLines(sprintf("- renv took %s to run the autoloader.", format(elapsed))) + writeLines(sprintf("- Profile: %s", profile)) + print(utils::summaryRprof(profile)) + }, add = TRUE) + } # figure out whether the autoloader is enabled enabled <- local({ @@ -15,6 +33,14 @@ local({ if (!is.null(override)) return(override) + # if we're being run in a context where R_LIBS is already set, + # don't load -- presumably we're being run as a sub-process and + # the parent process has already set up library paths for us + rcmd <- Sys.getenv("R_CMD", unset = NA) + rlibs <- Sys.getenv("R_LIBS", unset = NA) + if (!is.na(rlibs) && !is.na(rcmd)) + return(FALSE) + # next, check environment variables # TODO: prefer using the configuration one in the future envvars <- c( @@ -34,9 +60,22 @@ local({ }) - if (!enabled) + # bail if we're not enabled + if (!enabled) { + + # if we're not enabled, we might still need to manually load + # the user profile here + profile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile") + if (file.exists(profile)) { + cfg <- Sys.getenv("RENV_CONFIG_USER_PROFILE", unset = "TRUE") + if (tolower(cfg) %in% c("true", "t", "1")) + sys.source(profile, envir = globalenv()) + } + return(FALSE) + } + # avoid recursion if (identical(getOption("renv.autoloader.running"), TRUE)) { warning("ignoring recursive attempt to run renv autoloader") @@ -60,25 +99,90 @@ local({ # load bootstrap tools `%||%` <- function(x, y) { - if (is.environment(x) || length(x)) x else y + if (is.null(x)) y else x } - `%??%` <- function(x, y) { - if (is.null(x)) y else x + catf <- function(fmt, ..., appendLF = TRUE) { + + quiet <- getOption("renv.bootstrap.quiet", default = FALSE) + if (quiet) + return(invisible()) + + msg <- sprintf(fmt, ...) + cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") + + invisible(msg) + + } + + header <- function(label, + ..., + prefix = "#", + suffix = "-", + n = min(getOption("width"), 78)) + { + label <- sprintf(label, ...) + n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) + if (n <= 0) + return(paste(prefix, label)) + + tail <- paste(rep.int(suffix, n), collapse = "") + paste0(prefix, " ", label, " ", tail) + + } + + heredoc <- function(text, leave = 0) { + + # remove leading, trailing whitespace + trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text) + + # split into lines + lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]] + + # compute common indent + indent <- regexpr("[^[:space:]]", lines) + common <- min(setdiff(indent, -1L)) - leave + paste(substring(lines, common), collapse = "\n") + + } + + startswith <- function(string, prefix) { + substring(string, 1, nchar(prefix)) == prefix } bootstrap <- function(version, library) { + friendly <- renv_bootstrap_version_friendly(version) + section <- header(sprintf("Bootstrapping renv %s", friendly)) + catf(section) + # attempt to download renv - tarball <- tryCatch(renv_bootstrap_download(version), error = identity) - if (inherits(tarball, "error")) - stop("failed to download renv ", version) + catf("- Downloading renv ... ", appendLF = FALSE) + withCallingHandlers( + tarball <- renv_bootstrap_download(version), + error = function(err) { + catf("FAILED") + stop("failed to download:\n", conditionMessage(err)) + } + ) + catf("OK") + on.exit(unlink(tarball), add = TRUE) # now attempt to install - status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) - if (inherits(status, "error")) - stop("failed to install renv ", version) + catf("- Installing renv ... ", appendLF = FALSE) + withCallingHandlers( + status <- renv_bootstrap_install(version, tarball, library), + error = function(err) { + catf("FAILED") + stop("failed to install:\n", conditionMessage(err)) + } + ) + catf("OK") + + # add empty line to break up bootstrapping from normal output + catf("") + return(invisible()) } renv_bootstrap_tests_running <- function() { @@ -108,13 +212,6 @@ local({ if (!inherits(repos, "error") && length(repos)) return(repos) - # if we're testing, re-use the test repositories - if (renv_bootstrap_tests_running()) { - repos <- getOption("renv.tests.repos") - if (!is.null(repos)) - return(repos) - } - # retrieve current repos repos <- getOption("repos") @@ -158,33 +255,34 @@ local({ renv_bootstrap_download <- function(version) { - # if the renv version number has 4 components, assume it must - # be retrieved via github - nv <- numeric_version(version) - components <- unclass(nv)[[1]] - - # if this appears to be a development version of 'renv', we'll - # try to restore from github - dev <- length(components) == 4L - - # begin collecting different methods for finding renv - methods <- c( - renv_bootstrap_download_tarball, - if (dev) - renv_bootstrap_download_github - else c( - renv_bootstrap_download_cran_latest, - renv_bootstrap_download_cran_archive + sha <- attr(version, "sha", exact = TRUE) + + methods <- if (!is.null(sha)) { + + # attempting to bootstrap a development version of renv + c( + function() renv_bootstrap_download_tarball(sha), + function() renv_bootstrap_download_github(sha) ) - ) + + } else { + + # attempting to bootstrap a release version of renv + c( + function() renv_bootstrap_download_tarball(version), + function() renv_bootstrap_download_cran_latest(version), + function() renv_bootstrap_download_cran_archive(version) + ) + + } for (method in methods) { - path <- tryCatch(method(version), error = identity) + path <- tryCatch(method(), error = identity) if (is.character(path) && file.exists(path)) return(path) } - stop("failed to download renv ", version) + stop("All download methods failed") } @@ -248,8 +346,6 @@ local({ type <- spec$type repos <- spec$repos - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - baseurl <- utils::contrib.url(repos = repos, type = type) ext <- if (identical(type, "source")) ".tar.gz" @@ -266,13 +362,10 @@ local({ condition = identity ) - if (inherits(status, "condition")) { - message("FAILED") + if (inherits(status, "condition")) return(FALSE) - } # report success and return - message("OK (downloaded ", type, ")") destfile } @@ -329,8 +422,6 @@ local({ urls <- file.path(repos, "src/contrib/Archive/renv", name) destfile <- file.path(tempdir(), name) - message("* Downloading renv ", version, " ... ", appendLF = FALSE) - for (url in urls) { status <- tryCatch( @@ -338,14 +429,11 @@ local({ condition = identity ) - if (identical(status, 0L)) { - message("OK") + if (identical(status, 0L)) return(destfile) - } } - message("FAILED") return(FALSE) } @@ -368,7 +456,7 @@ local({ if (!file.exists(tarball)) { # let the user know we weren't able to honour their request - fmt <- "* RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." msg <- sprintf(fmt, tarball) warning(msg) @@ -377,10 +465,7 @@ local({ } - fmt <- "* Bootstrapping with tarball at path '%s'." - msg <- sprintf(fmt, tarball) - message(msg) - + catf("- Using local tarball '%s'.", tarball) tarball } @@ -407,8 +492,6 @@ local({ on.exit(do.call(base::options, saved), add = TRUE) } - message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) - url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) name <- sprintf("renv_%s.tar.gz", version) destfile <- file.path(tempdir(), name) @@ -418,26 +501,105 @@ local({ condition = identity ) - if (!identical(status, 0L)) { - message("FAILED") + if (!identical(status, 0L)) return(FALSE) - } - message("OK") + renv_bootstrap_download_augment(destfile) + return(destfile) } + # Add Sha to DESCRIPTION. This is stop gap until #890, after which we + # can use renv::install() to fully capture metadata. + renv_bootstrap_download_augment <- function(destfile) { + sha <- renv_bootstrap_git_extract_sha1_tar(destfile) + if (is.null(sha)) { + return() + } + + # Untar + tempdir <- tempfile("renv-github-") + on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) + untar(destfile, exdir = tempdir) + pkgdir <- dir(tempdir, full.names = TRUE)[[1]] + + # Modify description + desc_path <- file.path(pkgdir, "DESCRIPTION") + desc_lines <- readLines(desc_path) + remotes_fields <- c( + "RemoteType: github", + "RemoteHost: api.github.com", + "RemoteRepo: renv", + "RemoteUsername: rstudio", + "RemotePkgRef: rstudio/renv", + paste("RemoteRef: ", sha), + paste("RemoteSha: ", sha) + ) + writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) + + # Re-tar + local({ + old <- setwd(tempdir) + on.exit(setwd(old), add = TRUE) + + tar(destfile, compression = "gzip") + }) + invisible() + } + + # Extract the commit hash from a git archive. Git archives include the SHA1 + # hash as the comment field of the tarball pax extended header + # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) + # For GitHub archives this should be the first header after the default one + # (512 byte) header. + renv_bootstrap_git_extract_sha1_tar <- function(bundle) { + + # open the bundle for reading + # We use gzcon for everything because (from ?gzcon) + # > Reading from a connection which does not supply a 'gzip' magic + # > header is equivalent to reading from the original connection + conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) + on.exit(close(conn)) + + # The default pax header is 512 bytes long and the first pax extended header + # with the comment should be 51 bytes long + # `52 comment=` (11 chars) + 40 byte SHA1 hash + len <- 0x200 + 0x33 + res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) + + if (grepl("^52 comment=", res)) { + sub("52 comment=", "", res) + } else { + NULL + } + } + renv_bootstrap_install <- function(version, tarball, library) { # attempt to install it into project library - message("* Installing renv ", version, " ... ", appendLF = FALSE) dir.create(library, showWarnings = FALSE, recursive = TRUE) + output <- renv_bootstrap_install_impl(library, tarball) + + # check for successful install + status <- attr(output, "status") + if (is.null(status) || identical(status, 0L)) + return(status) + + # an error occurred; report it + header <- "installation of renv failed" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- paste(c(header, lines, output), collapse = "\n") + stop(text) + + } + + renv_bootstrap_install_impl <- function(library, tarball) { # invoke using system2 so we can capture and report output bin <- R.home("bin") exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" - r <- file.path(bin, exe) + R <- file.path(bin, exe) args <- c( "--vanilla", "CMD", "INSTALL", "--no-multiarch", @@ -445,19 +607,7 @@ local({ shQuote(path.expand(tarball)) ) - output <- system2(r, args, stdout = TRUE, stderr = TRUE) - message("Done!") - - # check for successful install - status <- attr(output, "status") - if (is.numeric(status) && !identical(status, 0L)) { - header <- "Error installing renv:" - lines <- paste(rep.int("=", nchar(header)), collapse = "") - text <- c(header, lines, output) - writeLines(text, con = stderr()) - } - - status + system2(R, args, stdout = TRUE, stderr = TRUE) } @@ -498,6 +648,9 @@ local({ # if the user has requested an automatic prefix, generate it auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (is.na(auto) && getRversion() >= "4.4.0") + auto <- "TRUE" + if (auto %in% c("TRUE", "True", "true", "1")) return(renv_bootstrap_platform_prefix_auto()) @@ -667,34 +820,61 @@ local({ } - renv_bootstrap_validate_version <- function(version) { + renv_bootstrap_validate_version <- function(version, description = NULL) { + + # resolve description file + # + # avoid passing lib.loc to `packageDescription()` below, since R will + # use the loaded version of the package by default anyhow. note that + # this function should only be called after 'renv' is loaded + # https://github.com/rstudio/renv/issues/1625 + description <- description %||% packageDescription("renv") - loadedversion <- utils::packageDescription("renv", fields = "Version") - if (version == loadedversion) + # check whether requested version 'version' matches loaded version of renv + sha <- attr(version, "sha", exact = TRUE) + valid <- if (!is.null(sha)) + renv_bootstrap_validate_version_dev(sha, description) + else + renv_bootstrap_validate_version_release(version, description) + + if (valid) return(TRUE) - # assume four-component versions are from GitHub; - # three-component versions are from CRAN - components <- strsplit(loadedversion, "[.-]")[[1]] - remote <- if (length(components) == 4L) - paste("rstudio/renv", loadedversion, sep = "@") + # the loaded version of renv doesn't match the requested version; + # give the user instructions on how to proceed + dev <- identical(description[["RemoteType"]], "github") + remote <- if (dev) + paste("rstudio/renv", description[["RemoteSha"]], sep = "@") else - paste("renv", loadedversion, sep = "@") + paste("renv", description[["Version"]], sep = "@") - fmt <- paste( - "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", - "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", - "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", - sep = "\n" + # display both loaded version + sha if available + friendly <- renv_bootstrap_version_friendly( + version = description[["Version"]], + sha = if (dev) description[["RemoteSha"]] ) - msg <- sprintf(fmt, loadedversion, version, remote) - warning(msg, call. = FALSE) + fmt <- heredoc(" + renv %1$s was loaded from project library, but this project is configured to use renv %2$s. + - Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile. + - Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library. + ") + catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) FALSE } + renv_bootstrap_validate_version_dev <- function(version, description) { + expected <- description[["RemoteSha"]] + is.character(expected) && startswith(expected, version) + } + + renv_bootstrap_validate_version_release <- function(version, description) { + expected <- description[["Version"]] + is.character(expected) && identical(expected, version) + } + renv_bootstrap_hash_text <- function(text) { hashfile <- tempfile("renv-hash-") @@ -718,7 +898,7 @@ local({ hooks <- getHook("renv::autoload") for (hook in hooks) if (is.function(hook)) - tryCatch(hook(), error = warning) + tryCatch(hook(), error = warnify) # load the project renv::load(project) @@ -859,6 +1039,40 @@ local({ } + renv_bootstrap_version_friendly <- function(version, shafmt = NULL, sha = NULL) { + sha <- sha %||% attr(version, "sha", exact = TRUE) + parts <- c(version, sprintf(shafmt %||% " [sha: %s]", substring(sha, 1L, 7L))) + paste(parts, collapse = "") + } + + renv_bootstrap_exec <- function(project, libpath, version) { + if (!renv_bootstrap_load(project, libpath, version)) + renv_bootstrap_run(version, libpath) + } + + renv_bootstrap_run <- function(version, libpath) { + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + return(renv::load(project = getwd())) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + + } renv_json_read <- function(file = NULL, text = NULL) { @@ -867,7 +1081,7 @@ local({ # if jsonlite is loaded, use that instead if ("jsonlite" %in% loadedNamespaces()) { - json <- catch(renv_json_read_jsonlite(file, text)) + json <- tryCatch(renv_json_read_jsonlite(file, text), error = identity) if (!inherits(json, "error")) return(json) @@ -876,7 +1090,7 @@ local({ } # otherwise, fall back to the default JSON reader - json <- catch(renv_json_read_default(file, text)) + json <- tryCatch(renv_json_read_default(file, text), error = identity) if (!inherits(json, "error")) return(json) @@ -889,14 +1103,14 @@ local({ } renv_json_read_jsonlite <- function(file = NULL, text = NULL) { - text <- paste(text %||% read(file), collapse = "\n") + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") jsonlite::fromJSON(txt = text, simplifyVector = FALSE) } renv_json_read_default <- function(file = NULL, text = NULL) { # find strings in the JSON - text <- paste(text %||% read(file), collapse = "\n") + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' locs <- gregexpr(pattern, text, perl = TRUE)[[1]] @@ -944,14 +1158,14 @@ local({ map <- as.list(map) # remap strings in object - remapped <- renv_json_remap(json, map) + remapped <- renv_json_read_remap(json, map) # evaluate eval(remapped, envir = baseenv()) } - renv_json_remap <- function(json, map) { + renv_json_read_remap <- function(json, map) { # fix names if (!is.null(names(json))) { @@ -978,7 +1192,7 @@ local({ # recurse if (is.recursive(json)) { for (i in seq_along(json)) { - json[i] <- list(renv_json_remap(json[[i]], map)) + json[i] <- list(renv_json_read_remap(json[[i]], map)) } } @@ -998,35 +1212,9 @@ local({ # construct full libpath libpath <- file.path(root, prefix) - # attempt to load - if (renv_bootstrap_load(project, libpath, version)) - return(TRUE) - - # load failed; inform user we're about to bootstrap - prefix <- paste("# Bootstrapping renv", version) - postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") - header <- paste(prefix, postfix) - message(header) - - # perform bootstrap - bootstrap(version, libpath) - - # exit early if we're just testing bootstrap - if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) - return(TRUE) - - # try again to load - if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { - message("* Successfully installed and loaded renv ", version, ".") - return(renv::load()) - } - - # failed to download or load renv; warn the user - msg <- c( - "Failed to find an renv installation: the project will not be loaded.", - "Use `renv::activate()` to re-initialize the project." - ) + # run bootstrap code + renv_bootstrap_exec(project, libpath, version) - warning(paste(msg, collapse = "\n"), call. = FALSE) + invisible() }) diff --git a/renv/settings.json b/renv/settings.json new file mode 100644 index 00000000..a3f6796f --- /dev/null +++ b/renv/settings.json @@ -0,0 +1,17 @@ +{ + "bioconductor.version": "3.18", + "external.libraries": [], + "ignored.packages": [], + "package.dependency.fields": [ + "Imports", + "Depends", + "LinkingTo" + ], + "r.version": null, + "snapshot.type": "implicit", + "use.cache": true, + "vcs.ignore.cellar": true, + "vcs.ignore.library": true, + "vcs.ignore.local": true, + "vcs.manage.ignores": true +} diff --git a/scripts/create_browser_data.R b/scripts/create_browser_data.R new file mode 100644 index 00000000..2e92e6a8 --- /dev/null +++ b/scripts/create_browser_data.R @@ -0,0 +1,130 @@ +# create_browser_data.R ----------------------------------------------------------------------- + +# To run this script for a new dataset: +# - modify the "User parameters" section below (see the comments in that section) +# - Either run it using +# - `Rscript ./scripts/create_browser_data.R` at the command line +# - or `source("./scripts/create_browser_data.R")` in R +# - Once finished, this script will explain how to use the created figures within tfpbrowser. + +# Installation options +# - when on Windows, you will need the --no-lock option for installing packages so that any packages +# that require C source compilation are placed into writeable locations +options(INSTALL_opts = "--no-lock") + +# User parameters ----------------------------------------------------------------------------- + +# File paths can be specified either relative to the working directory, or as absolute paths +# +# 1) The scanner environment file ("path/to/scanner_output/scanner-env-YYYY-MM-DD.rds") +env_file <- file.path() + +# 2) The output directory for the treeviews (typically the parent of the 'scanner_output' directory) +output_dir <- file.path() + +# 3) Any non-default arguments for the `treeview()` function +treeview_args <- list( + # branch_cols = c("logistic_growth_rate", "clock_outlier"), + # mutations = c("S:A222V", "S:Y145H", "N:Q9L", "S:E484K"), + # lineages = c("AY\\.9", "AY\\.43", "AY\\.4\\.2"), + # output_format = c("rds", "html"), + # dendrogram_colours = c("#2166ac", "#738fc0", "#afbad4", "#e8e8e8", "#e0a9a4", "#ce6964", "#b2182b"), + # heatmap_width = 0.075, + # heatmap_offset = 8, + # heatmap_lab_offset = -6, + # heatmap_fill = c(`FALSE` = "grey90", `TRUE` = "grey70") +) + +# Script environment -------------------------------------------------------------------------- + +# Ensure that the R session used when running this script is closed before running the app, because +# this script runs in a defined environment that doesn't contain some of the packages needed by the +# app. +# +# Here we define a running environment that is compatible with the versions of ggplot2, ggiraph etc +# that are used when running the app. +# +# If the renv.lock for the app is updated, the versions of the packages defined here should be +# updated to be in-sync with the renv.lock. +# +# {tfpscanner} is not directly used by the app, so it isn't present in the renv.lock for the app. + +tfpbrowser_env <- jsonlite::read_json("renv.lock") + +required_packages <- c( + "BiocVersion", "fastmap", "ggplot2", "ggiraph", "ggtree", "rmarkdown" +) +required_versions <- Map( + function(package, pkg_details) { + paste0(package, "@", pkg_details[["Version"]]) + }, + required_packages, + tfpbrowser_env[["Packages"]][required_packages] +) + +# {BiocManager} will be loaded along with {renv} when an R session is started in this repository + +renv::use( + # The versions of these packages should match those used in the 'renv.lock' for tfpbrowser, to + # ensure that the figure objects created by tfpscanner can be imported into tfpbrowser + # + # - ggtree for Bioconductor 3.16 depends upon a specific (outdated) version of ggplot2; + # later versions of ggtree have been rewritten to use newer ggplot2 versions. So if you ever + # update Bioconductor/R versions, you should start using the ggtree from Bioconductor that uses + # the newer version of ggplot2 + # + # - we force {rmarkdown} installation despite it being a transitive-dependency of tfpscanner. + # Without forcing it's installation, create_browser_data() runs in an env with no rmarkdown + # namespace + + required_versions[["BiocVersion"]], + required_versions[["ggplot2"]], + required_versions[["fastmap"]], + required_versions[["ggiraph"]], + required_versions[["rmarkdown"]], + "YuLab-SMU/ggtree@daf3371", + # These packages are required implicitly by {tfpscanner}, but not by {tfpbrowser} + "svglite@2.1.3", + # This is the HEAD of `jumpingrivers:dev-202403` as of 2024-04-15 + # If the commit ID is absent, this will use the latest 'master' branch + # Including the commit ID allows us to use development-versions of the 'tfpscanner' package + "mrc-ide/tfpscanner@cff68e483226bebe35436ee527fc61dcb5671951", + library = normalizePath(file.path(tempdir(), "renv", "create_browser_data")) +) + +# Create the browser data / figures ----------------------------------------------------------- + +# Please don't edit this section + +# Arguments for `create_browser_data` +browser_args <- append( + list( + e0 = normalizePath(env_file), + output_dir = normalizePath(output_dir) + ), + treeview_args +) + +stopifnot(file.exists(browser_args$e0)) +stopifnot(dir.exists(browser_args$output_dir)) + +do.call( + tfpscanner::create_browser_data, + browser_args +) + +# How to use the new browser data ------------------------------------------------------------- + +app_message <- glue::glue(' +# ================================================================================ # +# To run the "tfpbrowser" app over this dataset, please perform the following from +# the "tfpbrowser" home directory in R: + +# Start a new session first +# - the environment for this script will interfere with that used by the app +Sys.setenv(APP_DATA_DIR = "{output_dir}") +pkgload::load_all() +run_app() +') + +message(app_message) diff --git a/tests/testthat/test-shinytest2.R b/tests/testthat/test-shinytest2.R index 373c5b83..c9d436dd 100644 --- a/tests/testthat/test-shinytest2.R +++ b/tests/testthat/test-shinytest2.R @@ -2,7 +2,8 @@ test_that("tfpbrowser app initial values are consistent", { if (interactive()) { shiny_app = tfpbrowser::run_app() app = shinytest2::AppDriver$new(shiny_app, - name = "tfpbrowser") + name = "tfpbrowser" + ) navbar_tab_items = app$get_text(".nav-item") observed_navbar_tab_items = stringr::str_squish(navbar_tab_items) expected_navbar_tab_items = c("Data", "About", "Tables", "Plots", "RDS Files") diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 00000000..097b2416 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/deploy.Rmd b/vignettes/deploy.Rmd new file mode 100644 index 00000000..7f761338 --- /dev/null +++ b/vignettes/deploy.Rmd @@ -0,0 +1,339 @@ +--- +title: "Deploying tfpbrowser" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Deploying tfpbrowser} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +## Example + +Here we will + +- run tfpscanner against a set of scanner output, +- configure tfpbrowser to use the newly created tfpscanner output +- deploy the app, along with the new data, to shinyapps.io + +We are following the workflow described in the README for {tfpbrowser}, but with a practical +example. + +In this example, we have: + +- a dataset in `~/temp-data/wcdemo/` and +- the repository for {tfpbrowser} in `~/github/imp/tfpbrowser` +- and are using `r R.version.string` + +```{r} +dirs = list( + data = "~/temp-data/wcdemo/", + repo = "~/github/imp/tfpbrowser/", + # A copy of the tfpscanner-processed data will be placed in + # this subdirectory of the tfpbrowser repository + deploy_data = "~/github/imp/tfpbrowser/deploy-data/wcdemo/" +) +``` + +### General workflow issues + +The following must be ran inside RStudio in the {tfpbrowser} repository/project and must be ran +using the R version specified above. There are very precise package-requirements that ensure the +data-processing is compatible with the app, and these can only be controlled from the {tfpbrowser} +project. + +We assume you have cloned the {tfpbrowser} repository to your machine (in this example it is at +`r dirs$repo`). Open RStudio and then open the {tfpbrowser} 'Project' (File -> Open Project; +navigate to the tfpbrowser repo and double click on `tfpbrowser.Rproj`). + +We will use the [{fs}](https://fs.r-lib.org/) package for working with the file system. + +You should see an {renv} environment gets activated on opening the {tfpbrowser} project. This is the +environment within which the app runs (a related, but separate environment is used for data +pre-processing, see below). + +```r +... R preamble ... +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +- Project '~/github/imp/tfpbrowser' loaded. [renv 1.0.7] +``` + +If you receive a message stating that: + +- "there is no package called 'renv'", you will need to install {renv} from CRAN + (install.packages("renv")) and then reopen the {tfpbrowser} project +- the renv environment is out of sync, you may need to restore the package-versions that are defined + in the lock file (`renv::restore()`). + +#### GitHub Personal-Access Token (PAT) + +Some of the packages used by tfpscanner during data pre-processing (`ggtree` and `tfpscanner` +itself) must be installed from GitHub while data processing is underway. To make this possible, you +will need a `GITHUB_PAT` variable to be defined - this is a personal token that you can obtain from +[github](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). +If you have access to the {tfpscanner} repository on GitHub, then you will be able to install it +using your personal access token. + +To make your PAT available to tfpbrowser, add a `.Renviron` file to the tfpbrowser project / +repository with your PAT as the value on the 'GITHUB_PAT' variable line. + +```bash +GITHUB_PAT=ghp_blahBlahBlah... +``` + +Do not commit your `.Renviron` file using git! This file stores variables / secrets that are +required when the app runs. The variables will differ from one deployment to another, and the +secrets should be secret! + +#### MPI + +`create_browser_data.R` calls `{tfpscanner}`, which imports the `{Rmpi}` package. MPI is a code +parallelisation tool and must be installed on your machine before `{Rmpi}` can be installed. So +before running the `create_browser_data` script. + +Instructions for installing {Rmpi} can be found [here](https://www.stats.uwo.ca/faculty/yu/Rmpi/). +MPI for Windows can be obtained from [Microsoft](https://learn.microsoft.com/en-us/message-passing-interface/microsoft-mpi). + +### The scanner dataset + +The contents of the scanner dataset directory are as follows: + +```r +fs::dir_tree(dirs$data, recurse=1) +~/temp-data/wcdemo +└── scanner_output + ├── 1601 + ├── ... + ├── 2194 + ├── scanner-2021-11-27.rds + └── scanner-env-2021-11-27.rds +``` + +The 'scanner-env' file and the contents of the `1601` to `2194` directories are needed for +tfpscanner to generate the files needed by tfpbrowser. + +The directory `r dirs$data` contains ~ 13MB of data before processing by tfpscanner. + +### Processing the scanner dataset + +We use the `./scripts/create_browser_data.R` script inside the {tfpbrowser} repository to +process the scanner data. + +There are three user-configurable parameters in that script (`env_file`, `output_dir`, +`treeview_args`). +We define the location of the `scanner-env-2021-11-27.rds` file and the output directory. + +The output directory must be the parent of the input `scanner_output` directory for now (that is, +`r dirs$data` in this example) because tfpbrowser requires additional files from the +`scanner_output` directory to run. + +We haven't modified the `treeview_args` parameter here, but this can be used to pass additional +arguments to `tfpscanner::treeview()`. + +After modifying the script in-place, the user-parameters section of `create_browser_data.R` looks +like this: + +```r +# User parameters ----------------------------------------------------------------------------- + +# File paths can be specified either relative to the working directory, or as absolute paths +# +# 1) The scanner environment file ("path/to/scanner_output/scanner-env-YYYY-MM-DD.rds") +env_file <- file.path("~/temp-data/wcdemo/scanner_output/scanner-env-2021-11-27.rds") + +# 2) The output directory for the treeviews (typically the parent of the 'scanner_output' directory) +output_dir <- file.path("~/temp-data/wcdemo") + +# 3) Any non-default arguments for the `treeview()` function +treeview_args <- list( + # unmodified +) +``` + +With these changes in place, the `create_browser_data.R` script can be ran. Either use `source("scripts/create_browser_data.R")` or open the script in RStudio and click the "Source" +button above the text editor for the script. + +The script runs in it's own environment and will install packages into a temporary location while +it is running. This process will fail if you haven't defined a `GITHUB_PAT` variable (see above). + +```r +source("~/github/imp/tfpbrowser/scripts/create_browser_data.R") + +#> The following loaded package(s) have been updated: +#> - BiocManager +#> Restart your R session to use the new versions. + +#> The following package(s) will be installed: +#> - ape [5.8] +#> - aplot [0.2.3] +#> - base64enc [0.1-3] +#> ... +#> # ================================================================================ # +#> # To run the "tfpbrowser" app over this dataset, please perform the following from +#> # the "tfpbrowser" home directory in R: + +#> # Start a new session first +#> # - the environment for this script will interfere with that used by the app +#> Sys.setenv(APP_DATA_DIR = "~/temp-data/wcdemo") +#> pkgload::load_all() +#> run_app() +``` + +After running `create_browser_data.R`, the data directory should contain additional entries: + +```r +fs::dir_tree(dirs$data, recurse=1) +~/temp-data/wcdemo/ +├── mutations +│ ├── all_mutations.csv +│ └── defining_mutations.csv +├── scanner_output +│ ├── 1601 +│ ├── ... +│ ├── 2194 +│ ├── scanner-2021-11-27.rds +│ └── scanner-env-2021-11-27.rds +├── sequences +│ └── all_sequences.csv +└── treeview + ├── node_lookup + ├── ... + └── tree-sequences.rds +``` + +The `scanner_output` subdirectory is unmodified by the workflow, but some additional subdirectories +have been added (`mutations`, `sequences`, `treeview`). + +The data directory now contains ~ 33MB. + +Whenever you run the `create_browser_data.R` script, you must restart your R session afterwards. So, +we restarted R from inside RStudio (`Session` -> `Restart R`). + +### Integrating the scanner dataset into tfpbrowser + +We want to deploy the app to shinyapps.io. When you do this a single directory is uploaded to +shinyapps.io and if you want to embed data with the app, that data must be in the directory that +you upload (unless it is accessed via an API, URL or from another R package). + +We will put the contents of the `r dirs$data` directory into the `./deploy-data/wcdemo/` +directory of our app and then configure the app to use this directory when it is deployed. + +In a new R session (with the `dirs` variable, above, redefined), we can copy the directory contents +as follows: + +```r +fs::dir_copy( + path = dirs$data, + new_path = dirs$deploy_data +) +``` + +```r +fs::dir_tree( + dirs$deploy_data, + recurse = 0 +) +``` + +```r +#> ~/github/imp/tfpbrowser/deploy-data/wcdemo/ +#> ├── mutations +#> ├── scanner_output +#> ├── sequences +#> └── treeview +``` + +### Configuring tfpbrowser + +By default, tfpbrowser presents the scanner data that is found at `./inst/app/www/data/`. But the +files in this directory are hard to update and to keep in-sync with the app's working environment. + +To present a dataset from a different directory, you can configure {tfpbrowser} using an environment +variable. + +In the `.Renviron` file, add a line that defines where the `deploy-data/wcdemo/` directory is, +relative to the repository root and call this variable `APP_DATA_DIR`. + +```bash +# ./.Renviron +APP_DATA_DIR=./deploy-data/wcdemo/ +GITHUB_PAT=ghp_..... +``` + +This environment variable is used by tfpbrowser to find the data for presentation. Some of the files +within that directory are also served to the user's browser while the app runs. + +When you change the `.Renviron` file, you need to restart your R session before those changes affect +your R session. So we restarted R (`Session` -> `Restart R`) and then checked that the app runs +locally: + +```r +pkgload::load_all() +run_app() +``` + +The `.Renviron` file will be sent to shinyapps.io during deployment, so the data configuration will +be sent there too. + +### Deploying tfpbrowser + +We deploy the app to shinyapps.io using the {rsconnect} package. That package is not included in the +renv.lock file, so you may need to install it prior to deployment: + +```r +renv::install("rsconnect") +``` + +If you haven't deployed from your machine before, you will need to add some (secrets) from your +shinyapps.io account. Log into shinyapps.io and go to the "Account -> Tokens" page. Click +"Add Token", then "Show" to view the code needed to configure your connection to shinyapps.io from +your local machine. Copy the code revealed. Then run that in your R session (including the secret): + +```r +rsconnect::setAccountInfo( + name='my-user-name', + token='RANDOM123ALPHANUMERIC', + secret='some-secret-value' +) +``` + +Then we deployed the app using the following command: + +```r +rsconnect::deployApp() +``` + +This uploaded all the files in the repository, which is unnecessary. RStudio provides a second +method for deploying a shiny app to shinyapps.io. Assuming your account info and .Renviron file have +been set up (as above) run the {tfpbrowser} app + +```r +pkgload::load_all() +run_app() +``` + +Then click on the "Publish" or "Republish" button in the RStudio browser window that opens. +A "Publish to Server" dialog box will open, and within this you can select/deselect which files to +upload to shinyapps.io along with your app. You shouldn't upload any tests, un-needed datasets, +github workflows. + +The minimum files you will need for deployment are (`.Rprofile`, `.Renviron`, `app.R`, +`DESCRIPTION`, `NAMESPACE`, `renv.lock`, and the contents of `inst/` and `R/`). If the data you wish +to deploy with the app is in some other directory, this must also be selected for upload. + +You may receive an warning message indicating that (file)paths outside of the project are referred +to by some scripts within this project. These arise in `vignettes/deploy.Rmd` and +`scripts/create_browser_data.R` and (provided these are the only files that refer to non-embedded +filepaths) you can safely ignore that warning (`deploy.Rmd` and `create_browser_data.R` needn't +be uploaded to shinyapps.io anyway). + +Deployment may take a long time (around 5 minutes for deployment with the `wcdemo` example data).