Separate reference and comparison gene sets

This commit is contained in:
Elias Projahn 2022-08-18 09:02:53 +02:00
parent 7f0090620b
commit e9033883a5
5 changed files with 28 additions and 19 deletions

19
R/app.R
View file

@ -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
)

View file

@ -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]]
}
})
})

View file

@ -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({

View file

@ -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") {

View file

@ -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