2021-10-21 14:56:19 +02:00
|
|
|
# Create a preset editor.
|
|
|
|
|
preset_editor_ui <- 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
|
|
|
|
|
|
|
|
|
|
verticalLayout(
|
2021-11-15 10:22:28 +01:00
|
|
|
h3("Inputs"),
|
2021-10-21 14:56:19 +02:00
|
|
|
selectInput(
|
2021-11-15 10:22:28 +01:00
|
|
|
NS(id, "species"),
|
|
|
|
|
"Species to include",
|
2021-10-21 14:56:19 +02:00
|
|
|
choices = list(
|
|
|
|
|
"Replicatively aging species" = "replicative",
|
|
|
|
|
"All species" = "all",
|
|
|
|
|
"Customize" = "custom"
|
|
|
|
|
)
|
|
|
|
|
),
|
2021-11-02 14:42:52 +01:00
|
|
|
tabsetPanel(
|
2021-11-15 10:22:28 +01:00
|
|
|
id = NS(id, "custom_species_panel"),
|
2021-11-02 14:42:52 +01:00
|
|
|
type = "hidden",
|
2021-11-15 10:22:28 +01:00
|
|
|
tabPanelBody(value = "hide"),
|
2021-11-02 14:42:52 +01:00
|
|
|
tabPanelBody(
|
2021-11-15 10:22:28 +01:00
|
|
|
value = "show",
|
2021-11-02 14:42:52 +01:00
|
|
|
shinyWidgets::pickerInput(
|
2021-11-15 10:22:28 +01:00
|
|
|
inputId = NS(id, "custom_species"),
|
2021-11-02 14:42:52 +01:00
|
|
|
choices = species_choices,
|
|
|
|
|
options = list(
|
|
|
|
|
"actions-box" = TRUE,
|
|
|
|
|
"live-search" = TRUE
|
|
|
|
|
),
|
|
|
|
|
multiple = TRUE
|
2021-11-15 10:22:28 +01:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
selectInput(
|
|
|
|
|
NS(id, "reference_genes"),
|
|
|
|
|
"Reference genes",
|
|
|
|
|
choices = list(
|
|
|
|
|
"Verified or suggested TPE-OLD genes" = "tpeold",
|
|
|
|
|
"Only verified TPE-OLD genes" = "verified",
|
|
|
|
|
"Customize" = "custom"
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
tabsetPanel(
|
|
|
|
|
id = NS(id, "custom_reference_genes_panel"),
|
|
|
|
|
type = "hidden",
|
|
|
|
|
tabPanelBody(value = "hide"),
|
|
|
|
|
tabPanelBody(
|
|
|
|
|
value = "show",
|
2021-11-02 14:42:52 +01:00
|
|
|
shinyWidgets::pickerInput(
|
2021-11-15 10:22:28 +01:00
|
|
|
inputId = NS(id, "custom_reference_genes"),
|
2021-11-02 14:42:52 +01:00
|
|
|
choices = gene_choices,
|
|
|
|
|
options = list(
|
|
|
|
|
"actions-box" = TRUE,
|
|
|
|
|
"live-search" = TRUE
|
|
|
|
|
),
|
|
|
|
|
multiple = TRUE
|
2021-11-15 10:22:28 +01:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
2021-11-19 15:38:46 +01:00
|
|
|
selectInput(
|
|
|
|
|
NS(id, "optimization_target"),
|
|
|
|
|
"Optimization target",
|
|
|
|
|
choices = list(
|
|
|
|
|
"Mean rank of reference genes" = "mean",
|
2021-11-21 23:57:03 +01:00
|
|
|
"Median rank of reference genes" = "median",
|
2021-11-19 15:38:46 +01:00
|
|
|
"First rank of reference genes" = "min",
|
|
|
|
|
"Last rank of reference genes" = "max"
|
|
|
|
|
)
|
|
|
|
|
),
|
2021-11-15 10:22:28 +01:00
|
|
|
tabsetPanel(
|
|
|
|
|
id = NS(id, "apply_panel"),
|
|
|
|
|
type = "hidden",
|
|
|
|
|
tabPanelBody(value = "hide"),
|
|
|
|
|
tabPanelBody(
|
|
|
|
|
value = "show",
|
2021-11-02 14:42:52 +01:00
|
|
|
actionButton(
|
|
|
|
|
NS(id, "apply_button"),
|
|
|
|
|
"Perform analysis",
|
|
|
|
|
class = "btn-primary",
|
|
|
|
|
style = "margin-top: 16px; margin-bottom: 16px"
|
|
|
|
|
)
|
2021-10-21 14:56:19 +02:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Create a server for the preset editor.
|
|
|
|
|
#
|
|
|
|
|
# @param id ID for namespacing the inputs and outputs.
|
|
|
|
|
#
|
|
|
|
|
# @return A reactive containing the preset.
|
|
|
|
|
preset_editor_server <- function(id) {
|
|
|
|
|
moduleServer(id, function(input, output, session) {
|
2021-11-15 10:22:28 +01:00
|
|
|
current_preset <- reactiveVal(geposan::preset(
|
|
|
|
|
methods = method_ids,
|
|
|
|
|
species_ids = species[replicative == TRUE, id],
|
|
|
|
|
gene_ids = genes$id,
|
2021-11-19 15:38:46 +01:00
|
|
|
reference_gene_ids = genes[suggested | verified == TRUE, id],
|
|
|
|
|
optimization_target = "mean"
|
2021-11-15 10:22:28 +01:00
|
|
|
))
|
2021-10-21 14:56:19 +02:00
|
|
|
|
2021-11-15 10:22:28 +01:00
|
|
|
observeEvent(input$species, {
|
|
|
|
|
if (input$species == "custom") {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"custom_species_panel",
|
|
|
|
|
selected = "show"
|
|
|
|
|
)
|
2021-11-02 14:42:52 +01:00
|
|
|
} else {
|
2021-11-15 10:22:28 +01:00
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"custom_species_panel",
|
|
|
|
|
selected = "hide"
|
|
|
|
|
)
|
2021-10-21 14:56:19 +02:00
|
|
|
}
|
2021-11-15 10:22:28 +01:00
|
|
|
})
|
2021-11-02 14:42:52 +01:00
|
|
|
|
2021-11-15 10:22:28 +01:00
|
|
|
observeEvent(input$reference_genes, {
|
|
|
|
|
if (input$reference_genes == "custom") {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"custom_reference_genes_panel",
|
|
|
|
|
selected = "show"
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"custom_reference_genes_panel",
|
|
|
|
|
selected = "hide"
|
|
|
|
|
)
|
|
|
|
|
}
|
2021-10-21 14:56:19 +02:00
|
|
|
})
|
|
|
|
|
|
2021-11-15 10:22:28 +01:00
|
|
|
new_preset <- reactive({
|
2021-11-18 14:10:06 +01:00
|
|
|
species_ids <- if (input$species == "replicative") {
|
|
|
|
|
species[replicative == TRUE, id]
|
|
|
|
|
} else if (input$species == "all") {
|
|
|
|
|
species$id
|
|
|
|
|
} else {
|
|
|
|
|
input$custom_species
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 10:22:28 +01:00
|
|
|
reference_gene_ids <- if (input$reference_genes == "tpeold") {
|
|
|
|
|
genes[verified | suggested == TRUE, id]
|
|
|
|
|
} else if (input$reference_genes == "verified") {
|
|
|
|
|
genes[verified == TRUE, id]
|
|
|
|
|
} else {
|
|
|
|
|
input$custom_reference_genes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
geposan::preset(
|
2021-11-14 22:34:46 +01:00
|
|
|
methods = method_ids,
|
2021-11-18 14:10:06 +01:00
|
|
|
species_ids = species_ids,
|
2021-11-14 22:34:46 +01:00
|
|
|
gene_ids = genes$id,
|
2021-11-19 15:38:46 +01:00
|
|
|
reference_gene_ids = reference_gene_ids,
|
|
|
|
|
optimization_target = input$optimization_target
|
2021-11-15 10:22:28 +01:00
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
observeEvent(
|
|
|
|
|
{ # nolint
|
|
|
|
|
current_preset()
|
|
|
|
|
new_preset()
|
|
|
|
|
},
|
|
|
|
|
{ # nolint
|
|
|
|
|
if (rlang::hash(new_preset()) !=
|
|
|
|
|
rlang::hash(current_preset())) {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"apply_panel",
|
|
|
|
|
selected = "show"
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
updateTabsetPanel(
|
|
|
|
|
session,
|
|
|
|
|
"apply_panel",
|
|
|
|
|
selected = "hide"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
observeEvent(input$apply_button, {
|
|
|
|
|
current_preset(new_preset())
|
2021-10-21 14:56:19 +02:00
|
|
|
})
|
|
|
|
|
|
2021-11-15 10:22:28 +01:00
|
|
|
current_preset
|
2021-10-21 14:56:19 +02:00
|
|
|
})
|
|
|
|
|
}
|