From 601199a06fd14b67152553adc3a92635b6c79267 Mon Sep 17 00:00:00 2001 From: Oliver Mazariegos Date: Tue, 2 Jan 2024 04:55:43 -0600 Subject: [PATCH] ci: linting files --- .lintr | 2 +- Dashboard/demographics.R | 144 +++++----- Dashboard/diagnosis.R | 179 ++++++------ Dashboard/files.R | 232 ++++++++-------- Dashboard/global.R | 6 +- Dashboard/project.R | 93 ++++--- Dashboard/server.R | 571 +++++++++++++++++++-------------------- Dashboard/ui.R | 12 +- run.R | 2 +- setup.R | 36 +-- 10 files changed, 633 insertions(+), 644 deletions(-) diff --git a/.lintr b/.lintr index 6c2c005..a46d741 100644 --- a/.lintr +++ b/.lintr @@ -1,2 +1,2 @@ -linters: linters_with_defaults(object_usage_linter = NULL) +linters: linters_with_defaults(object_usage_linter = NULL, cyclocomp_linter = NULL, object_length_linter = NULL) encoding: "UTF-8" diff --git a/Dashboard/demographics.R b/Dashboard/demographics.R index f53b73b..0f49ce0 100644 --- a/Dashboard/demographics.R +++ b/Dashboard/demographics.R @@ -1,10 +1,10 @@ # race_pie ---- race_pie <- function(data) { - fig <- data %>% - dplyr::select(race) %>% - replace(is.na(.), "Sin dato") %>% - group_by(race) %>% - tally() %>% + fig <- data %>% + dplyr::select(race) %>% + replace(is.na(.), "Sin dato") %>% + group_by(race) %>% + tally() %>% dplyr::mutate( key_color = case_when( race == "white" ~ "#ffa600", @@ -16,7 +16,7 @@ race_pie <- function(data) { race == "native hawaiian or other pacific islander" ~ "#665191", race == "Unknown" ~ "#2f4b7c" ) - ) %>% + ) %>% plot_ly( labels = ~race, values = ~n, @@ -43,14 +43,14 @@ race_pie <- function(data) { # race_piedt ---- race_piedt <- function(data) { - data <- data %>% - dplyr::select(race) %>% - replace(is.na(.), "Sin dato") %>% - group_by(race) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + dplyr::select(race) %>% + replace(is.na(.), "Sin dato") %>% + group_by(race) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Raza" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -79,11 +79,11 @@ race_piedt <- function(data) { # ethnicity_pie ---- ethnicity_pie <- function(data) { - fig <- data %>% - dplyr::select(ethnicity) %>% - replace(is.na(.), "Sin dato") %>% - group_by(ethnicity) %>% - tally() %>% + fig <- data %>% + dplyr::select(ethnicity) %>% + replace(is.na(.), "Sin dato") %>% + group_by(ethnicity) %>% + tally() %>% dplyr::mutate( key_color = case_when( ethnicity == "not hispanic or latino" ~ "#C3E2C2", @@ -92,7 +92,7 @@ ethnicity_pie <- function(data) { ethnicity == "Sin dato" ~ "#010101", ethnicity == "Unknown" ~ "#2f4b7c" ) - ) %>% + ) %>% plot_ly( labels = ~ethnicity, values = ~n, @@ -119,14 +119,14 @@ ethnicity_pie <- function(data) { # ethnicity_piedt ---- ethnicity_piedt <- function(data) { - data <- data %>% - dplyr::select(ethnicity) %>% - replace(is.na(.), "Sin dato") %>% - group_by(ethnicity) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + dplyr::select(ethnicity) %>% + replace(is.na(.), "Sin dato") %>% + group_by(ethnicity) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Etnicidad" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -155,11 +155,11 @@ ethnicity_piedt <- function(data) { # gender_pie ---- gender_pie <- function(data) { - fig <- data %>% - dplyr::select(gender) %>% - replace(is.na(.), "Sin dato") %>% - group_by(gender) %>% - tally() %>% + fig <- data %>% + dplyr::select(gender) %>% + replace(is.na(.), "Sin dato") %>% + group_by(gender) %>% + tally() %>% dplyr::mutate( key_color = case_when( gender == "female" ~ "#FF90C2", @@ -167,7 +167,7 @@ gender_pie <- function(data) { gender == "male" ~ "#1640D6", gender == "Sin dato" ~ "#010101", ) - ) %>% + ) %>% plot_ly( labels = ~gender, values = ~n, @@ -194,14 +194,14 @@ gender_pie <- function(data) { # gender_piedt ---- gender_piedt <- function(data) { - data <- data %>% - dplyr::select(gender) %>% - replace(is.na(.), "Sin dato") %>% - group_by(gender) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + dplyr::select(gender) %>% + replace(is.na(.), "Sin dato") %>% + group_by(gender) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Género" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -230,10 +230,10 @@ gender_piedt <- function(data) { # gender_age_pyramid ---- gender_age_pyramid <- function(data) { - age_pyramid_df <- data %>% + age_pyramid_df <- data %>% dplyr::filter( gender %in% c("female", "male") - ) %>% + ) %>% dplyr::mutate( `Edad` = age_categories( age_at_index, @@ -241,37 +241,39 @@ gender_age_pyramid <- function(data) { 0, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 ) ) - ) %>% - dplyr::group_by(gender, Edad) %>% + ) %>% + dplyr::group_by(gender, Edad) %>% dplyr::tally() %>% mutate( `Edad` = as.character(`Edad`) - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% mutate( `Edad` = factor(`Edad`) - ) %>% + ) %>% dplyr::mutate( `n` = ifelse(gender == "male", -`n`, `n`), abs_pop = abs(`n`) - ) %>% + ) %>% rename( "Género" = "gender", "Casos" = "n", "Casos absolutos" = "abs_pop" ) - + age_pyramid <- plot_ly( data = age_pyramid_df, x = ~Casos, - y = ~Edad, + y = ~Edad, color = ~`Género`, colors = c(female = "#FF90C2", male = "#1640D6"), textposition = "inside" - ) %>% - add_bars(orientation = 'h', hoverinfo = 'text', text = ~`Casos absolutos`) %>% + ) %>% + add_bars( + orientation = "h", hoverinfo = "text", text = ~`Casos absolutos` + ) %>% layout( - bargap = 0.1, barmode = 'overlay', + bargap = 0.1, barmode = "overlay", xaxis = list( title = "Número de caos" ) @@ -281,10 +283,10 @@ gender_age_pyramid <- function(data) { # gender_age_pyramiddt ---- gender_age_pyramiddt <- function(data) { - data <- data %>% + data <- data %>% dplyr::filter( gender %in% c("female", "male") - ) %>% + ) %>% dplyr::mutate( `Edad` = age_categories( age_at_index, @@ -292,28 +294,28 @@ gender_age_pyramiddt <- function(data) { 0, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 ) ) - ) %>% - dplyr::group_by(gender, Edad) %>% + ) %>% + dplyr::group_by(gender, Edad) %>% dplyr::tally() %>% mutate( `Edad` = as.character(`Edad`) - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% mutate( `Edad` = factor(`Edad`) - ) %>% + ) %>% dplyr::mutate( `n` = ifelse(gender == "male", -`n`, `n`), abs_pop = abs(`n`) - ) %>% + ) %>% rename( "Género" = "gender", "Casos" = "n", "Número de casos" = "abs_pop" - ) %>% + ) %>% dplyr::select( `Género`, Edad, `Número de casos` - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -342,11 +344,11 @@ gender_age_pyramiddt <- function(data) { # vital_status_pie ---- vital_status_pie <- function(data) { - fig <- data %>% - dplyr::select(vital_status) %>% - replace(is.na(.), "Sin dato") %>% - group_by(vital_status) %>% - tally() %>% + fig <- data %>% + dplyr::select(vital_status) %>% + replace(is.na(.), "Sin dato") %>% + group_by(vital_status) %>% + tally() %>% dplyr::mutate( key_color = case_when( vital_status == "Dead" ~ "#5F8670", @@ -354,7 +356,7 @@ vital_status_pie <- function(data) { vital_status == "Alive" ~ "#5D3587", vital_status == "Sin dato" ~ "#010101", ) - ) %>% + ) %>% plot_ly( labels = ~vital_status, values = ~n, @@ -381,14 +383,14 @@ vital_status_pie <- function(data) { # vital_status_piedt ---- vital_status_piedt <- function(data) { - data <- data %>% - dplyr::select(vital_status) %>% - replace(is.na(.), "Sin dato") %>% - group_by(vital_status) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + dplyr::select(vital_status) %>% + replace(is.na(.), "Sin dato") %>% + group_by(vital_status) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Estado vital" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, diff --git a/Dashboard/diagnosis.R b/Dashboard/diagnosis.R index d9eb149..5f71c3c 100644 --- a/Dashboard/diagnosis.R +++ b/Dashboard/diagnosis.R @@ -1,61 +1,60 @@ # primary_diagnosis_treemap ---- primary_diagnosis_treemap <- function(data) { - primary_diagnosis_tree_df <- data %>% - group_by(tissue_or_organ_of_origin, `primary_diagnosis`) %>% - tally(name = "cases") %>% - replace(is.na(.), "Sin dato") %>% - ungroup() %>% + primary_diagnosis_tree_df <- data %>% + group_by(tissue_or_organ_of_origin, `primary_diagnosis`) %>% + tally(name = "cases") %>% + replace(is.na(.), "Sin dato") %>% + ungroup() %>% mutate( primary_diagnosis = paste( as.character(cases), primary_diagnosis ) ) - - primary_diagnosis_tree_df <- data %>% + + primary_diagnosis_tree_df <- data %>% mutate( parent = "Tejido u órgano de origen y sus diagnosticos" - ) %>% - group_by(parent, tissue_or_organ_of_origin) %>% - tally(name = "cases") %>% + ) %>% + group_by(parent, tissue_or_organ_of_origin) %>% + tally(name = "cases") %>% rename( "tissue_or_organ_of_origin" = 1, "primary_diagnosis" = 2, - ) %>% - rbind(., primary_diagnosis_tree_df) %>% - replace(is.na(.), "Sin dato") %>% - ungroup() %>% + ) %>% + rbind(., primary_diagnosis_tree_df) %>% + replace(is.na(.), "Sin dato") %>% + ungroup() %>% mutate( ids = ifelse( - tissue_or_organ_of_origin == "", + tissue_or_organ_of_origin == "", paste0("-", primary_diagnosis), paste0(tissue_or_organ_of_origin, "-", primary_diagnosis) ) ) - + primary_diagnosis_treemap <- plot_ly( data = primary_diagnosis_tree_df, branchvalues = "total", type = "treemap", - #ids = ~ids, labels = ~primary_diagnosis, parents = ~tissue_or_organ_of_origin, values = ~cases, - hoverinfo = 'label' + hoverinfo = "label" ) - + return(primary_diagnosis_treemap) } # primary_diagnosis_treedt ---- primary_diagnosis_treedt <- function(data) { - data <- data %>% - group_by(tissue_or_organ_of_origin, primary_diagnosis) %>% - tally(name = "Número de casos") %>% + data <- data %>% + group_by(tissue_or_organ_of_origin, primary_diagnosis) %>% + tally(name = "Número de casos") %>% rename( "Tejido u órgano de origen" = 1, "Diagnóstico primario" = 2 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -84,39 +83,39 @@ primary_diagnosis_treedt <- function(data) { # primary_stage_treemap ---- pathologic_stage_treemap <- function(data) { - ajcc_pathologic_stage_tree_df <- data %>% - group_by(tissue_or_organ_of_origin, ajcc_pathologic_stage) %>% - tally(name = "cases") %>% - replace(is.na(.), "Sin dato") %>% - ungroup() %>% + ajcc_pathologic_stage_tree_df <- data %>% + group_by(tissue_or_organ_of_origin, ajcc_pathologic_stage) %>% + tally(name = "cases") %>% + replace(is.na(.), "Sin dato") %>% + ungroup() %>% mutate( ajcc_pathologic_stage = paste( as.character(cases), ajcc_pathologic_stage ) ) - - ajcc_pathologic_stage_tree_df <- data %>% + + ajcc_pathologic_stage_tree_df <- data %>% mutate( parent = "Tejido u órgano de origen y sus etapa patológica" - ) %>% - group_by(parent, tissue_or_organ_of_origin) %>% - tally(name = "cases") %>% + ) %>% + group_by(parent, tissue_or_organ_of_origin) %>% + tally(name = "cases") %>% rename( "tissue_or_organ_of_origin" = 1, "ajcc_pathologic_stage" = 2, - ) %>% - rbind(., ajcc_pathologic_stage_tree_df) %>% - replace(is.na(.), "Sin dato") %>% - ungroup() %>% + ) %>% + rbind(., ajcc_pathologic_stage_tree_df) %>% + replace(is.na(.), "Sin dato") %>% + ungroup() %>% mutate( ids = ifelse( - tissue_or_organ_of_origin == "", + tissue_or_organ_of_origin == "", paste0("-", ajcc_pathologic_stage), paste0(tissue_or_organ_of_origin, "-", ajcc_pathologic_stage) ) ) - + ajcc_pathologic_stage_treemap <- plot_ly( data = ajcc_pathologic_stage_tree_df, branchvalues = "total", @@ -124,22 +123,22 @@ pathologic_stage_treemap <- function(data) { labels = ~ajcc_pathologic_stage, parents = ~tissue_or_organ_of_origin, values = ~cases, - hoverinfo = 'label' + hoverinfo = "label" ) - + return(ajcc_pathologic_stage_treemap) } # pathologic_stage_treedt ---- pathologic_stage_treedt <- function(data) { - data <- data %>% - group_by(tissue_or_organ_of_origin, ajcc_pathologic_stage) %>% - tally(name = "Número de casos") %>% + data <- data %>% + group_by(tissue_or_organ_of_origin, ajcc_pathologic_stage) %>% + tally(name = "Número de casos") %>% rename( "Tejido u órgano de origen" = 1, "Etapa patológica" = 2 - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -168,14 +167,14 @@ pathologic_stage_treedt <- function(data) { # tissue_origin_bar ---- tissue_origin_bar <- function(data) { - data <- data %>% - group_by(tissue_or_organ_of_origin) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(tissue_or_organ_of_origin) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Tejido u órgano de origen" = 1 - ) %>% + ) %>% replace(is.na(.), "Sin dato") - + if (nrow(data) > 30) { data <- head(data, 30) } @@ -207,13 +206,13 @@ tissue_origin_bar <- function(data) { # tissue_origin_bardt ---- tissue_origin_bardt <- function(data) { - data <- data %>% - group_by(tissue_or_organ_of_origin) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(tissue_or_organ_of_origin) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Tejido u órgano de origen" = 1 - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -242,14 +241,14 @@ tissue_origin_bardt <- function(data) { # primary_diagnosis_bar ---- primary_diagnosis_bar <- function(data) { - data <- data %>% - group_by(primary_diagnosis) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(primary_diagnosis) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Diagnóstico primario" = 1 - ) %>% + ) %>% replace(is.na(.), "Sin dato") - + if (nrow(data) > 30) { data <- head(data, 30) } @@ -281,13 +280,13 @@ primary_diagnosis_bar <- function(data) { # primary_diagnosis_bardt ---- primary_diagnosis_bardt <- function(data) { - data <- data %>% - group_by(primary_diagnosis) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(primary_diagnosis) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Diagnóstico primario" = 1 - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -316,14 +315,14 @@ primary_diagnosis_bardt <- function(data) { # pathologic_stage_bar ---- pathologic_stage_bar <- function(data) { - data <- data %>% - group_by(ajcc_pathologic_stage) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(ajcc_pathologic_stage) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Etapa patológica" = 1 - ) %>% + ) %>% replace(is.na(.), "Sin dato") - + fig <- plot_ly( data, x = ~`Etapa patológica`, y = ~`Número de casos`, type = "bar" @@ -351,13 +350,13 @@ pathologic_stage_bar <- function(data) { # pathologic_stage_bardt ---- pathologic_stage_bardt <- function(data) { - data <- data %>% - group_by(ajcc_pathologic_stage) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(ajcc_pathologic_stage) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Etapa patológia" = 1 - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -386,7 +385,7 @@ pathologic_stage_bardt <- function(data) { # age_at_diagnosis_bar ---- age_at_diagnosis_bar <- function(data) { - fig <- data %>% + fig <- data %>% mutate( age = age_at_diagnosis_years, `Edad al diagnostico` = age_categories( @@ -395,16 +394,16 @@ age_at_diagnosis_bar <- function(data) { 0, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 ) ) - ) %>% - group_by(`Edad al diagnostico`) %>% - tally(name = "Casos") %>% + ) %>% + group_by(`Edad al diagnostico`) %>% + tally(name = "Casos") %>% mutate( `Edad al diagnostico` = as.character(`Edad al diagnostico`) - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% mutate( `Edad al diagnostico` = factor(`Edad al diagnostico`) - ) %>% + ) %>% plot_ly( x = ~`Edad al diagnostico`, y = ~`Casos`, type = "bar" ) %>% @@ -430,7 +429,7 @@ age_at_diagnosis_bar <- function(data) { # age_at_diagnosis_bardt ---- age_at_diagnosis_bardt <- function(data) { - data <- data %>% + data <- data %>% mutate( age = age_at_diagnosis_years, `Edad al diagnostico` = age_categories( @@ -439,16 +438,16 @@ age_at_diagnosis_bardt <- function(data) { 0, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90 ) ) - ) %>% - group_by(`Edad al diagnostico`) %>% - tally(name = "Casos") %>% + ) %>% + group_by(`Edad al diagnostico`) %>% + tally(name = "Casos") %>% mutate( `Edad al diagnostico` = as.character(`Edad al diagnostico`) - ) %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% mutate( `Edad al diagnostico` = factor(`Edad al diagnostico`) - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, diff --git a/Dashboard/files.R b/Dashboard/files.R index c1a3426..4d290bc 100644 --- a/Dashboard/files.R +++ b/Dashboard/files.R @@ -1,92 +1,91 @@ # category_type_format_treemap ---- category_type_format_treemap <- function(data) { - f_category_type_format_tree_0 <- data %>% + f_category_type_format_tree_0 <- data %>% dplyr::mutate( parent = "Archivos por categoría de dato, tipo de dato y formato" - ) %>% + ) %>% dplyr::group_by( parent, data_category - ) %>% - tally(name = "Casos") %>% + ) %>% + tally(name = "Casos") %>% rename( "label" = "data_category" ) - - f_category_type_format_tree_1 <- data %>% + + f_category_type_format_tree_1 <- data %>% dplyr::group_by( data_category, data_type - ) %>% - dplyr::tally(name = "Casos") %>% + ) %>% + dplyr::tally(name = "Casos") %>% dplyr::rename( "parent" = "data_category", "label" = "data_type" ) - - - f_category_type_format_tree_2 <- data %>% + + + f_category_type_format_tree_2 <- data %>% dplyr::group_by( data_category, data_type, data_format - ) %>% - dplyr::tally(name = "Casos") - + ) %>% + dplyr::tally(name = "Casos") + f_category_type_format_tree_2 <- dplyr::left_join( f_category_type_format_tree_1, f_category_type_format_tree_2, by = join_by( - parent == data_category, + parent == data_category, label == data_type ) - ) %>% + ) %>% mutate( label = paste(Casos.x, label), data_format = paste(Casos.y, data_format) - ) %>% - ungroup() %>% + ) %>% + ungroup() %>% select( label, data_format, Casos.y - ) %>% + ) %>% rename( "parent" = "label", "label" = "data_format", "Casos" = "Casos.y" ) - - f_category_type_format_tree_1 <- f_category_type_format_tree_1 %>% + + f_category_type_format_tree_1 <- f_category_type_format_tree_1 %>% mutate( label = paste(Casos, label) ) - + f_category_type_format_tree <- rbind( f_category_type_format_tree_0, f_category_type_format_tree_1 - ) %>% + ) %>% rbind(., f_category_type_format_tree_2) - + fig <- plot_ly( data = f_category_type_format_tree, branchvalues = "total", type = "treemap", - #ids = ~ids, labels = ~label, parents = ~parent, values = ~Casos, - hoverinfo = 'label' + hoverinfo = "label" ) return(fig) } # category_type_format_treedt ---- category_type_format_treedt <- function(data) { - data <- data %>% + data <- data %>% dplyr::group_by( data_category, data_type, data_format - ) %>% - dplyr::tally(name = "Número de archivos") %>% + ) %>% + dplyr::tally(name = "Número de archivos") %>% rename( "Categoría de dato" = 1, "Tipo de dato" = 2, "Formato" = 3 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -111,22 +110,20 @@ category_type_format_treedt <- function(data) { ) ) return(data) - } # experimental_strategy_treemap ---- experimental_strategy_treemap <- function(data, cases) { - tree_data <- left_join( - data %>% + data %>% dplyr::select(file_id, experimental_strategy), - cases %>% + cases %>% dplyr::select(file_id, project_id), dplyr::join_by(file_id) - ) %>% + ) %>% dplyr::filter( !is.na(project_id) - ) %>% + ) %>% dplyr::mutate( project_id = case_when( is.na(project_id) ~ "Sin proyecto", @@ -136,37 +133,37 @@ experimental_strategy_treemap <- function(data, cases) { is.na(experimental_strategy) ~ "Sin dato", TRUE ~ experimental_strategy ) - ) %>% - replace(is.na(.), "Sin dato") %>% - dplyr::group_by(project_id, experimental_strategy) %>% - dplyr::tally(name = "Casos") %>% + ) %>% + replace(is.na(.), "Sin dato") %>% + dplyr::group_by(project_id, experimental_strategy) %>% + dplyr::tally(name = "Casos") %>% dplyr::mutate( experimental_strategy = paste( Casos, experimental_strategy ) - ) %>% + ) %>% dplyr::rename( "parent" = 1, "label" = 2 ) - - tree_data <- cases %>% - dplyr::select(file_id, project_id) %>% + + tree_data <- cases %>% + dplyr::select(file_id, project_id) %>% dplyr::mutate( project_id = case_when( is.na(project_id) ~ "Sin proyecto", TRUE ~ project_id ), parent = "Archivos por proyecto y estrategia experimental" - ) %>% - dplyr::group_by(parent, project_id) %>% - dplyr::tally(name = "Casos") %>% + ) %>% + dplyr::group_by(parent, project_id) %>% + dplyr::tally(name = "Casos") %>% dplyr::rename( "parent" = 1, "label" = 2 - ) %>% + ) %>% rbind(., tree_data) - + fig <- plot_ly( data = tree_data, @@ -175,7 +172,7 @@ experimental_strategy_treemap <- function(data, cases) { labels = ~label, parents = ~parent, values = ~Casos, - hoverinfo = 'label' + hoverinfo = "label" ) return(fig) } @@ -183,19 +180,19 @@ experimental_strategy_treemap <- function(data, cases) { # experimental_strategy_treedt ---- experimental_strategy_treedt <- function(data, cases) { data <- left_join( - data %>% + data %>% dplyr::select(file_id, experimental_strategy), - cases %>% + cases %>% dplyr::select(file_id, project_id), join_by(file_id) - ) %>% - group_by(project_id, experimental_strategy) %>% - tally(name = "Número de archivos") %>% - replace(is.na(.), "Sin dato") %>% + ) %>% + group_by(project_id, experimental_strategy) %>% + tally(name = "Número de archivos") %>% + replace(is.na(.), "Sin dato") %>% rename( "Proyecto" = 1, "Estrategía experimental" = 2 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -224,12 +221,13 @@ experimental_strategy_treedt <- function(data, cases) { # file_project_bar ---- file_project_bar <- function(data) { - fig <- data %>% - group_by(project_id) %>% - tally(name = "Número de archivos") %>% + fig <- data %>% + group_by(project_id) %>% + tally(name = "Número de archivos") %>% rename( "Proyecto" = 1 - ) %>% plot_ly( + ) %>% + plot_ly( x = ~`Proyecto`, y = ~`Número de archivos`, type = "bar" ) %>% layout( @@ -255,12 +253,12 @@ file_project_bar <- function(data) { # file_project_bardt ---- file_project_bardt <- function(data) { - data <- data %>% - group_by(project_id) %>% - tally(name = "Número de archivos") %>% + data <- data %>% + group_by(project_id) %>% + tally(name = "Número de archivos") %>% rename( "Proyecto" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -289,13 +287,14 @@ file_project_bardt <- function(data) { # experimental_strategy_bar ---- experimental_strategy_bar <- function(data) { - fig <- data %>% - group_by(experimental_strategy) %>% - tally(name = "Número de archivos") %>% - replace(is.na(.), "Sin dato") %>% + fig <- data %>% + group_by(experimental_strategy) %>% + tally(name = "Número de archivos") %>% + replace(is.na(.), "Sin dato") %>% rename( "Estrategía experimental" = 1 - ) %>% plot_ly( + ) %>% + plot_ly( x = ~`Estrategía experimental`, y = ~`Número de archivos`, type = "bar" ) %>% layout( @@ -321,13 +320,13 @@ experimental_strategy_bar <- function(data) { # experimental_strategy_bardt ---- experimental_strategy_bardt <- function(data) { - data <- data %>% - group_by(experimental_strategy) %>% - tally(name = "Número de archivos") %>% - replace(is.na(.), "Sin dato") %>% + data <- data %>% + group_by(experimental_strategy) %>% + tally(name = "Número de archivos") %>% + replace(is.na(.), "Sin dato") %>% rename( "Estrategía experimental" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -356,12 +355,13 @@ experimental_strategy_bardt <- function(data) { # data_category_bar ----- data_category_bar <- function(data) { - fig <- data %>% - group_by(data_category) %>% - tally(name = "Número de archivos") %>% + fig <- data %>% + group_by(data_category) %>% + tally(name = "Número de archivos") %>% rename( "Categoría de dato" = 1 - ) %>% plot_ly( + ) %>% + plot_ly( x = ~`Categoría de dato`, y = ~`Número de archivos`, type = "bar" ) %>% layout( @@ -387,13 +387,13 @@ data_category_bar <- function(data) { # data_category_bardt ----- data_category_bardt <- function(data) { - data <- data %>% - group_by(data_category) %>% - tally(name = "Número de archivos") %>% - replace(is.na(.), "Sin dato") %>% + data <- data %>% + group_by(data_category) %>% + tally(name = "Número de archivos") %>% + replace(is.na(.), "Sin dato") %>% rename( "Categoría de dato" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -422,19 +422,19 @@ data_category_bardt <- function(data) { # data_type_format_bar ---- data_type_format_bar <- function(data) { - fig <- data %>% + fig <- data %>% group_by( data_type, data_format - ) %>% - tally(name = "Número de archivos") %>% + ) %>% + tally(name = "Número de archivos") %>% plot_ly( - type = "bar", - x = ~data_type, - y = ~`Número de archivos`, - color = ~data_format, - colors = "Paired" - ) %>% + type = "bar", + x = ~data_type, + y = ~`Número de archivos`, + color = ~data_format, + colors = "Paired" + ) %>% layout( barmode = "stack", xaxis = list( @@ -462,16 +462,16 @@ data_type_format_bar <- function(data) { # data_type_format_bardt ---- data_type_format_bardt <- function(data) { - data <- data %>% + data <- data %>% group_by( data_type, data_format - ) %>% - tally(name = "Número de archivos") %>% + ) %>% + tally(name = "Número de archivos") %>% rename( "Tipo de dato" = 1, "Formato" = 2 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -500,12 +500,13 @@ data_type_format_bardt <- function(data) { # data_type_bar ---- data_type_bar <- function(data) { - fig <- data %>% - group_by(data_type) %>% - tally(name = "Número de archivos") %>% + fig <- data %>% + group_by(data_type) %>% + tally(name = "Número de archivos") %>% rename( "tipo de dato" = 1 - ) %>% plot_ly( + ) %>% + plot_ly( x = ~`tipo de dato`, y = ~`Número de archivos`, type = "bar" ) %>% layout( @@ -531,13 +532,13 @@ data_type_bar <- function(data) { # data_type_bardt ---- data_type_bardt <- function(data) { - data <- data %>% - group_by(data_type) %>% - tally(name = "Número de archivos") %>% - replace(is.na(.), "Sin dato") %>% + data <- data %>% + group_by(data_type) %>% + tally(name = "Número de archivos") %>% + replace(is.na(.), "Sin dato") %>% rename( "Tipo de dato" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -566,12 +567,13 @@ data_type_bardt <- function(data) { # data_format_bar ---- data_format_bar <- function(data) { - fig <- data %>% - group_by(data_format) %>% - tally(name = "Número de archivos") %>% + fig <- data %>% + group_by(data_format) %>% + tally(name = "Número de archivos") %>% rename( "Formato" = 1 - ) %>% plot_ly( + ) %>% + plot_ly( x = ~`Formato`, y = ~`Número de archivos`, type = "bar" ) %>% layout( @@ -597,13 +599,13 @@ data_format_bar <- function(data) { # data_format_bardt ---- data_format_bardt <- function(data) { - data <- data %>% - group_by(data_format) %>% - tally(name = "Número de archivos") %>% - replace(is.na(.), "Sin dato") %>% + data <- data %>% + group_by(data_format) %>% + tally(name = "Número de archivos") %>% + replace(is.na(.), "Sin dato") %>% rename( "Formato" = 1 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, diff --git a/Dashboard/global.R b/Dashboard/global.R index 4ffdbe1..d22ac69 100644 --- a/Dashboard/global.R +++ b/Dashboard/global.R @@ -11,7 +11,7 @@ library(htmltools) library(GenomicDataCommons) library(DT) library(BiocManager) -# options(repos = BiocManager::repositories()) + load(file = "tcga.RData") tcga_project_ids_list <- c("TODOS", tcga_project_ids_list) @@ -21,8 +21,8 @@ projects <- GenomicDataCommons::projects() %>% GenomicDataCommons::facet(c("name", "project_id")) %>% results_all() -vb_style <- function(msg = '', style="font-size: 100%;") { - tags$p( msg , style = style ) +vb_style <- function(msg = "", style = "font-size: 100%;") { + tags$p(msg, style = style) } diff --git a/Dashboard/project.R b/Dashboard/project.R index 862090d..f2a066d 100644 --- a/Dashboard/project.R +++ b/Dashboard/project.R @@ -1,54 +1,53 @@ # project_disease_type_treemap ---- project_disease_type_treemap <- function(data) { - project_disease_type_tree <- data %>% - group_by(project_id, disease_type) %>% - tally(name = "Casos") %>% + project_disease_type_tree <- data %>% + group_by(project_id, disease_type) %>% + tally(name = "Casos") %>% mutate( disease_type = paste( Casos, disease_type ) - ) %>% + ) %>% rename( "parent" = 1, "label" = 2 ) - - project_disease_type_tree <- data %>% - dplyr::select(project_id) %>% + + project_disease_type_tree <- data %>% + dplyr::select(project_id) %>% mutate( parent = "Número de casos por proyecto y por tipo de enfermedad" - ) %>% - group_by(parent, project_id) %>% - tally(name = "Casos") %>% + ) %>% + group_by(parent, project_id) %>% + tally(name = "Casos") %>% rename( "parent" = 1, "label" = 2 - ) %>% - rbind(., project_disease_type_tree) %>% + ) %>% + rbind(., project_disease_type_tree) %>% replace(is.na(.), "Sin dato") - + # project_disease_type_treemap ---- project_disease_type_treemap <- plot_ly( data = project_disease_type_tree, branchvalues = "total", type = "treemap", - #ids = ~ids, labels = ~label, parents = ~parent, values = ~Casos ) - + return(project_disease_type_treemap) } project_disease_type_treedt <- function(data) { - data <- data %>% - group_by(project_id, disease_type) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(project_id, disease_type) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename( "Proyecto" = 1, "Tipo de enfermedad" = 2 - ) %>% + ) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -77,10 +76,10 @@ project_disease_type_treedt <- function(data) { # project_bar ---- project_bar <- function(data) { - fig <- data %>% - group_by(project_id) %>% - tally(name = "Número de casos", sort = TRUE) %>% - rename("Proyecto" = 1) %>% + fig <- data %>% + group_by(project_id) %>% + tally(name = "Número de casos", sort = TRUE) %>% + rename("Proyecto" = 1) %>% plot_ly( x = ~Proyecto, y = ~`Número de casos`, type = "bar" ) %>% @@ -107,10 +106,10 @@ project_bar <- function(data) { # project_bardt ---- project_bardt <- function(data) { - data <- data %>% - group_by(project_id, project_name) %>% - tally(name = "Número de casos", sort = TRUE) %>% - rename("Proyecto" = 1, "Nombre" = 2) %>% + data <- data %>% + group_by(project_id, project_name) %>% + tally(name = "Número de casos", sort = TRUE) %>% + rename("Proyecto" = 1, "Nombre" = 2) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -139,10 +138,10 @@ project_bardt <- function(data) { # disease_type_bar ---- disease_type_bar <- function(data) { - fig <- data %>% - group_by(disease_type) %>% - tally(name = "Número de casos", sort = TRUE) %>% - rename("Tipo de enfermedad" = 1) %>% + fig <- data %>% + group_by(disease_type) %>% + tally(name = "Número de casos", sort = TRUE) %>% + rename("Tipo de enfermedad" = 1) %>% plot_ly( x = ~`Tipo de enfermedad`, y = ~`Número de casos`, type = "bar" ) %>% @@ -169,10 +168,10 @@ disease_type_bar <- function(data) { # disease_type_bardt ---- disease_type_bardt <- function(data) { - data <- data %>% - group_by(disease_type) %>% - tally(name = "Número de casos", sort = TRUE) %>% - rename("Tipo de enfermedad" = 1) %>% + data <- data %>% + group_by(disease_type) %>% + tally(name = "Número de casos", sort = TRUE) %>% + rename("Tipo de enfermedad" = 1) %>% datatable( extensions = "Buttons", rownames = FALSE, @@ -201,17 +200,17 @@ disease_type_bardt <- function(data) { # primary_site_bar ---- primary_site_bar <- function(data) { - data <- data %>% - group_by(primary_site) %>% - tally(name = "Número de casos", sort = TRUE) %>% + data <- data %>% + group_by(primary_site) %>% + tally(name = "Número de casos", sort = TRUE) %>% rename("Sitio primario" = 1) - + xticks_labels <- as.list(substr(data$`Sitio primario`, 1, 30)) - + fig <- plot_ly( - data, - x = ~`Sitio primario`, y = ~`Número de casos`, type = "bar" - ) %>% + data, + x = ~`Sitio primario`, y = ~`Número de casos`, type = "bar" + ) %>% layout( xaxis = list( title = "Sitio primario", @@ -238,10 +237,10 @@ primary_site_bar <- function(data) { # primary_site_bardt ---- primary_site_bardt <- function(data) { - data <- data %>% - group_by(primary_site) %>% - tally(name = "Número de casos", sort = TRUE) %>% - rename("Sitio primario" = 1) %>% + data <- data %>% + group_by(primary_site) %>% + tally(name = "Número de casos", sort = TRUE) %>% + rename("Sitio primario" = 1) %>% datatable( extensions = "Buttons", rownames = FALSE, diff --git a/Dashboard/server.R b/Dashboard/server.R index f37335e..56c4b1c 100644 --- a/Dashboard/server.R +++ b/Dashboard/server.R @@ -24,172 +24,173 @@ function(input, output, session) { projects <- projects %>% GenomicDataCommons::results_all() }) - + ## combined_cases_reactive ---- combined_cases_reactive <- reactive({ combined_cases_reactive <- combined_cases - - if(input$project_id != "TODOS") { - combined_cases_reactive <- combined_cases_reactive %>% + + if (input$project_id != "TODOS") { + combined_cases_reactive <- combined_cases_reactive %>% dplyr::filter(project_id == input$project_id) } - + if (input$disease_type != "TODOS") { - combined_cases_reactive <- combined_cases_reactive %>% + combined_cases_reactive <- combined_cases_reactive %>% dplyr::filter(disease_type == input$disease_type) } - + if (input$primary_site != "TODOS") { - combined_cases_reactive <- combined_cases_reactive %>% - dplyr::filter(primary_site == input$primary_site) + combined_cases_reactive <- combined_cases_reactive %>% + dplyr::filter(primary_site == input$primary_site) } combined_cases_reactive }) - + ## combined_demographics_reactive ---- combined_demographics_reactive <- reactive({ combined_demographics_reactive <- combined_demographics - + if (input$age_at_index_na) { - combined_demographics_reactive <- combined_demographics_reactive %>% + combined_demographics_reactive <- combined_demographics_reactive %>% dplyr::filter( (age_at_index >= input$age_at_index[1] & age_at_index <= input$age_at_index[2]) | is.na(age_at_index) ) } else { - combined_demographics_reactive <- combined_demographics_reactive %>% + combined_demographics_reactive <- combined_demographics_reactive %>% dplyr::filter( !is.na(age_at_index), (age_at_index >= input$age_at_index[1] & age_at_index <= input$age_at_index[2]) ) } - + if (input$race != "TODOS") { - combined_demographics_reactive <- combined_demographics_reactive %>% + combined_demographics_reactive <- combined_demographics_reactive %>% dplyr::filter( race == input$race ) } - + if (input$ethnicity != "TODOS") { - combined_demographics_reactive <- combined_demographics_reactive %>% + combined_demographics_reactive <- combined_demographics_reactive %>% dplyr::filter( ethnicity == input$ethnicity ) } - + if (input$vital_status != "TODOS") { - combined_demographics_reactive <- combined_demographics_reactive %>% + combined_demographics_reactive <- combined_demographics_reactive %>% dplyr::filter( vital_status == input$vital_status ) } - + if (input$gender != "TODOS") { - combined_demographics_reactive <- combined_demographics_reactive %>% + combined_demographics_reactive <- combined_demographics_reactive %>% dplyr::filter( gender == input$gender ) } - + combined_demographics_reactive }) - + ## combined_diagnosis_reactive ---- combined_diagnoses_reactive <- reactive({ combined_diagnoses_reactive <- combined_diagnoses - + if (input$age_at_diagnosis_na) { - combined_diagnoses_reactive <- combined_diagnoses_reactive %>% + combined_diagnoses_reactive <- combined_diagnoses_reactive %>% dplyr::filter( (age_at_diagnosis_years >= input$age_at_diagnosis[1] & - age_at_diagnosis_years <= input$age_at_diagnosis[2]) | + age_at_diagnosis_years <= input$age_at_diagnosis[2]) | is.na(age_at_diagnosis_years) ) } else { - combined_diagnoses_reactive <- combined_diagnoses_reactive %>% + combined_diagnoses_reactive <- combined_diagnoses_reactive %>% dplyr::filter( !is.na(age_at_diagnosis_years), (age_at_diagnosis_years >= input$age_at_diagnosis[1] & age_at_diagnosis_years <= input$age_at_diagnosis[2]) ) } - - if (input$tissue_or_organ_of_origin != "TODOS") - combined_diagnoses_reactive <- combined_diagnoses_reactive %>% + + if (input$tissue_or_organ_of_origin != "TODOS") { + combined_diagnoses_reactive <- combined_diagnoses_reactive %>% dplyr::filter( tissue_or_organ_of_origin == input$tissue_or_organ_of_origin ) - + } + if (input$primary_diagnosis != "TODOS") { - combined_diagnoses_reactive <- combined_diagnoses_reactive %>% + combined_diagnoses_reactive <- combined_diagnoses_reactive %>% dplyr::filter( primary_diagnosis == input$primary_diagnosis ) } - + if (input$ajcc_pathologic_stage != "TODOS") { - combined_diagnoses_reactive <- combined_diagnoses_reactive %>% + combined_diagnoses_reactive <- combined_diagnoses_reactive %>% dplyr::filter( ajcc_pathologic_stage == input$ajcc_pathologic_stage ) } - + combined_diagnoses_reactive }) - - + + ## files_results_reactive ---- files_results_reactive <- reactive({ files_results_reactive <- files_results - + if (input$experimental_strategy != "TODOS") { - files_results_reactive <- files_results_reactive %>% + files_results_reactive <- files_results_reactive %>% dplyr::filter( experimental_strategy == input$experimental_strategy ) } - + if (input$data_category != "TODOS") { - files_results_reactive <- files_results_reactive %>% + files_results_reactive <- files_results_reactive %>% dplyr::filter( data_category == input$data_category ) } - + if (input$data_type != "TODOS") { - files_results_reactive <- files_results_reactive %>% + files_results_reactive <- files_results_reactive %>% dplyr::filter( data_type == input$data_type ) } - + if (input$data_format != "TODOS") { - files_results_reactive <- files_results_reactive %>% + files_results_reactive <- files_results_reactive %>% dplyr::filter( data_format == input$data_format ) } - + files_results_reactive }) - + ## files_cases_reactive ---- files_cases_reactive <- reactive({ - files_cases_reactive <- files_cases %>% + files_cases_reactive <- files_cases %>% dplyr::filter( file_id %in% files_results_reactive()$file_id ) - + files_cases_reactive }) - + ## case_ids_list ---- case_ids <- reactiveValues() case_ids$case_id <- case_id_list - + ### Observers ---- ## disease_type filter ---- diseases_types_reactive <- reactive({ @@ -212,7 +213,6 @@ function(input, output, session) { # primary_site filter ---- primary_site_reactive <- reactive({ unique(combined_cases_reactive()$primary_site) - }) primary_site_list <- reactive({ @@ -227,17 +227,16 @@ function(input, output, session) { selected = input$primary_site ) }) - + # tissue_or_organ_of_origin filter ---- tissue_or_organ_of_origin_reactive <- reactive({ unique(combined_diagnoses_reactive()$tissue_or_organ_of_origin) - }) - + tissue_or_organ_of_origin_list <- reactive({ c("TODOS", tissue_or_organ_of_origin_reactive()) }) - + observe({ updateSelectInput( session, @@ -246,17 +245,16 @@ function(input, output, session) { selected = input$tissue_or_organ_of_origin ) }) - + # primary_diagnosis filter ---- primary_diagnosis_reactive <- reactive({ unique(combined_diagnoses_reactive()$primary_diagnosis) - }) - + primary_diagnosis_list <- reactive({ c("TODOS", primary_diagnosis_reactive()) }) - + observe({ updateSelectInput( session, @@ -265,17 +263,16 @@ function(input, output, session) { selected = input$primary_diagnosis ) }) - + # ajcc_pathologic_stage_reactive filter ---- ajcc_pathologic_stage_reactive <- reactive({ unique(combined_diagnoses_reactive()$ajcc_pathologic_stage) - }) - + ajcc_pathologic_stage_list <- reactive({ c("TODOS", ajcc_pathologic_stage_reactive()) }) - + observe({ updateSelectInput( session, @@ -284,20 +281,19 @@ function(input, output, session) { selected = input$ajcc_pathologic_stage ) }) - + # race_reactive filter ---- race_reactive <- reactive({ unique(combined_demographics_reactive()[ !is.na(combined_demographics_reactive()$race), "race" ]) - }) - + race_list <- reactive({ c("TODOS", race_reactive()) }) - + observe({ updateSelectInput( session, @@ -306,20 +302,19 @@ function(input, output, session) { selected = input$race ) }) - + # ethnicity_reactive filter ---- ethnicity_reactive <- reactive({ unique(combined_demographics_reactive()[ !is.na(combined_demographics_reactive()$ethnicity), "ethnicity" ]) - }) - + ethnicity_list <- reactive({ c("TODOS", ethnicity_reactive()) }) - + observe({ updateSelectInput( session, @@ -328,20 +323,19 @@ function(input, output, session) { selected = input$ethnicity ) }) - + # vital_status_reactive filter ---- vital_status_reactive <- reactive({ unique(combined_demographics_reactive()[ !is.na(combined_demographics_reactive()$vital_status), "vital_status" ]) - }) - + vital_status_list <- reactive({ c("TODOS", vital_status_reactive()) }) - + observe({ updateSelectInput( session, @@ -350,20 +344,19 @@ function(input, output, session) { selected = input$vital_status ) }) - + # gender_reactive filter ---- gender_reactive <- reactive({ unique(combined_demographics_reactive()[ !is.na(combined_demographics_reactive()$gender), "gender" ]) - }) - + gender_list <- reactive({ c("TODOS", gender_reactive()) }) - + observe({ updateSelectInput( session, @@ -372,20 +365,19 @@ function(input, output, session) { selected = input$gender ) }) - + # experimental_strategy_reactive filter ---- experimental_strategy_reactive <- reactive({ unique(files_results_reactive()[ !is.na(files_results_reactive()$experimental_strategy), "experimental_strategy" ]) - }) - + experimental_strategy_list <- reactive({ c("TODOS", experimental_strategy_reactive()) }) - + observe({ updateSelectInput( session, @@ -394,20 +386,19 @@ function(input, output, session) { selected = input$experimental_strategy ) }) - + # data_category_reactive filter ---- data_category_reactive <- reactive({ unique(files_results_reactive()[ !is.na(files_results_reactive()$data_category), "data_category" ]) - }) - + data_category_list <- reactive({ c("TODOS", data_category_reactive()) }) - + observe({ updateSelectInput( session, @@ -416,20 +407,19 @@ function(input, output, session) { selected = input$data_category ) }) - + # data_type_reactive filter ---- data_type_reactive <- reactive({ unique(files_results_reactive()[ !is.na(files_results_reactive()$data_type), "data_type" ]) - }) - + data_type_list <- reactive({ c("TODOS", data_type_reactive()) }) - + observe({ updateSelectInput( session, @@ -438,20 +428,19 @@ function(input, output, session) { selected = input$data_type ) }) - + # data_format_reactive filter ---- data_format_reactive <- reactive({ unique(files_results_reactive()[ !is.na(files_results_reactive()$data_format), "data_format" ]) - }) - + data_format_list <- reactive({ c("TODOS", data_format_reactive()) }) - + observe({ updateSelectInput( session, @@ -462,14 +451,14 @@ function(input, output, session) { }) - + ## Explorer ---- ### Value boxes ---- box_data <- reactiveValues() box_data$proyectos <- 0 box_data$casos <- 0 box_data$disease_type <- 0 - + #### Boxes ---- ##### Proyectos ---- output$box_proyectos <- renderValueBox({ @@ -484,7 +473,7 @@ function(input, output, session) { color = "purple" ) }) - + ##### Casos ---- output$box_casos <- renderValueBox({ valueBox( @@ -498,7 +487,7 @@ function(input, output, session) { color = "purple" ) }) - + ##### disease_type ---- output$box_disease_type <- renderValueBox({ valueBox( @@ -512,9 +501,9 @@ function(input, output, session) { color = "purple" ) }) - + ### Observers ---- - + #### Observe project_id ---- observeEvent(input$project_id, { case_ids$case_id <- unique( @@ -522,22 +511,22 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), files_cases_reactive()$case_id ) ) - + file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -545,7 +534,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -558,7 +547,7 @@ function(input, output, session) { ] ) ) - + box_data$archivos <- length( unique( files_results_reactive()[ @@ -567,9 +556,8 @@ function(input, output, session) { ] ) ) - }) - + #### Observe disease_type ---- observeEvent(input$disease_type, { case_ids$case_id <- unique( @@ -577,7 +565,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -587,11 +575,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -599,7 +587,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -607,12 +595,12 @@ function(input, output, session) { box_data$disease_type <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "disease_type" ] ) ) - + box_data$archivos <- length( unique( files_results_reactive()[ @@ -622,7 +610,7 @@ function(input, output, session) { ) ) }) - + #### Observe primary_site ---- observeEvent(input$primary_site, { case_ids$case_id <- unique( @@ -630,7 +618,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -640,7 +628,7 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ @@ -652,7 +640,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -660,7 +648,7 @@ function(input, output, session) { box_data$disease_type <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "disease_type" ] ) @@ -673,9 +661,8 @@ function(input, output, session) { ] ) ) - }) - + #### Observe age_at_diagnosis ---- observeEvent(input$age_at_diagnosis, { case_ids$case_id <- unique( @@ -683,7 +670,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -693,11 +680,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -705,7 +692,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -727,7 +714,7 @@ function(input, output, session) { ) ) }) - + #### Observe age_at_diagnosis_na ---- observeEvent(input$age_at_diagnosis_na, { case_ids$case_id <- unique( @@ -735,7 +722,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -745,11 +732,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -757,7 +744,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -779,7 +766,7 @@ function(input, output, session) { ) ) }) - + #### Observe tissue_or_organ_of_origin ---- observeEvent(input$tissue_or_organ_of_origin, { case_ids$case_id <- unique( @@ -787,7 +774,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -797,11 +784,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -809,7 +796,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -831,7 +818,7 @@ function(input, output, session) { ) ) }) - + #### Observe primary_diagnosis ---- observeEvent(input$primary_diagnosis, { case_ids$case_id <- unique( @@ -839,7 +826,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -849,11 +836,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -861,7 +848,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -883,7 +870,7 @@ function(input, output, session) { ) ) }) - + #### Observe ajcc_pathologic_stage ---- observeEvent(input$ajcc_pathologic_stage, { case_ids$case_id <- unique( @@ -891,7 +878,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -901,11 +888,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -913,7 +900,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -935,7 +922,7 @@ function(input, output, session) { ) ) }) - + #### Observe race ---- observeEvent(input$race, { case_ids$case_id <- unique( @@ -943,7 +930,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -953,11 +940,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -965,7 +952,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -987,7 +974,7 @@ function(input, output, session) { ) ) }) - + #### Observe ethnicity ---- observeEvent(input$ethnicity, { case_ids$case_id <- unique( @@ -995,7 +982,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1005,11 +992,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1017,7 +1004,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1039,7 +1026,7 @@ function(input, output, session) { ) ) }) - + #### Observe vital_status ---- observeEvent(input$vital_status, { case_ids$case_id <- unique( @@ -1047,7 +1034,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1057,11 +1044,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1069,7 +1056,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1091,7 +1078,7 @@ function(input, output, session) { ) ) }) - + #### Observe gender ---- observeEvent(input$gender, { case_ids$case_id <- unique( @@ -1099,7 +1086,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1109,11 +1096,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1121,7 +1108,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1143,7 +1130,7 @@ function(input, output, session) { ) ) }) - + #### Observe age_at_index ---- observeEvent(input$age_at_index, { case_ids$case_id <- unique( @@ -1151,7 +1138,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1161,11 +1148,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1173,7 +1160,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1195,9 +1182,9 @@ function(input, output, session) { ) ) }) - - + + #### Observe age_at_index_na ---- observeEvent(input$age_at_index_na, { case_ids$case_id <- unique( @@ -1205,7 +1192,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1215,11 +1202,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1227,7 +1214,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1249,7 +1236,7 @@ function(input, output, session) { ) ) }) - + #### Observe experimental_strategy ---- observeEvent(input$experimental_strategy, { case_ids$case_id <- unique( @@ -1257,7 +1244,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1267,11 +1254,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1279,7 +1266,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1301,7 +1288,7 @@ function(input, output, session) { ) ) }) - + #### Observe data_category ---- observeEvent(input$data_category, { case_ids$case_id <- unique( @@ -1309,7 +1296,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1319,11 +1306,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1331,7 +1318,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1353,7 +1340,7 @@ function(input, output, session) { ) ) }) - + #### Observe data_type ---- observeEvent(input$data_type, { case_ids$case_id <- unique( @@ -1361,7 +1348,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1371,11 +1358,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1383,7 +1370,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1405,7 +1392,7 @@ function(input, output, session) { ) ) }) - + #### Observe data_format ---- observeEvent(input$data_format, { case_ids$case_id <- unique( @@ -1413,7 +1400,7 @@ function(input, output, session) { intersect( intersect( combined_diagnoses_reactive()$case_id, - combined_demographics_reactive()$case_id + combined_demographics_reactive()$case_id ), combined_cases_reactive()$case_id ), @@ -1423,11 +1410,11 @@ function(input, output, session) { file_ids$file_id <- unique( files_results_reactive()$file_id ) - + box_data$proyectos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "project_id" ] ) @@ -1435,7 +1422,7 @@ function(input, output, session) { box_data$casos <- length( unique( combined_cases_reactive()[ - combined_cases_reactive()$case_id %in% case_ids$case_id, + combined_cases_reactive()$case_id %in% case_ids$case_id, "case_id" ] ) @@ -1457,296 +1444,296 @@ function(input, output, session) { ) ) }) - + ### Project ---- #### project_disease_type_treemap ---- output$project_disease_type_treemap <- renderPlotly({ project_disease_type_treemap( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### project_disease_type_treedt ---- output$project_disease_type_treedt <- DT::renderDataTable({ project_disease_type_treedt( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### project_bar ---- output$project_bar <- renderPlotly({ project_bar( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### project_bardt ---- output$project_bardt <- DT::renderDataTable({ project_bardt( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### disease_type ---- output$disease_type_bar <- renderPlotly({ disease_type_bar( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### disease_typedt ---- output$disease_type_bardt <- DT::renderDataTable({ disease_type_bardt( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### primary_site_bar ---- output$primary_site_bar <- renderPlotly({ primary_site_bar( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### primary_site_bardt ---- output$primary_site_bardt <- DT::renderDataTable({ primary_site_bardt( - combined_cases_reactive() %>% + combined_cases_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + ### Diagnosis ---- #### primary_diagnosis_treemap ---- output$primary_diagnosis_treemap <- renderPlotly({ primary_diagnosis_treemap( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### primary_diagnosis_treedt ---- output$primary_diagnosis_treedt <- DT::renderDataTable({ primary_diagnosis_treedt( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### pathologic_stage_treemap ---- output$pathologic_stage_treemap <- renderPlotly({ pathologic_stage_treemap( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### pathologic_stage_treedt ---- output$pathologic_stage_treedt <- DT::renderDataTable({ pathologic_stage_treedt( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### tissue_origin_bar ---- output$tissue_origin_bar <- renderPlotly({ tissue_origin_bar( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### tissue_origin_bardt ---- output$tissue_origin_bardt <- DT::renderDataTable({ tissue_origin_bardt( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### primary_diagnosis_bar ---- output$primary_diagnosis_bar <- renderPlotly({ primary_diagnosis_bar( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### primary_diagnosis_bardt ---- output$primary_diagnosis_bardt <- DT::renderDataTable({ primary_diagnosis_bardt( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### pathologic_stage_bar ---- output$pathologic_stage_bar <- renderPlotly({ pathologic_stage_bar( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### pathologic_stage_bardt ---- output$pathologic_stage_bardt <- DT::renderDataTable({ pathologic_stage_bardt( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### age_at_diagnosis_bar ---- output$age_at_diagnosis_bar <- renderPlotly({ age_at_diagnosis_bar( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### age_at_diagnosis_bardt ---- output$age_at_diagnosis_bardt <- DT::renderDataTable({ age_at_diagnosis_bardt( - combined_diagnoses_reactive() %>% + combined_diagnoses_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + ## Demographics ---- #### race_pie ---- output$race_pie <- renderPlotly({ race_pie( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### race_piedt ---- output$race_piedt <- DT::renderDataTable({ race_piedt( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### ethnicity_pie ---- output$ethnicity_pie <- renderPlotly({ ethnicity_pie( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### ethnicity_piedt ---- output$ethnicity_piedt <- DT::renderDataTable({ ethnicity_piedt( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### vital_status_pie ---- output$vital_status_pie <- renderPlotly({ vital_status_pie( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### vital_status_piedt ---- output$vital_status_piedt <- DT::renderDataTable({ vital_status_piedt( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### gender_age_pyramid ---- output$gender_age_pyramid <- renderPlotly({ gender_age_pyramid( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + #### gender_age_pyramiddt ---- output$gender_age_pyramiddt <- DT::renderDataTable({ gender_age_pyramiddt( - combined_demographics_reactive() %>% + combined_demographics_reactive() %>% dplyr::filter( case_id %in% case_ids$case_id ) ) }) - + ## Files ---- ## file_ids_list ---- file_ids <- reactiveValues() file_ids$file_id <- file_id_list - + ### Value boxes ---- box_data$archivos <- 0 ##### Proyectos ---- @@ -1762,7 +1749,7 @@ function(input, output, session) { color = "purple" ) }) - + ##### Casos ---- output$box_f_casos <- renderValueBox({ valueBox( @@ -1776,7 +1763,7 @@ function(input, output, session) { color = "purple" ) }) - + ##### Archivos ---- output$box_f_archivos <- renderValueBox({ valueBox( @@ -1790,73 +1777,73 @@ function(input, output, session) { color = "purple" ) }) - + ### Treemaps ---- #### experimental_strategy_treemap ---- output$experimental_strategy_treemap <- renderPlotly({ experimental_strategy_treemap( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ), - files_cases_reactive() %>% + files_cases_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id & case_id %in% case_ids$case_id ) ) }) - + #### experimental_strategy_treedt ---- output$experimental_strategy_treedt <- DT::renderDataTable({ experimental_strategy_treedt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ), - files_cases_reactive() %>% + files_cases_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id & case_id %in% case_ids$case_id ) ) }) - + #### category_type_format_treemap ---- output$category_type_format_treemap <- renderPlotly({ category_type_format_treemap( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### category_type_format_treedt ---- output$category_type_format_treedt <- DT::renderDataTable({ category_type_format_treedt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### file_project_bar ---- output$file_project_bar <- renderPlotly({ file_project_bar( - files_cases_reactive() %>% + files_cases_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id & case_id %in% case_ids$case_id ) ) }) - + #### file_project_bardt ---- output$file_project_bardt <- DT::renderDataTable({ file_project_bardt( - files_cases_reactive() %>% + files_cases_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id & case_id %in% case_ids$case_id @@ -1867,100 +1854,100 @@ function(input, output, session) { #### experimental_strategy_bar ---- output$experimental_strategy_bar <- renderPlotly({ experimental_strategy_bar( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### experimental_strategy_bardt ---- output$experimental_strategy_bardt <- DT::renderDataTable({ experimental_strategy_bardt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_category_bar ---- output$data_category_bar <- renderPlotly({ data_category_bar( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_category_bardt ---- output$data_category_bardt <- DT::renderDataTable({ data_category_bardt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_type_format_bar ---- output$data_type_format_bar <- renderPlotly({ data_type_format_bar( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_type_format_bardt ---- output$data_type_format_bardt <- DT::renderDataTable({ data_type_format_bardt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_type_bar ---- output$data_type_bar <- renderPlotly({ data_type_bar( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_type_bardt ---- output$data_type_bardt <- DT::renderDataTable({ data_type_bardt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_format_bar ---- output$data_format_bar <- renderPlotly({ data_format_bar( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - + #### data_format_bardt ---- output$data_format_bardt <- DT::renderDataTable({ data_format_bardt( - files_results_reactive() %>% + files_results_reactive() %>% dplyr::filter( file_id %in% file_ids$file_id ) ) }) - } +} diff --git a/Dashboard/ui.R b/Dashboard/ui.R index 5115e72..558f097 100644 --- a/Dashboard/ui.R +++ b/Dashboard/ui.R @@ -113,7 +113,7 @@ fluidPage( label = "Edad al diagnostico", min = min_diagnosis_age, max = max_diagnosis_age, - value = c(min_diagnosis_age,max_diagnosis_age) + value = c(min_diagnosis_age, max_diagnosis_age) ), bsTooltip( "disease_type", @@ -179,7 +179,7 @@ fluidPage( label = "Edad", min = min_age, max = max_age, - value = c(min_diagnosis_age,max_diagnosis_age) + value = c(min_diagnosis_age, max_diagnosis_age) ), bsTooltip( "age_at_index", @@ -716,8 +716,8 @@ fluidPage( # experimental_strategy_treedt ---- tabPanel( title = paste( - "Cuadro de datos de proyectos y estrategía experimental") - , + "Cuadro de datos de proyectos y estrategía experimental" + ), icon = icon("table"), shinycssloaders::withSpinner( DT::dataTableOutput("experimental_strategy_treedt"), @@ -746,8 +746,8 @@ fluidPage( # category_type_format_treedt ---- tabPanel( title = paste( - "Cuadro de datos categoría, tipo y formato") - , + "Cuadro de datos categoría, tipo y formato" + ), icon = icon("table"), shinycssloaders::withSpinner( DT::dataTableOutput("category_type_format_treedt"), diff --git a/run.R b/run.R index 9a868cb..86586b0 100644 --- a/run.R +++ b/run.R @@ -4,4 +4,4 @@ setwd(dirname(rstudioapi::getSourceEditorContext()$path)) rm(list = ls()) source("setup.R") -runApp('Dashboard') +runApp("Dashboard") diff --git a/setup.R b/setup.R index 62d3b6d..31ca5e6 100644 --- a/setup.R +++ b/setup.R @@ -2,17 +2,17 @@ library(GenomicDataCommons) library(dplyr) # setup ---- -path_global = dirname(rstudioapi::getSourceEditorContext()$path) +path_global <- dirname(rstudioapi::getSourceEditorContext()$path) # Get diagnosis, demographic and project ---- -expands = c("diagnoses", "demographic", "project") -clin_results = cases() %>% +expands <- c("diagnoses", "demographic", "project") +clin_results <- cases() %>% GenomicDataCommons::select( c( "disease_type", "primary_site" ) - ) %>% + ) %>% GenomicDataCommons::filter(project.program.name == "TCGA") %>% GenomicDataCommons::expand(expands) %>% GenomicDataCommons::results_all() @@ -22,7 +22,7 @@ combined_cases <- data.frame( case_id = clin_results$case_id, project_id = clin_results$project$project_id, project_name = clin_results$project$name -) %>% +) %>% left_join( ., data.frame( @@ -38,21 +38,21 @@ combined_cases <- data.frame( combined_diagnoses <- lapply( clin_results$diagnoses, function(inner_list) inner_list ) %>% - bind_rows(.id = "case_id") %>% + bind_rows(.id = "case_id") %>% select( where( - ~!all(is.na(.x)) + ~ !all(is.na(.x)) ) ) -combined_diagnoses$age_at_diagnosis_years = floor( +combined_diagnoses$age_at_diagnosis_years <- floor( combined_diagnoses$age_at_diagnosis / 365 ) # combined_demographics ---- -combined_demographics <- as.data.frame(clin_results$demographic) %>% +combined_demographics <- as.data.frame(clin_results$demographic) %>% select( where( - ~!all(is.na(.x)) + ~ !all(is.na(.x)) ) ) combined_demographics$case_id <- rownames(combined_demographics) @@ -65,7 +65,7 @@ files_info <- GenomicDataCommons::files() %>% ) %>% GenomicDataCommons::filter( access == "open" - ) %>% + ) %>% GenomicDataCommons::facet( c( "data_category", @@ -80,13 +80,13 @@ files_info <- GenomicDataCommons::files() %>% aggregations() # files_result ---- -files_results <- GenomicDataCommons::files() %>% +files_results <- GenomicDataCommons::files() %>% GenomicDataCommons::filter( cases.project.program.name == "TCGA" ) %>% GenomicDataCommons::filter( access == "open" - ) %>% + ) %>% GenomicDataCommons::select( c( "cases.project.project_id", @@ -97,24 +97,24 @@ files_results <- GenomicDataCommons::files() %>% "experimental_strategy", "wgs_coverage" ) - ) %>% + ) %>% GenomicDataCommons::results_all() # files_cases ---- files_cases <- lapply( files_results$cases, function(inner_list) inner_list ) %>% - bind_rows(.id = "file_id") %>% + bind_rows(.id = "file_id") %>% select( where( - ~!all(is.na(.x)) + ~ !all(is.na(.x)) ) - ) %>% + ) %>% unnest(., project) files_results <- as.data.frame( within(files_results, rm(cases)) -) %>% +) %>% select(-id) tcga_project_ids_list <- unique(combined_cases$project_id)