mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 19:27:24 +01:00
Add slider to set required number of species
This commit is contained in:
parent
48aa46c2c4
commit
4222a08b87
3 changed files with 42 additions and 6 deletions
18
init.R
18
init.R
|
|
@ -79,6 +79,13 @@ neural_replicative <- run_cached(
|
||||||
|
|
||||||
results_all <- merge(
|
results_all <- merge(
|
||||||
genes,
|
genes,
|
||||||
|
distances[, .(n_species = .N), by = "gene"],
|
||||||
|
by.x = "id",
|
||||||
|
by.y = "gene"
|
||||||
|
)
|
||||||
|
|
||||||
|
results_all <- merge(
|
||||||
|
results_all,
|
||||||
clustering_all,
|
clustering_all,
|
||||||
by.x = "id",
|
by.x = "id",
|
||||||
by.y = "gene"
|
by.y = "gene"
|
||||||
|
|
@ -100,6 +107,17 @@ results_all <- merge(
|
||||||
|
|
||||||
results_replicative <- merge(
|
results_replicative <- merge(
|
||||||
genes,
|
genes,
|
||||||
|
distances[
|
||||||
|
species %chin% species_ids_replicative,
|
||||||
|
.(n_species = .N),
|
||||||
|
by = gene
|
||||||
|
],
|
||||||
|
by.x = "id",
|
||||||
|
by.y = "gene"
|
||||||
|
)
|
||||||
|
|
||||||
|
results_replicative <- merge(
|
||||||
|
results_replicative,
|
||||||
clustering_replicative,
|
clustering_replicative,
|
||||||
by.x = "id",
|
by.x = "id",
|
||||||
by.y = "gene"
|
by.y = "gene"
|
||||||
|
|
|
||||||
27
server.R
27
server.R
|
|
@ -18,6 +18,22 @@ js_link <- JS("function(row, data) {
|
||||||
}")
|
}")
|
||||||
|
|
||||||
server <- function(input, output) {
|
server <- function(input, output) {
|
||||||
|
#' Show the customized slider for setting the required number of species.
|
||||||
|
output$n_species_slider <- renderUI({
|
||||||
|
sliderInput(
|
||||||
|
"n_species",
|
||||||
|
"Required number of species per gene",
|
||||||
|
min = 0,
|
||||||
|
max = if (input$species == "all") {
|
||||||
|
nrow(species)
|
||||||
|
} else {
|
||||||
|
length(species_ids_replicative)
|
||||||
|
},
|
||||||
|
step = 1,
|
||||||
|
value = 10
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
#' This reactive expression applies all user defined filters as well as the
|
#' This reactive expression applies all user defined filters as well as the
|
||||||
#' desired ranking weights to the results.
|
#' desired ranking weights to the results.
|
||||||
results <- reactive({
|
results <- reactive({
|
||||||
|
|
@ -40,11 +56,12 @@ server <- function(input, output) {
|
||||||
neural_factor <- neural_weight / total_weight
|
neural_factor <- neural_weight / total_weight
|
||||||
|
|
||||||
results[, score := clusteriness_factor * clusteriness +
|
results[, score := clusteriness_factor * clusteriness +
|
||||||
correlation_factor * r_mean + neural_factor * neural]
|
correlation_factor * correlation + neural_factor * neural]
|
||||||
|
|
||||||
# Apply the cut-off score.
|
# Apply the cut-off score & the required number of species.
|
||||||
|
|
||||||
results <- results[score >= input$cutoff / 100]
|
results <- results[n_species >= input$n_species &
|
||||||
|
score >= input$cutoff / 100]
|
||||||
|
|
||||||
# Order the results based on their score. The resulting index will be
|
# Order the results based on their score. The resulting index will be
|
||||||
# used as the "rank".
|
# used as the "rank".
|
||||||
|
|
@ -59,7 +76,7 @@ server <- function(input, output) {
|
||||||
gene,
|
gene,
|
||||||
name,
|
name,
|
||||||
clusteriness,
|
clusteriness,
|
||||||
r_mean,
|
correlation,
|
||||||
neural,
|
neural,
|
||||||
score
|
score
|
||||||
)],
|
)],
|
||||||
|
|
@ -82,7 +99,7 @@ server <- function(input, output) {
|
||||||
|
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
dt,
|
dt,
|
||||||
c("clusteriness", "r_mean", "neural", "score"),
|
c("clusteriness", "correlation", "neural", "score"),
|
||||||
digits = 1
|
digits = 1
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
3
ui.R
3
ui.R
|
|
@ -17,7 +17,8 @@ ui <- fluidPage(
|
||||||
"Replicatively aging" = "replicative",
|
"Replicatively aging" = "replicative",
|
||||||
"All qualified" = "all"
|
"All qualified" = "all"
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
uiOutput("n_species_slider")
|
||||||
),
|
),
|
||||||
wellPanel(
|
wellPanel(
|
||||||
h3("Ranking"),
|
h3("Ranking"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue