From ce467707e065faedb3bd89aee206b5f20e42f476 Mon Sep 17 00:00:00 2001 From: Oliver Mazariegos Date: Fri, 15 Dec 2023 23:06:19 -0600 Subject: [PATCH] feat: resection_site and primary_diagnosis added --- Dashboard/explorer.R | 2 +- Dashboard/global.R | 9 ----- Dashboard/server.R | 48 +++++++++++++++++++++++++-- Dashboard/ui.R | 78 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 124 insertions(+), 13 deletions(-) diff --git a/Dashboard/explorer.R b/Dashboard/explorer.R index 7424679..d0743fe 100644 --- a/Dashboard/explorer.R +++ b/Dashboard/explorer.R @@ -62,7 +62,7 @@ project_id_dt <- function(data) { return(data) } -primary_site_barplot <- function(data, variable_name) { +aggregation_substr_barplot <- function(data, variable_name) { data <- as.data.frame(data) xticks_labels <- as.list(substr(data$key, 1, 30)) diff --git a/Dashboard/global.R b/Dashboard/global.R index b0dc024..cec5b41 100644 --- a/Dashboard/global.R +++ b/Dashboard/global.R @@ -13,15 +13,6 @@ library(DT) library(BiocManager) options(repos = BiocManager::repositories()) -projects <- GenomicDataCommons::projects() %>% - GenomicDataCommons::filter(program.name == "TCGA") %>% - GenomicDataCommons::facet(c("name", "project_id")) %>% - results_all() - -tcga_project_ids_list <- projects$project_id -tcga_project_ids_list <- c("TODOS", tcga_project_ids_list) - - Sys.setenv(OPENSSL_CONF = "/dev/null") options(shiny.fullstacktrace = TRUE) diff --git a/Dashboard/server.R b/Dashboard/server.R index f50b8c9..2627403 100644 --- a/Dashboard/server.R +++ b/Dashboard/server.R @@ -1,4 +1,12 @@ function(input, output, session) { + # Static data ---- + projects <- GenomicDataCommons::projects() %>% + GenomicDataCommons::filter(program.name == "TCGA") %>% + GenomicDataCommons::facet(c("name", "project_id")) %>% + results_all() + + tcga_project_ids_list <- projects$project_id + tcga_project_ids_list <- c("TODOS", tcga_project_ids_list) # Filters --- ## projects_reactive ---- projects_reactive <- reactive({ @@ -123,7 +131,7 @@ function(input, output, session) { ## primary_site ---- ### barplot ---- output$primary_site_barplot <- renderPlotly({ - primary_site_barplot( + aggregation_substr_barplot( head(explorer_data_reactive()$primary_site, 30), "Sitio primario" ) @@ -138,6 +146,42 @@ function(input, output, session) { ) }) + ## primary_diagnosis ---- + ### barplot ---- + output$primary_diagnosis_barplot <- renderPlotly({ + aggregation_substr_barplot( + head(explorer_data_reactive()$diagnoses.primary_diagnosis, 30), + "Diagnóstico primario" + ) + }) + + ### datatable ---- + output$primary_diagnosis_dt <- renderDataTable({ + aggregation_dt( + explorer_data_reactive()$diagnoses.primary_diagnosis, + "Diagnóstico primario", + "casos_por_diagnostico_primario" + ) + }) + + ## site_of_resection_or_biopsy ---- + ### barplot ---- + output$resection_site_barplot <- renderPlotly({ + aggregation_substr_barplot( + head(explorer_data_reactive()$diagnoses.site_of_resection_or_biopsy, 30), + "Sitio de Resección o Biopsia" + ) + }) + + ### datatable ---- + output$resection_site_dt <- renderDataTable({ + aggregation_dt( + explorer_data_reactive()$diagnoses.site_of_resection_or_biopsy, + "Sitio de Resección o Biopsia", + "casos_por_sitio_de_reseccion_o_biopsia" + ) + }) + ## race ---- ### barplot ---- output$race_barplot <- renderPlotly({ @@ -186,7 +230,7 @@ function(input, output, session) { output$gender_dt <- renderDataTable({ aggregation_dt( explorer_data_reactive()$demographic.gender, - "Genero", + "Género", "casos_por_genero" ) }) diff --git a/Dashboard/ui.R b/Dashboard/ui.R index 95708cb..b697c19 100644 --- a/Dashboard/ui.R +++ b/Dashboard/ui.R @@ -92,7 +92,9 @@ fluidPage( ## Tab EXPLORADOR ---- tabItem( tabName = "EXPLORADOR", - h2("Explorador de datos"), + h1("Explorador de datos"), + br(), + h2("Proyectos"), br(), fluidRow( width = 12, @@ -163,6 +165,80 @@ fluidPage( ) ) ), + fluidRow( + width = 12, + ### primary_diagnosis ---- + box( + width = 6, + solidHeader = TRUE, + collapsible = TRUE, + title = "Número de casos por diagnóstico primario", + tabBox( + width = 12, + height = NULL, + #### barplot ---- + tabPanel( + title = "Gráfico de barras", + icon = icon("chart-bar"), + h4( + class = "text-center", + "Número de Casos por Diagnóstico Primario (top 30)" + ), + shinycssloaders::withSpinner( + plotlyOutput("primary_diagnosis_barplot", height = 500), + color = "#1c9ad6", type = "8", size = 0.5 + ) + ), + #### datatable ---- + tabPanel( + title = "Cuadro de datos", + icon = icon("table"), + shinycssloaders::withSpinner( + dataTableOutput("primary_diagnosis_dt"), + color = "#1c9ad6", type = "8", size = 0.5 + ) + ) + ) + ), + ### site_of_resection_or_biopsy ---- + box( + width = 6, + solidHeader = TRUE, + collapsible = TRUE, + title = "Número de casos por sitio de resección o biopsia", + tabBox( + width = 12, + height = NULL, + #### barplot ---- + tabPanel( + title = "Gráfico de barras", + icon = icon("chart-bar"), + h4( + class = "text-center", + paste0( + "Número de Casos por ", + "Sitio de Resección o Biopsia (top 30)" + ) + ), + shinycssloaders::withSpinner( + plotlyOutput("resection_site_barplot", height = 500), + color = "#1c9ad6", type = "8", size = 0.5 + ) + ), + #### datatable ---- + tabPanel( + title = "Cuadro de datos", + icon = icon("table"), + shinycssloaders::withSpinner( + dataTableOutput("resection_site_dt"), + color = "#1c9ad6", type = "8", size = 0.5 + ) + ) + ) + ) + ), + h2("Demografía"), + br(), fluidRow( ### race ---- box(