Separate reference and comparison gene sets

This commit is contained in:
Elias Projahn 2022-08-18 09:02:53 +02:00
parent 4e0eb523ea
commit 04ab4f4a82
5 changed files with 28 additions and 19 deletions

19
R/app.R
View file

@ -1,13 +1,14 @@
#' Run the application server. #' Run the application server.
#' #'
#' @param gene_sets A list of predefined gene sets. This should be a named list #' @param reference_gene_sets A list of predefined gene sets to be used as
#' containing vectors of gene IDs for each set. The names will be used to #' reference genes. This should be a named list containing vectors of gene IDs
#' present the gene set throughout the user interface. You have to provide *at #' for each set. You have to provide *at least one gene set* which will be
#' least one gene set* which will be selected as the initial reference gene #' selected as the initial reference gene set.
#' set.
#' @param species_sets A list of predefined species sets. This should be a named #' @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 #' list containing vectors of species IDs for each set. The names will be used
#' to present the species set throughout the user interface. #' 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 #' @param locked Whether the application should be locked and prohibit
#' performing custom analyses. If this is set to `TRUE`, only the predefined #' performing custom analyses. If this is set to `TRUE`, only the predefined
#' gene and species sets are available for customizing the analysis. This may #' 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. #' @param port The port to serve the application on.
#' #'
#' @export #' @export
run_app <- function(gene_sets, run_app <- function(reference_gene_sets,
species_sets = NULL, species_sets = NULL,
comparison_gene_sets = NULL,
locked = FALSE, locked = FALSE,
title = "Gene Position Analysis", title = "Gene Position Analysis",
port = 3464) { 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. # These function calls make the required java scripts available.
shinyjs::useShinyjs() shinyjs::useShinyjs()
@ -29,8 +31,9 @@ run_app <- function(gene_sets,
# Bundle of global options to redue broilerplate. # Bundle of global options to redue broilerplate.
options <- list( options <- list(
gene_sets = gene_sets, reference_gene_sets = reference_gene_sets,
species_sets = species_sets, species_sets = species_sets,
comparison_gene_sets = comparison_gene_sets,
locked = locked, locked = locked,
title = title title = title
) )

View file

@ -11,7 +11,7 @@ comparison_editor_ui <- function(id, options) {
choices = c( choices = c(
"Your genes", "Your genes",
"Random genes", "Random genes",
names(options$gene_sets) names(options$comparison_gene_sets)
) )
), ),
conditionalPanel( conditionalPanel(
@ -47,7 +47,7 @@ comparison_editor_server <- function(id, preset, options) {
} else if (input$comparison_genes == "Your genes") { } else if (input$comparison_genes == "Your genes") {
custom_gene_ids() custom_gene_ids()
} else { } else {
options$gene_sets[[input$comparison_genes]] options$comparison_gene_sets[[input$comparison_genes]]
} }
}) })
}) })

View file

@ -44,7 +44,10 @@ input_page_ui <- function(id, options) {
#' @noRd #' @noRd
input_page_server <- function(id, options) { input_page_server <- function(id, options) {
moduleServer(id, function(input, output, session) { 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) potential_preset <- preset_editor_server("preset_editor", options)
output$positions_plot <- plotly::renderPlotly({ output$positions_plot <- plotly::renderPlotly({

View file

@ -8,7 +8,7 @@
#' @noRd #' @noRd
preset_editor_ui <- function(id, options) { preset_editor_ui <- function(id, options) {
species_choices <- c("All species", names(options$species_sets)) 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) { if (!options$locked) {
species_choices <- c(species_choices, "Customize") species_choices <- c(species_choices, "Customize")
@ -97,7 +97,7 @@ preset_editor_server <- function(id, options) {
reference_gene_ids <- if (input$reference_genes == "Customize") { reference_gene_ids <- if (input$reference_genes == "Customize") {
custom_gene_ids() custom_gene_ids()
} else { } else {
options$gene_sets[[input$reference_genes]] options$reference_gene_sets[[input$reference_genes]]
} }
species_ids <- if (input$species == "All species") { species_ids <- if (input$species == "All species") {

View file

@ -5,24 +5,27 @@
\title{Run the application server.} \title{Run the application server.}
\usage{ \usage{
run_app( run_app(
gene_sets, reference_gene_sets,
species_sets = NULL, species_sets = NULL,
comparison_gene_sets = NULL,
locked = FALSE, locked = FALSE,
title = "Gene Position Analysis", title = "Gene Position Analysis",
port = 3464 port = 3464
) )
} }
\arguments{ \arguments{
\item{gene_sets}{A list of predefined gene sets. This should be a named list \item{reference_gene_sets}{A list of predefined gene sets to be used as
containing vectors of gene IDs for each set. The names will be used to reference genes. This should be a named list containing vectors of gene IDs
present the gene set throughout the user interface. You have to provide \emph{at for each set. You have to provide \emph{at least one gene set} which will be
least one gene set} which will be selected as the initial reference gene selected as the initial reference gene set.}
set.}
\item{species_sets}{A list of predefined species sets. This should be a named \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 list containing vectors of species IDs for each set. The names will be used
to present the species set throughout the user interface.} 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 \item{locked}{Whether the application should be locked and prohibit
performing custom analyses. If this is set to \code{TRUE}, only the predefined 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 gene and species sets are available for customizing the analysis. This may