diff --git a/server.R b/server.R index 949a1b7..9395af9 100644 --- a/server.R +++ b/server.R @@ -19,8 +19,18 @@ server <- function(input, output) { # Compute scoring factors and the weighted score. - results[, score := input$clusteriness / 100 * clusteriness + - input$correlation / 100 * r_mean] + clusteriness_weight <- input$clusteriness / 100 + correlation_weight <- input$correlation / 100 + total_weight <- clusteriness_weight + correlation_weight + clusteriness_factor <- clusteriness_weight / total_weight + correlation_factor <- correlation_weight / total_weight + + results[, score := clusteriness_factor * clusteriness + + correlation_factor * r_mean] + + # Apply the cut-off score. + + results <- results[score >= input$cutoff / 100] # Order the results based on their score. The resulting index will be # used as the "rank". @@ -29,17 +39,20 @@ server <- function(input, output) { }) output$genes <- renderDT({ - datatable( - results()[, .(.I, name, clusteriness, r_mean)], + dt <- datatable( + results()[, .(.I, name, clusteriness, r_mean, score)], rownames = FALSE, colnames = c( "Rank", "Gene", "Clusteriness", - "Correlation" + "Correlation", + "Score" ), style = "bootstrap" ) + + formatPercentage(dt, c("clusteriness", "r_mean", "score"), digits = 1) }) output$synposis <- renderText({ diff --git a/ui.R b/ui.R index 9f1b4a2..05aec8f 100644 --- a/ui.R +++ b/ui.R @@ -25,7 +25,7 @@ ui <- fluidPage( min = 0, max = 100, step = 1, - value = 50 + value = 100 ), sliderInput( "correlation", @@ -35,6 +35,15 @@ ui <- fluidPage( max = 100, step = 1, value = 100 + ), + sliderInput( + "cutoff", + "Cut-off score", + post = "%", + min = 0, + max = 100, + step = 1, + value = 50 ) ), wellPanel(