diff --git a/R/server.R b/R/server.R index 10c847e..5664db0 100644 --- a/R/server.R +++ b/R/server.R @@ -2,18 +2,14 @@ #' @noRd server <- function(input, output) { ranked_data <- reactive({ - total_weight <- abs(input$above_zero) + - abs(input$above_median) + - abs(input$above_95) + + total_weight <- abs(input$cross_sample_weight) + abs(input$mean_expression) + abs(input$sd_expression) data <- data.table::copy(ubigen::genes) data[, score := - (input$above_zero * above_zero + - input$above_95 * above_95 + - input$above_median * above_median + + (input$cross_sample_weight * get(input$cross_sample_metric) + input$mean_expression * mean_expression_normalized + input$sd_expression * sd_expression_normalized) / total_weight] diff --git a/R/ui.R b/R/ui.R index 5f53b08..d515993 100644 --- a/R/ui.R +++ b/R/ui.R @@ -14,49 +14,29 @@ ui <- function() { sidebarPanel( width = 3, h3("Features"), - sliderInput( - "above_zero", + selectInput( + "cross_sample_metric", verticalLayout( - strong("Expressed"), - paste0( - "Percentage of samples in which the gene is ", - "expressed." - ) + strong("Expression across samples"), + paste0( + "Proportion samples in which the gene is expressed above the ", + "selected threshold. Select a method and a weight for the ", + "final score." + ) ), - min = -1.0, - max = 1.0, - step = 0.01, - value = 0.33 + list( + "Above 95th percentile" = "above_95", + "Above median" = "above_median", + "Above zero" = "above_zero" + ) ), sliderInput( - "above_median", - verticalLayout( - strong("Expressed above median"), - paste0( - "Percentage of samples that express the gene ", - "more than the median of expression within ", - "that sample." - ) - ), + "cross_sample_weight", + label = NULL, min = -1.0, max = 1.0, step = 0.01, - value = 0.33 - ), - sliderInput( - "above_95", - verticalLayout( - strong("Expressed above 95%"), - paste0( - "Percentage of samples that express the gene ", - "more than the 95. percentile of expression ", - "within that sample." - ) - ), - min = -1.0, - max = 1.0, - step = 0.01, - value = 0.33 + value = 1.0 ), sliderInput( "mean_expression",