mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 11:17:24 +01:00
Move filtering to tabs that use it
This commit is contained in:
parent
9fb6ca428e
commit
447fdfab4f
4 changed files with 87 additions and 85 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
#' @noRd
|
#' @noRd
|
||||||
details_ui <- function(id) {
|
details_ui <- function(id) {
|
||||||
verticalLayout(
|
verticalLayout(
|
||||||
|
filters_ui(NS(id, "filters")),
|
||||||
div(
|
div(
|
||||||
style = "margin-top: 16px",
|
style = "margin-top: 16px",
|
||||||
splitLayout(
|
splitLayout(
|
||||||
|
|
@ -20,12 +21,13 @@ details_ui <- function(id) {
|
||||||
#' Server for the detailed results panel.
|
#' Server for the detailed results panel.
|
||||||
#'
|
#'
|
||||||
#' @param options Global options for the application.
|
#' @param options Global options for the application.
|
||||||
#' @param filtered_results A reactive containing the prefiltered results to be
|
#' @param results A reactive containing the results to be displayed.
|
||||||
#' displayed.
|
|
||||||
#'
|
#'
|
||||||
#' @noRd
|
#' @noRd
|
||||||
details_server <- function(id, options, filtered_results) {
|
details_server <- function(id, options, results) {
|
||||||
moduleServer(id, function(input, output, session) {
|
moduleServer(id, function(input, output, session) {
|
||||||
|
filtered_results <- filters_server("filters", results)
|
||||||
|
|
||||||
output$copy <- renderUI({
|
output$copy <- renderUI({
|
||||||
results <- filtered_results()
|
results <- filtered_results()
|
||||||
|
|
||||||
|
|
|
||||||
43
R/filters.R
43
R/filters.R
|
|
@ -1,16 +1,19 @@
|
||||||
# Construct UI for the filter editor.
|
# Construct UI for the filter editor.
|
||||||
filters_ui <- function(id) {
|
filters_ui <- function(id) {
|
||||||
|
div(
|
||||||
|
class = "well",
|
||||||
|
style = "margin-top: 24px; margin-bottom: 16px; padding-top: 24px;",
|
||||||
verticalLayout(
|
verticalLayout(
|
||||||
h3("Filter criteria"),
|
radioButtons(
|
||||||
selectInput(
|
|
||||||
NS(id, "method"),
|
NS(id, "method"),
|
||||||
"Filter method",
|
label = NULL,
|
||||||
choices = list(
|
choices = list(
|
||||||
"Percentiles" = "percentile",
|
"Filter percentiles" = "percentile",
|
||||||
"Scores" = "score",
|
"Filter scores" = "score",
|
||||||
"Ranks" = "rank",
|
"Filter ranks" = "rank",
|
||||||
"None" = "none"
|
"No filtering" = "none"
|
||||||
)
|
),
|
||||||
|
inline = TRUE
|
||||||
),
|
),
|
||||||
tabsetPanel(
|
tabsetPanel(
|
||||||
id = NS(id, "sliders"),
|
id = NS(id, "sliders"),
|
||||||
|
|
@ -19,7 +22,7 @@ filters_ui <- function(id) {
|
||||||
value = "percentile",
|
value = "percentile",
|
||||||
sliderInput(
|
sliderInput(
|
||||||
NS(id, "percentile"),
|
NS(id, "percentile"),
|
||||||
label = "Included percentiles",
|
label = NULL,
|
||||||
post = "%",
|
post = "%",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 100,
|
max = 100,
|
||||||
|
|
@ -31,19 +34,18 @@ filters_ui <- function(id) {
|
||||||
value = "score",
|
value = "score",
|
||||||
sliderInput(
|
sliderInput(
|
||||||
NS(id, "score"),
|
NS(id, "score"),
|
||||||
label = "Included scores",
|
label = NULL,
|
||||||
post = "%",
|
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 100,
|
max = 1,
|
||||||
step = 1,
|
step = 0.01,
|
||||||
value = c(90, 100)
|
value = c(0.9, 1.0)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
tabPanelBody(
|
tabPanelBody(
|
||||||
value = "rank",
|
value = "rank",
|
||||||
sliderInput(
|
sliderInput(
|
||||||
NS(id, "rank"),
|
NS(id, "rank"),
|
||||||
label = "Included ranks",
|
label = NULL,
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2000,
|
max = 2000,
|
||||||
step = 10,
|
step = 10,
|
||||||
|
|
@ -63,6 +65,7 @@ filters_ui <- function(id) {
|
||||||
value = c(0, 150)
|
value = c(0, 150)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Construct server for the filter editor.
|
# Construct server for the filter editor.
|
||||||
|
|
@ -90,15 +93,9 @@ filters_server <- function(id, results) {
|
||||||
rank >= (1 - (input$percentile[2] / 100)) * n_ranks
|
rank >= (1 - (input$percentile[2] / 100)) * n_ranks
|
||||||
]
|
]
|
||||||
} else if (input$method == "score") {
|
} else if (input$method == "score") {
|
||||||
results[
|
results[score >= input$score[1] & score <= input$score[2]]
|
||||||
score >= input$score[1] / 100 &
|
|
||||||
score <= input$score[2] / 100
|
|
||||||
]
|
|
||||||
} else if (input$method == "rank") {
|
} else if (input$method == "rank") {
|
||||||
results[
|
results[rank >= input$rank[1] & rank <= input$rank[2]]
|
||||||
rank >= input$rank[1] &
|
|
||||||
rank <= input$rank[2]
|
|
||||||
]
|
|
||||||
} else {
|
} else {
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
R/gsea.R
16
R/gsea.R
|
|
@ -2,6 +2,12 @@
|
||||||
#' @noRd
|
#' @noRd
|
||||||
gsea_ui <- function(id) {
|
gsea_ui <- function(id) {
|
||||||
verticalLayout(
|
verticalLayout(
|
||||||
|
filters_ui(NS(id, "filters")),
|
||||||
|
actionButton(
|
||||||
|
NS(id, "gsea_run"),
|
||||||
|
"Update analysis",
|
||||||
|
class = "btn-primary"
|
||||||
|
),
|
||||||
div(
|
div(
|
||||||
style = "margin-top: 16px",
|
style = "margin-top: 16px",
|
||||||
plotly::plotlyOutput(NS(id, "plot")),
|
plotly::plotlyOutput(NS(id, "plot")),
|
||||||
|
|
@ -21,6 +27,8 @@ gsea_ui <- function(id) {
|
||||||
#' @noRd
|
#' @noRd
|
||||||
gsea_server <- function(id, ranking) {
|
gsea_server <- function(id, ranking) {
|
||||||
moduleServer(id, function(input, output, session) {
|
moduleServer(id, function(input, output, session) {
|
||||||
|
ranking_filtered <- filters_server("filters", ranking)
|
||||||
|
|
||||||
gsea_analysis <- reactive({
|
gsea_analysis <- reactive({
|
||||||
withProgress(
|
withProgress(
|
||||||
message = "Querying g:Profiler",
|
message = "Querying g:Profiler",
|
||||||
|
|
@ -28,13 +36,15 @@ gsea_server <- function(id, ranking) {
|
||||||
{ # nolint
|
{ # nolint
|
||||||
setProgress(0.2)
|
setProgress(0.2)
|
||||||
gprofiler2::gost(
|
gprofiler2::gost(
|
||||||
ranking()[, gene],
|
ranking_filtered()$gene,
|
||||||
custom_bg = NULL, # TODO
|
custom_bg = ranking()$gene,
|
||||||
domain_scope = "custom_annotated"
|
domain_scope = "custom_annotated"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}) |> bindCache(ranking())
|
}) |>
|
||||||
|
bindCache(ranking_filtered()) |>
|
||||||
|
bindEvent(input$gsea_run, ignoreNULL = FALSE)
|
||||||
|
|
||||||
output$plot <- plotly::renderPlotly({
|
output$plot <- plotly::renderPlotly({
|
||||||
gprofiler2::gostplot(
|
gprofiler2::gostplot(
|
||||||
|
|
|
||||||
13
R/results.R
13
R/results.R
|
|
@ -19,8 +19,7 @@ results_ui <- function(id, options) {
|
||||||
sidebarPanel(
|
sidebarPanel(
|
||||||
width = 3,
|
width = 3,
|
||||||
comparison_editor_ui(NS(id, "comparison_editor"), options),
|
comparison_editor_ui(NS(id, "comparison_editor"), options),
|
||||||
methods_ui(NS(id, "methods"), options),
|
methods_ui(NS(id, "methods"), options)
|
||||||
filters_ui(NS(id, "filters"))
|
|
||||||
),
|
),
|
||||||
mainPanel(
|
mainPanel(
|
||||||
width = 9,
|
width = 9,
|
||||||
|
|
@ -150,14 +149,11 @@ results_ui <- function(id, options) {
|
||||||
),
|
),
|
||||||
tabPanel(
|
tabPanel(
|
||||||
title = "g:Profiler",
|
title = "g:Profiler",
|
||||||
div(
|
|
||||||
style = "margin-top: 16px",
|
|
||||||
gsea_ui(NS(id, "gsea"))
|
gsea_ui(NS(id, "gsea"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' Application logic for the results page.
|
#' Application logic for the results page.
|
||||||
|
|
@ -198,11 +194,8 @@ results_server <- function(id, options, analysis) {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
# Apply the filters.
|
|
||||||
results_filtered <- filters_server("filters", results)
|
|
||||||
|
|
||||||
# Server for the detailed results panel.
|
# Server for the detailed results panel.
|
||||||
details_server("results", options, results_filtered)
|
details_server("results", options, results)
|
||||||
|
|
||||||
output$rank_plot <- plotly::renderPlotly({
|
output$rank_plot <- plotly::renderPlotly({
|
||||||
preset <- preset()
|
preset <- preset()
|
||||||
|
|
@ -403,7 +396,7 @@ results_server <- function(id, options, analysis) {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
gsea_server("gsea", results_filtered)
|
gsea_server("gsea", results)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue