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'",
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"),
label = "Select comparison genes",
choices = NULL,
multiple = TRUE
label = "Enter comparison genes",
height = "250px"
)
)
)
@ -37,17 +44,6 @@ comparison_editor_ui <- function(id) {
# @return A reactive containing the comparison gene IDs.
comparison_editor_server <- function(id, preset) {
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({
if (input$comparison_genes == "none") {
NULL
@ -64,7 +60,12 @@ comparison_editor_server <- function(id, preset) {
} else if (input$comparison_genes == "suggested") {
genes[suggested == TRUE, id]
} 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'",
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"),
label = "Select reference genes",
choices = NULL,
multiple = TRUE
label = "Enter reference genes",
height = "250px"
)
),
selectInput(
@ -78,10 +85,6 @@ preset_editor_server <- function(id) {
species_choices <- species$id
names(species_choices) <- species$name
known_genes <- genes[name != ""]
gene_choices <- known_genes$id
names(gene_choices) <- known_genes$name
updateSelectizeInput(
session,
"custom_species",
@ -89,13 +92,6 @@ preset_editor_server <- function(id) {
server = TRUE
)
updateSelectizeInput(
session,
"custom_reference_genes",
choices = gene_choices,
server = TRUE
)
current_preset <- reactiveVal(geposan::preset(
methods = method_ids,
species_ids = species$id,
@ -118,7 +114,12 @@ preset_editor_server <- function(id) {
} else if (input$reference_genes == "verified") {
genes[verified == TRUE, id]
} 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(