diff --git a/server.R b/server.R index cc7cdd7..785efd4 100644 --- a/server.R +++ b/server.R @@ -6,20 +6,37 @@ source("init.R") source("scatter_plot.R") server <- function(input, output) { - #' This expression applies all user defined filters to the available - #' results. + #' This reactive expression applies all user defined filters as well as the + #' desired ranking weights to the results. results <- reactive({ + # Select the species preset. + results <- if (input$species == "all") { results_all } else { results_replicative } - results[ + # Apply user defined filters. + + results <- results[ cluster_length >= input$length & cluster_mean >= input$range[1] * 1000000 & cluster_mean <= input$range[2] * 1000000 ] + + # Compute scoring factors and the weighted score. + + cluster_max <- results[, max(cluster_length)] + results[, cluster_score := cluster_length / cluster_max] + + results[, score := input$clustering / 100 * cluster_score + + input$correlation / 100 * r_mean] + + # Order the results based on their score. The resulting index will be + # used as the "rank". + + setorder(results, -score) }) output$genes <- renderDT({ diff --git a/ui.R b/ui.R index 685f907..58b3afd 100644 --- a/ui.R +++ b/ui.R @@ -27,8 +27,30 @@ ui <- fluidPage( "length", "Minimum cluster size", min = 0, - max = 30, - value = 10 + max = 50, + value = c(0, 15), + step = 0.1 + ) + ), + wellPanel( + h3("Ranking"), + sliderInput( + "clustering", + "Size of largest cluster", + post = "%", + min = 0, + max = 100, + step = 1, + value = 100 + ), + sliderInput( + "correlation", + "Correlation with known genes", + post = "%", + min = 0, + max = 100, + step = 1, + value = 100 ) ), wellPanel(