From f9f7593a005cfd339ebc112a865a1e3bda497773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Escrib=C3=A0=20Montagut?= Date: Tue, 25 Apr 2023 15:30:43 +0200 Subject: [PATCH] feat: from tipify to withToolTip --- components/board.clustering/R/clustering_ui.R | 15 ++++---- .../R/drugconnectivity_plot_cmap_dsea.R | 16 +++++---- components/board.featuremap/R/featuremap_ui.R | 28 ++++++++------- components/modules/BatchCorrectModule.R | 9 ++--- components/modules/MakeContrastModule.R | 10 +++--- components/modules/NormalizeCountsModule.R | 35 ++++++++++--------- 6 files changed, 64 insertions(+), 49 deletions(-) diff --git a/components/board.clustering/R/clustering_ui.R b/components/board.clustering/R/clustering_ui.R index 8ed6009c6..2d0e7c285 100644 --- a/components/board.clustering/R/clustering_ui.R +++ b/components/board.clustering/R/clustering_ui.R @@ -30,9 +30,10 @@ ClusteringInputs <- function(id) { shiny::conditionalPanel( "input.hm_features == ''", ns = ns, - tipifyR( + withTooltip( shiny::selectInput(ns("hm_contrast"), NULL, choices = NULL), - "Select contrast to be used as signature." + "Select contrast to be used as signature.", + placement = "right", options = list(container = "body") ) ), withTooltip(shiny::selectInput(ns("hm_group"), "Group by:", choices = NULL), @@ -58,7 +59,7 @@ ClusteringInputs <- function(id) { inline = TRUE ), "Choose the layout method for clustering plots.", - ), + ), shiny::conditionalPanel( "input.hm_options % 2 == 1", ns = ns, @@ -92,7 +93,7 @@ ClusteringUI <- function(id) { fullH <- "80vh" ## full height of full page rowH <- "40vh" - + div( class = "row", ## h4("Cluster Samples"), @@ -130,7 +131,7 @@ ClusteringUI <- function(id) { "Parallel", shinyjqui::jqui_sortable( bslib::layout_column_wrap( - width = 1, + width = 1, clustering_plot_parcoord_ui( id = ns("parcoord"), title = "Parallel coordinates", @@ -147,9 +148,9 @@ ClusteringUI <- function(id) { caption = "Table showing the expression in each sample of the genes displayed in the Parallel Coordinates.", label = "a", width = c("100%", "100%"), - height = c("calc(50vh - 100px)", TABLE_HEIGHT_MODAL) + height = c("calc(50vh - 100px)", TABLE_HEIGHT_MODAL) ) - ) ## layout + ) ## layout ) ## sortable ) )), diff --git a/components/board.drugconnectivity/R/drugconnectivity_plot_cmap_dsea.R b/components/board.drugconnectivity/R/drugconnectivity_plot_cmap_dsea.R index efb29b921..1e8f2fabd 100644 --- a/components/board.drugconnectivity/R/drugconnectivity_plot_cmap_dsea.R +++ b/components/board.drugconnectivity/R/drugconnectivity_plot_cmap_dsea.R @@ -23,25 +23,29 @@ drugconnectivity_plot_cmap_dsea_ui <- function( ns <- shiny::NS(id) plot_opts <- shiny::tagList( - tipifyL( + withTooltip( shiny::radioButtons( ns("cmap_labeltype"), "label type:", c("drugs", "MOA", "target"), inline = TRUE ), - "Label point with drugs, MOA terms or targets (if no drug selected)." + "Label point with drugs, MOA terms or targets (if no drug selected).", + placement = "left", options = list(container = "body") ), - tipifyL( + withTooltip( shiny::radioButtons(ns("cmap_nlabel"), "number of labels:", c(3, 10, 20, 100), selected = 10, inline = TRUE ), - "Number of labels to show." + "Number of labels to show.", + placement = "left", options = list(container = "body") ), - tipifyL(shiny::checkboxGroupInput( + withTooltip(shiny::checkboxGroupInput( ns("cmap_labeloptions"), "label options:", choices = c("show", "fixed"), selected = c("show"), inline = TRUE - ), "Other labels options.") + ), "Other labels options.", + placement = "left", options = list(container = "body") + ) ) PlotModuleUI(ns("plot"), diff --git a/components/board.featuremap/R/featuremap_ui.R b/components/board.featuremap/R/featuremap_ui.R index f47288cd8..732f25a2f 100644 --- a/components/board.featuremap/R/featuremap_ui.R +++ b/components/board.featuremap/R/featuremap_ui.R @@ -23,27 +23,31 @@ FeatureMapInputs <- function(id) { "input.options % 2 == 1", ns = ns, shiny::tagList( - tipifyR( + withTooltip( shiny::selectInput(ns("ref_group"), "Reference:", choices = NULL), - "Reference group. If no group is selected the average is used as reference." + "Reference group. If no group is selected the average is used as reference.", + placement = "right", options = list(container = "body") ), - tipifyR( + withTooltip( shiny::radioButtons(ns("umap_type"), "UMAP datatype:", choices = c("logCPM", "logFC"), inline = TRUE ), - "The UMAP can be computed from the normalized log-expression (logCPM), or from the log-foldchange matrix (logFC). Clustering based on logCPM is the default, but when batch/tissue effects are present the logFC might be better." + "The UMAP can be computed from the normalized log-expression (logCPM), or from the log-foldchange matrix (logFC). Clustering based on logCPM is the default, but when batch/tissue effects are present the logFC might be better.", + placement = "right", options = list(container = "body") ), - tipifyR( + withTooltip( shiny::selectInput(ns("filter_genes"), "Show genes:", choices = NULL, multiple = FALSE ), - "Filter the genes to highlight on the map." + "Filter the genes to highlight on the map.", + placement = "right", options = list(container = "body") ), - tipifyR( + withTooltip( shiny::selectInput(ns("filter_gsets"), "Show genesets:", choices = NULL, multiple = FALSE ), - "Filter the genesets to highlight on the map." + "Filter the genesets to highlight on the map.", + placement = "right", options = list(container = "body") ) ) ) @@ -54,8 +58,8 @@ FeatureMapUI <- function(id) { ns <- shiny::NS(id) ## namespace height1 <- c("calc(60vh - 100px)", "70vh") - height2 <- c("calc(40vh - 100px)", "70vh") - + height2 <- c("calc(40vh - 100px)", "70vh") + div( boardHeader(title = "Cluster features", info_link = ns("info")), shiny::tabsetPanel( @@ -81,7 +85,7 @@ FeatureMapUI <- function(id) { info.text = "UMAP clustering of genes colored by relative log-expression of the phenotype group. The distance metric is covariance. Genes that are clustered nearby have high covariance.", caption = "Gene signature maps coloured by differential expression.", height = height1, - width = c("auto", "100%") + width = c("auto", "100%") ) ), featuremap_table_gene_map_ui( @@ -108,7 +112,7 @@ FeatureMapUI <- function(id) { caption = "Geneset UMAP coloured by level of variance. Shades of red indicate high variance.", height = height1, width = c("auto", "100%") - ), + ), featuremap_plot_gset_sig_ui( ns("gsetSigPlots"), title = "Geneset signatures", diff --git a/components/modules/BatchCorrectModule.R b/components/modules/BatchCorrectModule.R index 7bcda27e8..b3f222b52 100644 --- a/components/modules/BatchCorrectModule.R +++ b/components/modules/BatchCorrectModule.R @@ -35,7 +35,7 @@ BatchCorrectUI <- function(id, height=720) { width = 2 ), shiny::mainPanel( - shiny::plotOutput(ns("canvas"), width="100%", height=height) %>% shinycssloaders::withSpinner(), + shiny::plotOutput(ns("canvas"), width="100%", height=height) %>% bigLoaders::useSpinner(), width = 10 ) ) @@ -48,7 +48,7 @@ BatchCorrectInputsUI <- function(id) { BatchCorrectCanvas <- function(id, height=720) { ns <- shiny::NS(id) - shiny::plotOutput(ns("canvas"), width="100%", height=height) %>% shinycssloaders::withSpinner() + shiny::plotOutput(ns("canvas"), width="100%", height=height) %>% bigLoaders::useSpinner() } BatchCorrectServer <- function(id, X, pheno, is.count=FALSE, height=720) { @@ -230,10 +230,11 @@ BatchCorrectServer <- function(id, X, pheno, is.count=FALSE, height=720) { shiny::br(), shiny::br(), - tipify2( + withTooltip( shiny::selectInput(ns("bc_modelpar"), "Model parameters:", pheno.par, selected=sel.par, multiple=TRUE), - "Please specify all your model parameters. These are the parameters of interest that will determine your groupings."), + "Please specify all your model parameters. These are the parameters of interest that will determine your groupings.", + placement = "top", options = list(container = "body")), ## withTooltip( ## shiny::radioButtons(ns("bc_strength"), NULL, diff --git a/components/modules/MakeContrastModule.R b/components/modules/MakeContrastModule.R index cdcca900e..4637d91cf 100644 --- a/components/modules/MakeContrastModule.R +++ b/components/modules/MakeContrastModule.R @@ -30,14 +30,15 @@ MakeContrastUI <- function(id) { flex = c(1, 4), shiny::fillCol( flex = c(NA, NA, NA, NA, 1), - tipifyL( + withTooltip( shiny::selectInput(ns("param"), "Phenotype:", choices = NULL, selected = NULL, multiple = TRUE ), - "Select phenotype(s) to create conditions for your groups. Select <gene> if you want to split by high/low expression of some gene. Select <samples> if you want to group manually on sample names. You can select multiple phenotypes to create combinations." + "Select phenotype(s) to create conditions for your groups. Select <gene> if you want to split by high/low expression of some gene. Select <samples> if you want to group manually on sample names. You can select multiple phenotypes to create combinations.", + placement = "left", options = list(container = "body") ), shiny::conditionalPanel( "input.param == ''", @@ -49,12 +50,13 @@ MakeContrastUI <- function(id) { ) ), shiny::br(), - tipifyL( + withTooltip( shiny::textInput(ns("newname"), "Comparison name:", placeholder = "e.g. MAIN_vs_CONTROL" ), - "Give a name for your contrast as MAIN_vs_CONTROL, with the name of the main group first. You must keep _vs_ in the name to separate the names of the two groups." + "Give a name for your contrast as MAIN_vs_CONTROL, with the name of the main group first. You must keep _vs_ in the name to separate the names of the two groups.", + placement = "left", options = list(container = "body") ), shiny::br(), shiny::actionButton(ns("addcontrast"), diff --git a/components/modules/NormalizeCountsModule.R b/components/modules/NormalizeCountsModule.R index 3a258e47b..71f812e89 100644 --- a/components/modules/NormalizeCountsModule.R +++ b/components/modules/NormalizeCountsModule.R @@ -9,11 +9,11 @@ ##===================================================================================== if(0) { - load("~/Playground/omicsplayground/data/GSE10846-dlbcl-nc.pgx") + load("~/Playground/omicsplayground/data/GSE10846-dlbcl-nc.pgx") NormalizeCountsGadget(X=ngs$X, pheno=ngs$samples) out <- gadgetize2( NormalizeCountsUI, NormalizeCountsServer, - title = "UploadGadget", height=640, size="l", + title = "UploadGadget", height=640, size="l", X = ngs$X, pheno=ngs$samples ) names(out) } @@ -36,8 +36,8 @@ NormalizeCountsServerRT <- function(id, counts, height=720) { shiny::moduleServer( id, function(input, output, session) { - - all.methods <- c("none","scale","quantile", "CPM","TMM","RLE") + + all.methods <- c("none","scale","quantile", "CPM","TMM","RLE") nc_info = "normalization module" nc_info = "" @@ -48,21 +48,24 @@ NormalizeCountsServerRT <- function(id, counts, height=720) { shiny::sidebarLayout( shiny::sidebarPanel( shiny::helpText(nc_info), - ##br(), + ##br(), ##radioButtons(ns("selectmethod"),"Select normalization:", ## choices=all.methods, selected="CPM"), - tipify2( + withTooltip( shiny::selectInput(ns("selectmethod"),"Select normalization:", choices=all.methods, selected="CPM"), - "Select initial normalization method." + "Select initial normalization method.", + placement = "top", options = list(container = "body") ), - tipify2( + withTooltip( shiny::checkboxInput(ns("postqn"),"Post quantile normalization"), - "Apply additional quantile normalization after scaling method." + "Apply additional quantile normalization after scaling method.", + placement = "top", options = list(container = "body") ), - tipify2( + withTooltip( shiny::checkboxInput(ns("addnoise"),"Simulate unnormalized"), - "Simulated unnormalized data by adding random scaling to raw data" + "Simulated unnormalized data by adding random scaling to raw data", + placement = "top", options = list(container = "body") ), width = 2 ), @@ -73,7 +76,7 @@ NormalizeCountsServerRT <- function(id, counts, height=720) { ) }) shiny::outputOptions(output, "UI", suspendWhenHidden=FALSE) ## important!!! - + pgx <- shiny::reactive({ if(is.null(input$addnoise)) return(NULL) pgx <- list(counts=counts()) @@ -89,11 +92,11 @@ NormalizeCountsServerRT <- function(id, counts, height=720) { } pgx }) - + output$canvas <- shiny::renderPlot({ shiny::req(counts()) ## Show all methods - postqn <- input$postqn + postqn <- input$postqn viz.NormalizeCounts( pgx(), methods = all.methods, @@ -108,10 +111,10 @@ NormalizeCountsServerRT <- function(id, counts, height=720) { methods = NULL, post.qn = FALSE, title=NULL, subtitle=NULL, caption=NULL) - + } - + normalized_counts <- shiny::reactive({ ##req(input$selectmethod) method <- input$selectmethod