Allow manually entering genes

This commit is contained in:
Elias Projahn 2021-12-15 12:41:35 +01:00
parent 7bef0f3bda
commit 663128271e
2 changed files with 34 additions and 32 deletions

View file

@ -19,11 +19,18 @@ comparison_editor_ui <- function(id) {
"input['%s'] == 'custom'", "input['%s'] == 'custom'",
NS(id, "comparison_genes") NS(id, "comparison_genes")
), ),
selectizeInput( selectInput(
NS(id, "identifier_type"),
"Gene identifiers",
choices = list(
"HGNC symbols" = "hgnc",
"Ensembl gene IDs" = "ensembl"
)
),
textAreaInput(
inputId = NS(id, "custom_comparison_genes"), inputId = NS(id, "custom_comparison_genes"),
label = "Select comparison genes", label = "Enter comparison genes",
choices = NULL, height = "250px"
multiple = TRUE
) )
) )
) )
@ -37,17 +44,6 @@ comparison_editor_ui <- function(id) {
# @return A reactive containing the comparison gene IDs. # @return A reactive containing the comparison gene IDs.
comparison_editor_server <- function(id, preset) { comparison_editor_server <- function(id, preset) {
moduleServer(id, function(input, output, session) { moduleServer(id, function(input, output, session) {
known_genes <- genes[name != ""]
gene_choices <- known_genes$id
names(gene_choices) <- known_genes$name
updateSelectizeInput(
session,
"custom_comparison_genes",
choices = gene_choices,
server = TRUE
)
reactive({ reactive({
if (input$comparison_genes == "none") { if (input$comparison_genes == "none") {
NULL NULL
@ -64,7 +60,12 @@ comparison_editor_server <- function(id, preset) {
} else if (input$comparison_genes == "suggested") { } else if (input$comparison_genes == "suggested") {
genes[suggested == TRUE, id] genes[suggested == TRUE, id]
} else { } else {
input$custom_comparison_genes inputs <- strsplit(input$custom_comparison_genes, "\\s+")[[1]]
if (input$identifier_type == "hgnc") {
geposan::genes[name %chin% inputs, id]
} else {
geposan::genes[id %chin% inputs, id]
}
} }
}) })
}) })

View file

@ -34,11 +34,18 @@ preset_editor_ui <- function(id) {
"input['%s'] == 'custom'", "input['%s'] == 'custom'",
NS(id, "reference_genes") NS(id, "reference_genes")
), ),
selectizeInput( selectInput(
NS(id, "identifier_type"),
"Gene identifiers",
choices = list(
"HGNC symbols" = "hgnc",
"Ensembl gene IDs" = "ensembl"
)
),
textAreaInput(
inputId = NS(id, "custom_reference_genes"), inputId = NS(id, "custom_reference_genes"),
label = "Select reference genes", label = "Enter reference genes",
choices = NULL, height = "250px"
multiple = TRUE
) )
), ),
selectInput( selectInput(
@ -78,10 +85,6 @@ preset_editor_server <- function(id) {
species_choices <- species$id species_choices <- species$id
names(species_choices) <- species$name names(species_choices) <- species$name
known_genes <- genes[name != ""]
gene_choices <- known_genes$id
names(gene_choices) <- known_genes$name
updateSelectizeInput( updateSelectizeInput(
session, session,
"custom_species", "custom_species",
@ -89,13 +92,6 @@ preset_editor_server <- function(id) {
server = TRUE server = TRUE
) )
updateSelectizeInput(
session,
"custom_reference_genes",
choices = gene_choices,
server = TRUE
)
current_preset <- reactiveVal(geposan::preset( current_preset <- reactiveVal(geposan::preset(
methods = method_ids, methods = method_ids,
species_ids = species$id, species_ids = species$id,
@ -118,7 +114,12 @@ preset_editor_server <- function(id) {
} else if (input$reference_genes == "verified") { } else if (input$reference_genes == "verified") {
genes[verified == TRUE, id] genes[verified == TRUE, id]
} else { } else {
input$custom_reference_genes inputs <- strsplit(input$custom_reference_genes, "\\s+")[[1]]
if (input$identifier_type == "hgnc") {
geposan::genes[name %chin% inputs, id]
} else {
geposan::genes[id %chin% inputs, id]
}
} }
geposan::preset( geposan::preset(