From 04ab4f4a82f1c0e8ecfed0273f929a07ef62610a Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Thu, 18 Aug 2022 09:02:53 +0200 Subject: [PATCH] Separate reference and comparison gene sets --- R/app.R | 19 +++++++++++-------- R/comparison_editor.R | 4 ++-- R/input_page.R | 5 ++++- R/preset_editor.R | 4 ++-- man/run_app.Rd | 15 +++++++++------ 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/R/app.R b/R/app.R index cd70f57..3612932 100644 --- a/R/app.R +++ b/R/app.R @@ -1,13 +1,14 @@ #' Run the application server. #' -#' @param gene_sets A list of predefined gene sets. This should be a named list -#' containing vectors of gene IDs for each set. The names will be used to -#' present the gene set throughout the user interface. You have to provide *at -#' least one gene set* which will be selected as the initial reference gene -#' set. +#' @param reference_gene_sets A list of predefined gene sets to be used as +#' reference genes. This should be a named list containing vectors of gene IDs +#' for each set. You have to provide *at least one gene set* which will be +#' selected as the initial reference gene set. #' @param species_sets A list of predefined species sets. This should be a named #' list containing vectors of species IDs for each set. The names will be used #' to present the species set throughout the user interface. +#' @param comparison_gene_sets A named list of predefined gene sets to be used +#' as comparison genes. #' @param locked Whether the application should be locked and prohibit #' performing custom analyses. If this is set to `TRUE`, only the predefined #' gene and species sets are available for customizing the analysis. This may @@ -16,12 +17,13 @@ #' @param port The port to serve the application on. #' #' @export -run_app <- function(gene_sets, +run_app <- function(reference_gene_sets, species_sets = NULL, + comparison_gene_sets = NULL, locked = FALSE, title = "Gene Position Analysis", port = 3464) { - stopifnot(!is.null(gene_sets) & !is.null(gene_sets[[1]])) + stopifnot(!is.null(reference_gene_sets) & !is.null(reference_gene_sets[[1]])) # These function calls make the required java scripts available. shinyjs::useShinyjs() @@ -29,8 +31,9 @@ run_app <- function(gene_sets, # Bundle of global options to redue broilerplate. options <- list( - gene_sets = gene_sets, + reference_gene_sets = reference_gene_sets, species_sets = species_sets, + comparison_gene_sets = comparison_gene_sets, locked = locked, title = title ) diff --git a/R/comparison_editor.R b/R/comparison_editor.R index b576847..cc7800d 100644 --- a/R/comparison_editor.R +++ b/R/comparison_editor.R @@ -11,7 +11,7 @@ comparison_editor_ui <- function(id, options) { choices = c( "Your genes", "Random genes", - names(options$gene_sets) + names(options$comparison_gene_sets) ) ), conditionalPanel( @@ -47,7 +47,7 @@ comparison_editor_server <- function(id, preset, options) { } else if (input$comparison_genes == "Your genes") { custom_gene_ids() } else { - options$gene_sets[[input$comparison_genes]] + options$comparison_gene_sets[[input$comparison_genes]] } }) }) diff --git a/R/input_page.R b/R/input_page.R index 079fb25..7d3cbbc 100644 --- a/R/input_page.R +++ b/R/input_page.R @@ -44,7 +44,10 @@ input_page_ui <- function(id, options) { #' @noRd input_page_server <- function(id, options) { moduleServer(id, function(input, output, session) { - current_preset <- reactiveVal(geposan::preset(options$gene_sets[[1]])) + current_preset <- reactiveVal( + geposan::preset(options$reference_gene_sets[[1]]) + ) + potential_preset <- preset_editor_server("preset_editor", options) output$positions_plot <- plotly::renderPlotly({ diff --git a/R/preset_editor.R b/R/preset_editor.R index 261c92a..216c182 100644 --- a/R/preset_editor.R +++ b/R/preset_editor.R @@ -8,7 +8,7 @@ #' @noRd preset_editor_ui <- function(id, options) { species_choices <- c("All species", names(options$species_sets)) - gene_choices <- names(options$gene_sets) + gene_choices <- names(options$reference_gene_sets) if (!options$locked) { species_choices <- c(species_choices, "Customize") @@ -97,7 +97,7 @@ preset_editor_server <- function(id, options) { reference_gene_ids <- if (input$reference_genes == "Customize") { custom_gene_ids() } else { - options$gene_sets[[input$reference_genes]] + options$reference_gene_sets[[input$reference_genes]] } species_ids <- if (input$species == "All species") { diff --git a/man/run_app.Rd b/man/run_app.Rd index dc5c920..02b9add 100644 --- a/man/run_app.Rd +++ b/man/run_app.Rd @@ -5,24 +5,27 @@ \title{Run the application server.} \usage{ run_app( - gene_sets, + reference_gene_sets, species_sets = NULL, + comparison_gene_sets = NULL, locked = FALSE, title = "Gene Position Analysis", port = 3464 ) } \arguments{ -\item{gene_sets}{A list of predefined gene sets. This should be a named list -containing vectors of gene IDs for each set. The names will be used to -present the gene set throughout the user interface. You have to provide \emph{at -least one gene set} which will be selected as the initial reference gene -set.} +\item{reference_gene_sets}{A list of predefined gene sets to be used as +reference genes. This should be a named list containing vectors of gene IDs +for each set. You have to provide \emph{at least one gene set} which will be +selected as the initial reference gene set.} \item{species_sets}{A list of predefined species sets. This should be a named list containing vectors of species IDs for each set. The names will be used to present the species set throughout the user interface.} +\item{comparison_gene_sets}{A named list of predefined gene sets to be used +as comparison genes.} + \item{locked}{Whether the application should be locked and prohibit performing custom analyses. If this is set to \code{TRUE}, only the predefined gene and species sets are available for customizing the analysis. This may