Show distances in results and add filtering

This commit is contained in:
Elias Projahn 2022-05-23 11:24:49 +02:00
parent 507f90e084
commit 17b738378a
3 changed files with 33 additions and 3 deletions

View file

@ -53,6 +53,14 @@ filters_ui <- function(id) {
tabPanelBody( tabPanelBody(
value = "none" value = "none"
) )
),
sliderInput(
NS(id, "distance"),
label = "Distance to telomeres",
post = " Mbp",
min = 0,
max = 150,
value = c(0, 150)
) )
) )
} }
@ -71,7 +79,7 @@ filters_server <- function(id, results) {
reactive({ reactive({
results <- results() results <- results()
if (input$method == "percentile") { results_prefiltered <- if (input$method == "percentile") {
n_ranks <- nrow(results) n_ranks <- nrow(results)
results[rank <= (1 - (input$percentile / 100)) * n_ranks] results[rank <= (1 - (input$percentile / 100)) * n_ranks]
} else if (input$method == "score") { } else if (input$method == "score") {
@ -81,6 +89,11 @@ filters_server <- function(id, results) {
} else { } else {
results results
} }
results_prefiltered[
distance >= 1000000 * input$distance[1] &
distance <= 1000000 * input$distance[2]
]
}) })
}) })
} }

View file

@ -56,6 +56,7 @@ results_server <- function(id, filtered_results) {
"gene", "gene",
"name", "name",
"chromosome", "chromosome",
"distance",
method_ids, method_ids,
"score", "score",
"percentile" "percentile"
@ -66,13 +67,22 @@ results_server <- function(id, filtered_results) {
"Gene", "Gene",
"", "",
"Chromosome", "Chromosome",
"Distance",
method_names, method_names,
"Score", "Score",
"Percentile" "Percentile"
) )
output_data <- reactive({ output_data <- reactive({
filtered_results()[, ..columns] filtered_results()[, ..columns][,
distance := paste0(
format(
round(distance / 1000000, digits = 2),
nsmall = 2,
),
" Mbp"
)
]
}) })
output$download <- downloadHandler( output$download <- downloadHandler(

View file

@ -45,11 +45,18 @@ server <- function(options) {
# Rank the results. # Rank the results.
ranking <- methods_server("methods", analysis, comparison_gene_ids) ranking <- methods_server("methods", analysis, comparison_gene_ids)
genes_with_distances <- merge(
geposan::genes,
geposan::distances[species == "hsapiens"],
by.x = "id",
by.y = "gene"
)
# Add gene information to the results. # Add gene information to the results.
results <- reactive({ results <- reactive({
merge( merge(
ranking(), ranking(),
geposan::genes, genes_with_distances,
by.x = "gene", by.x = "gene",
by.y = "id", by.y = "id",
sort = FALSE sort = FALSE