Add initial controls to the explore page

This commit is contained in:
Elias Projahn 2022-05-10 11:33:49 +02:00
parent be1a4ef2fd
commit 06de28a92b
2 changed files with 82 additions and 30 deletions

View file

@ -1,10 +1,34 @@
#' Server implementing the main user interface.
#' @noRd
server <- function(input, output) {
output$all_data <- DT::renderDataTable({
data <- ubigen::genes[, .(
output$ranked_data <- DT::renderDataTable({
total_weight <- abs(input$above_median) +
abs(input$mean_expression) +
abs(input$sd_expression)
data <- data.table::copy(ubigen::genes)
data[, score :=
(input$above_median * above_median +
input$mean_expression * mean_expression_normalized +
input$sd_expression * sd_expression_normalized) /
total_weight]
data.table::setorder(data, -score)
data[, rank := .I]
genes_table(data)
})
output$all_data <- DT::renderDataTable(genes_table(ubigen::genes))
}
#' Create a displayable data table from the gene results data.
#' @noRd
genes_table <- function(data) {
data <- data[, .(
"Gene" = glue::glue_data(
ubigen::genes,
data,
"<a href=\"https://www.ensembl.org/Homo_sapiens/Gene/Summary",
"?db=core;g={gene}\" target=\"_blank\">{hgnc_name}</a>"
),
@ -25,17 +49,19 @@ server <- function(input, output) {
rownames = FALSE,
escape = FALSE
) |>
DT::formatPercentage(c(
DT::formatPercentage(
c(
"Score",
"Expressed",
"Above 50 TPM",
"Above median",
"Above 95%"
)) |>
),
digits = 2,
) |>
DT::formatRound(c(
"Median",
"Mean",
"Standard deviation"
))
})
}

26
R/ui.R
View file

@ -13,9 +13,35 @@ ui <- function() {
sidebarLayout(
sidebarPanel(
width = 3,
h3("Criteria"),
sliderInput(
"above_median",
"Expressed above median",
min = -1.0,
max = 1.0,
step = 0.01,
value = 1.0
),
sliderInput(
"mean_expression",
"Mean expression",
min = -1.0,
max = 1.0,
step = 0.01,
value = 1.0
),
sliderInput(
"sd_expression",
"Standard deviation",
min = -1.0,
max = 1.0,
step = 0.01,
value = -1.0
)
),
mainPanel(
width = 9,
DT::dataTableOutput("ranked_data")
)
)
),