gsea: Properly show empty results

This commit is contained in:
Elias Projahn 2022-08-30 10:13:28 +02:00
parent 49d5a3f281
commit f0a8bce297

View file

@ -17,6 +17,11 @@ gsea_ui <- function(id) {
style = "margin-left: 16px" style = "margin-left: 16px"
) )
), ),
tabsetPanel(
id = NS(id, "results"),
type = "hidden",
tabPanelBody(
"some",
div( div(
style = "margin-top: 16px", style = "margin-top: 16px",
plotly::plotlyOutput(NS(id, "plot")), plotly::plotlyOutput(NS(id, "plot")),
@ -25,6 +30,21 @@ gsea_ui <- function(id) {
style = "margin-top: 16px", style = "margin-top: 16px",
DT::DTOutput(NS(id, "details")) DT::DTOutput(NS(id, "details"))
) )
),
tabPanelBody(
"none",
div(
style = "margin-top: 32px",
h5("No results"),
div(
"The enrichment analysis using g:Profiler yielded no results. ",
"You can change the parameters of the ranking and the filter ",
"criteria. Click the \"Update analysis\" button to rerun the ",
"analysis."
)
)
)
)
) )
} }
@ -55,15 +75,32 @@ gsea_server <- function(id, ranking) {
bindCache(ranking_filtered()) |> bindCache(ranking_filtered()) |>
bindEvent(input$gsea_run, ignoreNULL = FALSE) bindEvent(input$gsea_run, ignoreNULL = FALSE)
observe({
updateTabsetPanel(
session,
"results",
selected = if (!is.null(gsea_analysis()$result)) {
"some"
} else {
"none"
}
)
})
output$plot <- plotly::renderPlotly({ output$plot <- plotly::renderPlotly({
if (!is.null(gsea_analysis()$result)) {
gprofiler2::gostplot( gprofiler2::gostplot(
gsea_analysis(), gsea_analysis(),
capped = FALSE, capped = FALSE,
interactive = TRUE interactive = TRUE
) )
} else {
plotly::plotly_empty()
}
}) })
output$details <- DT::renderDT({ output$details <- DT::renderDT({
if (!is.null(gsea_analysis()$result)) {
data <- data.table(gsea_analysis()$result) data <- data.table(gsea_analysis()$result)
setorder(data, p_value) setorder(data, p_value)
@ -100,6 +137,9 @@ gsea_server <- function(id, ranking) {
c("total_ratio", "query_ratio", "increase"), c("total_ratio", "query_ratio", "increase"),
digits = 2 digits = 2
) )
} else {
DT::datatable(data.table())
}
}) })
}) })
} }