From aa25d81ce8223f9aa82251d3b31d38063b1288f2 Mon Sep 17 00:00:00 2001 From: lishensuo <80585985+lishensuo@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:26:33 +0800 Subject: [PATCH] Modify some UI details --- NEWS.md | 8 +++--- R/query_general.R | 6 ++++- R/vis_dim_dist.R | 4 +-- R/vis_identifier_dim_dist.R | 4 +-- inst/shinyapp/helper/cross_pw.md | 2 +- .../01_general/modules-ga-dim-distribution.R | 2 +- .../modules/02_quick/modules-1-tcga-11-Dim.R | 2 +- .../06_tpc_func/modules-z-download-feat.R | 4 ++- .../08_other_page/home-pancan-search.R | 27 +++++++++++++------ inst/shinyapp/server/modules.R | 2 +- .../shinyapp/shiny-doc/intro_personal_pips.md | 4 +-- inst/shinyapp/shiny-doc/intro_quick_mods.md | 4 +-- inst/shinyapp/ui/link2advanced.R | 4 +-- inst/shinyapp/ui/pancan-analysis-quick.R | 4 +-- man/vis_dim_dist.Rd | 6 ++--- man/vis_identifier_dim_dist.Rd | 4 +-- 16 files changed, 52 insertions(+), 35 deletions(-) diff --git a/NEWS.md b/NEWS.md index 461a49b0..9f8afec3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -37,8 +37,8 @@ See the [UCSCXenaShiny v2 Book](https://lishensuo.github.io/UCSCXenaShiny_Book/i - `.opt_pancan` : Default setting for alternative TPC datasets. - `mol_quick_analysis()`: Quick molecule analysis and report generation based on TCGA dataset. - `query_tcga_group()`: Group TPC samples by build-in or custom phenotype and support filtering or merging operations. -- `vis_dim_dist()`: Visualize the distribution difference of TCGA samples after dimension reduction analysis. -- `vis_identifier_dim_dist()`: Visualize the distribution difference of samples after Molecule Identifier dimension reduction analysis. +- `vis_dim_dist()`: Visualize the distribution difference of TCGA samples after dimensionality reduction analysis. +- `vis_identifier_dim_dist()`: Visualize the distribution difference of samples after Molecule Identifier dimensionality reduction analysis. - `vis_toil_Mut()`: Visualize molecular profile difference between mutation and wild status of queried gene. - `vis_toil_Mut_cancer()`: Visualize molecular profile difference between mutation and wild status of queried gene in Single Cancer Type @@ -50,13 +50,13 @@ See the [UCSCXenaShiny v2 Book](https://lishensuo.github.io/UCSCXenaShiny_Book/i - General Dataset Analysis - - Added one general dimension reduction analysis module. + - Added one general dimensionality reduction analysis module. - Quick TPC Analysis - Added one module for association analysis between molecule and pathway; - Added one module for association analysis between molecule and mutation; - - Added one module for dimension reduction analysis. + - Added one module for dimensionality reduction analysis. - Personalized Analysis diff --git a/R/query_general.R b/R/query_general.R index e9ead253..07ca2f71 100644 --- a/R/query_general.R +++ b/R/query_general.R @@ -425,7 +425,11 @@ mol_quick_analysis <- function(molecule, data_type, out_dir = ".", out_report = print("##### Step1: Query the moleluce value... #####") mol_data <- query_pancan_value(molecule, data_type = data_type, database = "toil") if (is.list(mol_data)) mol_data <- mol_data[[1]] - + + if (all(is.na(mol_data))) { + message("All NAs returned, return NULL instead.") + return(NULL) + } print(paste0("=== ", "Clinical phenotype")) mol_data_df <- suppressMessages(data.frame( diff --git a/R/vis_dim_dist.R b/R/vis_dim_dist.R index edaf42be..77791211 100644 --- a/R/vis_dim_dist.R +++ b/R/vis_dim_dist.R @@ -1,9 +1,9 @@ -#' Visualize the distribution difference of samples after dimension reduction analysis +#' Visualize the distribution difference of samples after dimensionality reduction analysis #' #' @param ids molecular identifiers (>=3) #' @param data_type molecular types, refer to query_pancan_value() function #' @param group_info two-column grouping information with names 'Sample','Group' -#' @param DR_method the dimension reduction method +#' @param DR_method the dimensionality reduction method #' @param palette the color setting of RColorBrewer #' @param add_margin the marginal plot (NULL, "density", "boxplot") #' @param opt_pancan specify one dataset for some molercular profiles diff --git a/R/vis_identifier_dim_dist.R b/R/vis_identifier_dim_dist.R index d847893f..1c8559ce 100644 --- a/R/vis_identifier_dim_dist.R +++ b/R/vis_identifier_dim_dist.R @@ -1,4 +1,4 @@ -#' Visualize the distribution difference of samples after Molecule Identifier dimension reduction analysis +#' Visualize the distribution difference of samples after Molecule Identifier dimensionality reduction analysis #' #' NOTE: the dataset must be dense matrix in UCSC Xena data hubs. #' @@ -10,7 +10,7 @@ #' - The second column refers to groups indicated in axis X. #' @param samples default is `NULL`, can be common sample names for two datasets. #' @param return.data whether to reture the raw meta/matrix data (list) instead of plot -#' @param DR_method the dimension reduction method +#' @param DR_method the dimensionality reduction method #' @param add_margin the marginal plot (NULL, "density", "boxplot") #' @param palette the color setting of RColorBrewer #' diff --git a/inst/shinyapp/helper/cross_pw.md b/inst/shinyapp/helper/cross_pw.md index 97ea02ce..06a020e5 100644 --- a/inst/shinyapp/helper/cross_pw.md +++ b/inst/shinyapp/helper/cross_pw.md @@ -33,7 +33,7 @@ -helper_cross_pw +helper_cross_pw diff --git a/inst/shinyapp/modules/01_general/modules-ga-dim-distribution.R b/inst/shinyapp/modules/01_general/modules-ga-dim-distribution.R index 99086302..4f7600f4 100644 --- a/inst/shinyapp/modules/01_general/modules-ga-dim-distribution.R +++ b/inst/shinyapp/modules/01_general/modules-ga-dim-distribution.R @@ -216,7 +216,7 @@ server.modules_ga_dim_distribution <- function( show_table <- selected_database_add_url_and_phenotype() selectInput( inputId = ns("ga_data2_id"), - label = "Select dataset for DR(Dimension Reduction):", + label = "Select dataset for DR(Dimensionality reduction):", choices = c("NONE", unique(show_table$XenaDatasets)), selected = "NONE", multiple = FALSE diff --git a/inst/shinyapp/modules/02_quick/modules-1-tcga-11-Dim.R b/inst/shinyapp/modules/02_quick/modules-1-tcga-11-Dim.R index 351385c5..6c627c3f 100644 --- a/inst/shinyapp/modules/02_quick/modules-1-tcga-11-Dim.R +++ b/inst/shinyapp/modules/02_quick/modules-1-tcga-11-Dim.R @@ -182,7 +182,7 @@ ui.modules_1_tcga_11 = function(id){ box(main_ui, width = 5, solidHeader = TRUE, - title = "Quick TCGA Analysis: Dimension reduction analysis", + title = "Quick TCGA Analysis: Dimensionality reduction analysis", status = "warning", background = "gray", collapsible = FALSE, diff --git a/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R b/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R index 89847291..70abd629 100644 --- a/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R +++ b/inst/shinyapp/modules/06_tpc_func/modules-z-download-feat.R @@ -264,7 +264,7 @@ download_feat_Server = function(input, output, session, database = "toil",#id_op x_data$cancer = clinical_phe[,2,drop=T][match(x_data$Sample, clinical_phe$Sample)] x_data = x_data[,c("id","level1","level2","Sample","value","cancer")] %>% dplyr::arrange(cancer,Sample) - shinyjs::enable("query_data") + # shinyjs::enable("query_data") x_data }) @@ -276,6 +276,8 @@ download_feat_Server = function(input, output, session, database = "toil",#id_op output$x_axis_data_table = renderUI({ if(table.ui){ output$x_tmp_table = renderDataTable({ + shinyjs::enable("query_data") + shiny::validate( need(try(nrow(download_data())>0), "No sample data available. Please inspect operations in Preset step."), diff --git a/inst/shinyapp/modules/08_other_page/home-pancan-search.R b/inst/shinyapp/modules/08_other_page/home-pancan-search.R index 39904fb6..71da54a8 100644 --- a/inst/shinyapp/modules/08_other_page/home-pancan-search.R +++ b/inst/shinyapp/modules/08_other_page/home-pancan-search.R @@ -134,7 +134,10 @@ server.home_search_box <- function(input, output, session) { Show.P.value = input$pdist_show_p_value, Show.P.label = input$pdist_show_p_label ) - + shiny::validate( + need(try(inherits(p,'gg')), + "Error: Please select a valid molecule.") + ) p + cowplot::theme_cowplot() + ggpubr::rotate_x_text(45) }) } @@ -233,23 +236,31 @@ server.home_search_box <- function(input, output, session) { observeEvent(input$report_1, { w$show() output$tip1 = renderText({ - paste0("Tip: You now can run step2 or step3. (", - format(Sys.time(), "%H:%M:%S"), ")") + if(report_1_OK()) { + paste0("Tip: You now can run step2 or step3. (", + format(Sys.time(), "%H:%M:%S"), ")") + } else { + "Error: Please exit and select a valid molecule." + } }) }) - + report_1_OK <- reactiveVal(TRUE) observeEvent(input$report_1, { time_stamp = format(Sys.time(), "%Y-%m-%d_%H-%M-%S") res_dat = mol_quick_analysis(molecule = input$Pancan_search, data_type = input$Pancan_search_type, out_dir = tempdir(), out_report = FALSE) + if(is.null(res_dat)) { + report_1_OK(FALSE) + } + shiny::validate( + need(try(!is.null(res_dat)), + "Error: Please exit and select a valid molecule.") + ) - - - output$report_2 = downloadHandler( - + output$report_2 = downloadHandler( filename = paste0(time_stamp,"_report.html"), content = function(file) { tempReport <- file.path(tempdir(), paste0(time_stamp,"_report.Rmd")) diff --git a/inst/shinyapp/server/modules.R b/inst/shinyapp/server/modules.R index b4893b90..a3330099 100644 --- a/inst/shinyapp/server/modules.R +++ b/inst/shinyapp/server/modules.R @@ -22,7 +22,7 @@ observeEvent(req(input$navbar=="TCGA: Survival analysis"),{ callModule(server.modules_1_tcga_10, "modules_1_tcga_10") }, once = TRUE) -observeEvent(req(input$navbar=="TCGA: Dimension reduction"),{ +observeEvent(req(input$navbar=="TCGA: Dimensionality reduction"),{ callModule(server.modules_1_tcga_11, "modules_1_tcga_11") }, once = TRUE) diff --git a/inst/shinyapp/shiny-doc/intro_personal_pips.md b/inst/shinyapp/shiny-doc/intro_personal_pips.md index 6e989fd0..bd230fdb 100644 --- a/inst/shinyapp/shiny-doc/intro_personal_pips.md +++ b/inst/shinyapp/shiny-doc/intro_personal_pips.md @@ -1,5 +1,5 @@
-

Personalized TPC pipelines

+

TPC pipelines

@@ -30,4 +30,4 @@ -> Tips: The menu of `Custom TPC modules` enable specific and quick  TPC molecular analysis, such as tumor and tomor comparison, molecule and molecule correlation. +> Tips: The menu of `TPC modules` enable specific and quick  TPC molecular analysis, such as tumor and tomor comparison, molecule and molecule correlation. diff --git a/inst/shinyapp/shiny-doc/intro_quick_mods.md b/inst/shinyapp/shiny-doc/intro_quick_mods.md index 907c4841..a4a9153e 100644 --- a/inst/shinyapp/shiny-doc/intro_quick_mods.md +++ b/inst/shinyapp/shiny-doc/intro_quick_mods.md @@ -1,5 +1,5 @@
-

Custom TPC modules

+

TPC modules

@@ -60,5 +60,5 @@ -> Tips: The menu of `Personalized TPC Pipelins` supports more general and personalized TPC molecular analysis, including alternative datasets, precise data preparation and versatile modes. +> Tips: The menu of `TPC Pipelins` supports more general and personalized TPC molecular analysis, including alternative datasets, precise data preparation and versatile modes. diff --git a/inst/shinyapp/ui/link2advanced.R b/inst/shinyapp/ui/link2advanced.R index ab28b452..b7390b1a 100644 --- a/inst/shinyapp/ui/link2advanced.R +++ b/inst/shinyapp/ui/link2advanced.R @@ -3,10 +3,10 @@ ui.link2advanced <- function() { title = "Advanced analysis", icon = icon("question-circle"), - tabPanel(a("Custom T·P·C Modules", + tabPanel(a("T·P·C Modules", href="http://localhost:1498/", target="_blank")), - # tabPanel(a("Personalized T·P·C Pipelines", + # tabPanel(a("T·P·C Pipelines", # href="https://lishensuo.github.io/UCSCXenaShiny_Book/", # target="_blank")), # tabPanel(a("PharmacoGenomics", diff --git a/inst/shinyapp/ui/pancan-analysis-quick.R b/inst/shinyapp/ui/pancan-analysis-quick.R index 64a0670e..785cbcb2 100644 --- a/inst/shinyapp/ui/pancan-analysis-quick.R +++ b/inst/shinyapp/ui/pancan-analysis-quick.R @@ -65,10 +65,10 @@ ui.page_pancan_quick <- function() { ) ), - tabPanel("TCGA: Dimension reduction", + tabPanel("TCGA: Dimensionality reduction", tabsetPanel( tabPanel( - "Dimension reduction", + "Dimensionality reduction", ui.modules_1_tcga_11("modules_1_tcga_11") ) ) diff --git a/man/vis_dim_dist.Rd b/man/vis_dim_dist.Rd index 1777ea10..80db44ca 100644 --- a/man/vis_dim_dist.Rd +++ b/man/vis_dim_dist.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/vis_dim_dist.R \name{vis_dim_dist} \alias{vis_dim_dist} -\title{Visualize the distribution difference of samples after dimension reduction analysis} +\title{Visualize the distribution difference of samples after dimensionality reduction analysis} \usage{ vis_dim_dist( ids = c("TP53", "KRAS", "PTEN", "MDM2", "CDKN1A"), @@ -21,7 +21,7 @@ vis_dim_dist( \item{group_info}{two-column grouping information with names 'Sample','Group'} -\item{DR_method}{the dimension reduction method} +\item{DR_method}{the dimensionality reduction method} \item{palette}{the color setting of RColorBrewer} @@ -33,7 +33,7 @@ vis_dim_dist( a ggplot object or rawdata list } \description{ -Visualize the distribution difference of samples after dimension reduction analysis +Visualize the distribution difference of samples after dimensionality reduction analysis } \examples{ \dontrun{ diff --git a/man/vis_identifier_dim_dist.Rd b/man/vis_identifier_dim_dist.Rd index 8f35f28b..bf9e4214 100644 --- a/man/vis_identifier_dim_dist.Rd +++ b/man/vis_identifier_dim_dist.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/vis_identifier_dim_dist.R \name{vis_identifier_dim_dist} \alias{vis_identifier_dim_dist} -\title{Visualize the distribution difference of samples after Molecule Identifier dimension reduction analysis} +\title{Visualize the distribution difference of samples after Molecule Identifier dimensionality reduction analysis} \usage{ vis_identifier_dim_dist( dataset = NULL, @@ -30,7 +30,7 @@ vis_identifier_dim_dist( \item{return.data}{whether to reture the raw meta/matrix data (list) instead of plot} -\item{DR_method}{the dimension reduction method} +\item{DR_method}{the dimensionality reduction method} \item{add_margin}{the marginal plot (NULL, "density", "boxplot")}