From a158f562278acecb5e1c1e1dc167468124e079a5 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Thu, 19 Dec 2024 22:24:41 +0100 Subject: [PATCH 1/7] version of roxygen up --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5024821..0680753 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -59,7 +59,7 @@ Imports: circlize, BioQC, shinyWidgets -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Encoding: UTF-8 Remotes: github::omnideconv/omnideconv From 17750fb9027e3213dc90cea03435732c27c57807 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Thu, 19 Dec 2024 22:31:32 +0100 Subject: [PATCH 2/7] ggplot --> ggplot2 --- R/BenchmarkingPlots.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/BenchmarkingPlots.R b/R/BenchmarkingPlots.R index 8feb0a9..da26422 100644 --- a/R/BenchmarkingPlots.R +++ b/R/BenchmarkingPlots.R @@ -60,7 +60,7 @@ plot_benchmark_scatter <- function(gtruth_df, theme(axis.text.x = element_text(angle = 60, hjust = 1), strip.background = ggplot2::element_rect(fill = "white")) + labs(x = "true cellular fractions", y = "cell type estimates", title = "") + theme(legend.position = "none", text = element_text(size = 15)) + - ggplot::geom_abline(linetype = "dashed") + ggplot2::geom_abline(linetype = "dashed") # get palette max_colors <- RColorBrewer::brewer.pal.info[color_palette, ]$maxcolors # for brewer.pal() From 4157cd480afba72ec6d6f8e8ac155171440a3742 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Thu, 19 Dec 2024 22:31:49 +0100 Subject: [PATCH 3/7] fixed imports --- NAMESPACE | 5 +---- R/DeconvExplorer-pkg.R | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 5cec841..561219d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,8 +18,7 @@ export(returnSelectedDeconvolutions) export(selectGenesByScore) import(omnideconv) import(shiny, except = c(renderDataTable, dataTableOutput)) -importFrom(BioQC,entropySpecificity) -importFrom(BioQC,gini) +import(shinyBS) importFrom(ComplexHeatmap,Heatmap) importFrom(ComplexHeatmap,UpSet) importFrom(ComplexHeatmap,comb_size) @@ -57,7 +56,6 @@ importFrom(ggplot2,geom_rect) importFrom(ggplot2,geom_text) importFrom(ggplot2,geom_tile) importFrom(ggplot2,ggplot) -importFrom(ggplot2,ggsave) importFrom(ggplot2,guide_colorbar) importFrom(ggplot2,guides) importFrom(ggplot2,labs) @@ -86,7 +84,6 @@ importFrom(rintrojs,readCallback) importFrom(rlang,.data) importFrom(shiny,addResourcePath) importFrom(shinyWidgets,actionBttn) -importFrom(shinyBS,bsPopover) importFrom(shinycssloaders,withSpinner) importFrom(shinydashboard,box) importFrom(shinydashboard,dashboardBody) diff --git a/R/DeconvExplorer-pkg.R b/R/DeconvExplorer-pkg.R index 2b3298d..119e758 100644 --- a/R/DeconvExplorer-pkg.R +++ b/R/DeconvExplorer-pkg.R @@ -6,10 +6,10 @@ #' @import omnideconv #' @importFrom shinydashboard box dashboardBody dashboardHeader dashboardPage #' dashboardSidebar dropdownMenu menuItem notificationItem sidebarMenu valueBox valueBoxOutput renderValueBox -#' tabItem tabItems +#' tabItem tabItems updateTabItems #' @importFrom plotly ggplotly plotlyOutput renderPlotly plot_ly layout config #' @importFrom ggplot2 aes aes_ aes_string coord_cartesian coord_flip element_text -#' facet_wrap geom_abline geom_boxplot geom_col geom_jitter geom_point +#' facet_wrap geom_abline geom_boxplot geom_col geom_jitter geom_point ggsave #' geom_tile ggplot guide_colorbar guides labs scale_fill_gradient theme geom_text element_blank #' geom_hline scale_colour_brewer scale_fill_brewer ylim theme_minimal geom_rect element_rect #' @importFrom shinycssloaders withSpinner From b5adb50a9f992111791c1c32d33364153d3aa8d2 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Thu, 19 Dec 2024 22:34:13 +0100 Subject: [PATCH 4/7] documenting also order_columns --- R/SignatureExplorationPlots.R | 1 + man/plot_signatureClustered.Rd | 2 ++ 2 files changed, 3 insertions(+) diff --git a/R/SignatureExplorationPlots.R b/R/SignatureExplorationPlots.R index e1fef8f..9df3b5f 100644 --- a/R/SignatureExplorationPlots.R +++ b/R/SignatureExplorationPlots.R @@ -163,6 +163,7 @@ plot_meanEntropyPerMethod <- function(signature_list, #' @param scoring_method The score used to annotate the genes (entropy, gini) #' @param annotation_type How the score is rendered (line, bar) #' @param order_rows Either 'cluster' to order cell types by similarity or 'no_cluster' to order alphabetically +#' @param order_columns Character, either 'z-score cutoff', 'hierarchical clustering' or 'alphabetical' #' @param threshold the threshold for the z-scored expression in the signature matrix to consider #' a gene as being differentially expressed. Default: 1.5 #' diff --git a/man/plot_signatureClustered.Rd b/man/plot_signatureClustered.Rd index 90d7aff..8cda985 100644 --- a/man/plot_signatureClustered.Rd +++ b/man/plot_signatureClustered.Rd @@ -27,6 +27,8 @@ plot_signatureClustered( \item{order_rows}{Either 'cluster' to order cell types by similarity or 'no_cluster' to order alphabetically} +\item{order_columns}{Character, either 'z-score cutoff', 'hierarchical clustering' or 'alphabetical'} + \item{threshold}{the threshold for the z-scored expression in the signature matrix to consider a gene as being differentially expressed. Default: 1.5} } From df65108766c409eb4eb1c426f79630bfe0edf4bc Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Thu, 19 Dec 2024 22:34:23 +0100 Subject: [PATCH 5/7] updating namespace --- NAMESPACE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 561219d..4c73691 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -56,6 +56,7 @@ importFrom(ggplot2,geom_rect) importFrom(ggplot2,geom_text) importFrom(ggplot2,geom_tile) importFrom(ggplot2,ggplot) +importFrom(ggplot2,ggsave) importFrom(ggplot2,guide_colorbar) importFrom(ggplot2,guides) importFrom(ggplot2,labs) @@ -97,6 +98,7 @@ importFrom(shinydashboard,renderValueBox) importFrom(shinydashboard,sidebarMenu) importFrom(shinydashboard,tabItem) importFrom(shinydashboard,tabItems) +importFrom(shinydashboard,updateTabItems) importFrom(shinydashboard,valueBox) importFrom(shinydashboard,valueBoxOutput) importFrom(shinyjs,hide) From 8e24e188311c948a786dcdb32bcca1f538670761 Mon Sep 17 00:00:00 2001 From: Federico Marini Date: Fri, 20 Dec 2024 11:49:35 +0100 Subject: [PATCH 6/7] enabling roxygen md tags if needed to have nicer links in a "native manner" --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 0680753..2a32a93 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,3 +76,4 @@ URL: https://github.com/omnideconv/DeconvExplorer/ BugReports: https://github.com/omnideconv/DeconvExplorer/issues VignetteBuilder: knitr Config/testthat/edition: 3 +Roxygen: list(markdown = TRUE) From 7562bb471434a8645a48fccc012917cb70fc7ed2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:58:30 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- R/DeconvExplorer.R | 39 +++++++++++++++++++---------------- R/SignatureExplorationPlots.R | 15 ++++++-------- R/SignatureRefinements.R | 14 ++++++------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/R/DeconvExplorer.R b/R/DeconvExplorer.R index 8f0e207..9ee0f91 100644 --- a/R/DeconvExplorer.R +++ b/R/DeconvExplorer.R @@ -127,7 +127,6 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, width = 12, fileInput("userSignatureUpload", "Upload Signature"), div(style = "margin-top: -25px"), - p("You can upload a previsouly generated signature matrix of a deconvolution method and analyse it with DeconvExplorer. Multiple uploads are possible."), fluidRow( column(4, shinyWidgets::actionBttn("selectSigExploration", "Explore the signature", icon = icon("arrow-right"), color = "success", style = "simple")), @@ -202,7 +201,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, column( width = 4, selectInput("deconvMethod", "Deconvolution Method", - choices = c('MuSiC'='music', omnideconv::deconvolution_methods[-10]) + choices = c("MuSiC" = "music", omnideconv::deconvolution_methods[-10]) ) ), column( @@ -221,8 +220,10 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, column( width = 3, div( - shinyBS::popify(shinyWidgets::actionBttn("deconvolute", "Deconvolute", style = 'simple', icon = icon('triangle-exclamation'), color = 'warning'), - "Attention", "Some methods are considerably slower than others; please keep this in mind when using DeconvExplorer for deconvolution."), + shinyBS::popify( + shinyWidgets::actionBttn("deconvolute", "Deconvolute", style = "simple", icon = icon("triangle-exclamation"), color = "warning"), + "Attention", "Some methods are considerably slower than others; please keep this in mind when using DeconvExplorer for deconvolution." + ), style = "margin-top:1.7em" ) ), @@ -235,7 +236,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, title = "", content = "Select a deconvolution method to run. If required and supported by the deconvolution method you can additionally select a custom signature to be used in computation. Please note this is an advanced feature and should be used with caution. " ) - + deconv_plot_box <- shinydashboard::box( id = "tour_deconvPlot", @@ -512,7 +513,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, title = span("Clustered Signature", icon("question-circle", id = "sigHeatmapQ")), status = "info", solidHeader = TRUE, width = 12, - fluidRow( + fluidRow( column( width = 4, selectInput("signatureToHeatmap", "Select a Signature", choices = NULL) @@ -520,27 +521,29 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, column( width = 2, selectInput("signatureAnnotationScore", "Select an annotation score", - choices = c("Entropy" = "entropy", "Gini Index" = "gini") + choices = c("Entropy" = "entropy", "Gini Index" = "gini") ) ), column( width = 2, selectInput("signatureAnnotationPlotType", "Annotation Type", - choices = c("Bars" = "bar", "Lines" = "line") + choices = c("Bars" = "bar", "Lines" = "line") ) ), column( width = 2, selectInput("clusterCelltypes", "Order rows (cell types)", - choices = c(".. by cell-type similarity" = "cluster", ".. alphabetically" = "no_cluster") + choices = c(".. by cell-type similarity" = "cluster", ".. alphabetically" = "no_cluster") ) ), column( width = 2, selectInput("clusterGenes", "Order columns (genes)", - choices = c(".. by maximal z-score per cell type" = "z-score cutoff", - ".. hierarchically based on euclidean distance" = "hierarchical clustering", - ".. alphabetically" = "alphabetical") + choices = c( + ".. by maximal z-score per cell type" = "z-score cutoff", + ".. hierarchically based on euclidean distance" = "hierarchical clustering", + ".. alphabetically" = "alphabetical" + ) ) ) ), @@ -548,7 +551,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, column( width = 12, InteractiveComplexHeatmap::originalHeatmapOutput("clusteredHeatmapOneSignature", - width = "1250px", height = "450px", containment = TRUE + width = "1250px", height = "450px", containment = TRUE ) ) ), @@ -726,7 +729,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, column( width = 7, sliderInput("refinePercentZero", "Maximum percentage of zeroes allowed for each gene", - min = 0, max = 100, value = 90, step = 1, post = "%" + min = 0, max = 100, value = 90, step = 1, post = "%" ) ), column( @@ -760,7 +763,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL, ) ) -refUnspecificPopover <- + refUnspecificPopover <- shinyBS::bsPopover( id = "refUnspecificQ", title = "", @@ -818,8 +821,8 @@ refUnspecificPopover <- shinyBS::bsPopover( id = "refManuallyQ", title = "", - content = - ) + content = + ) # Info Boxes -------------------------------------------------------------- info_overview <- shinydashboard::box( @@ -1662,7 +1665,7 @@ refUnspecificPopover <- scoring_method = input$signatureAnnotationScore, annotation_type = input$signatureAnnotationPlotType, color_palette = input$globalColor, - order_rows = input$clusterCelltypes, + order_rows = input$clusterCelltypes, order_columns = input$clusterGenes ), "clusteredHeatmapOneSignature", diff --git a/R/SignatureExplorationPlots.R b/R/SignatureExplorationPlots.R index 9df3b5f..cc4b060 100644 --- a/R/SignatureExplorationPlots.R +++ b/R/SignatureExplorationPlots.R @@ -163,7 +163,7 @@ plot_meanEntropyPerMethod <- function(signature_list, #' @param scoring_method The score used to annotate the genes (entropy, gini) #' @param annotation_type How the score is rendered (line, bar) #' @param order_rows Either 'cluster' to order cell types by similarity or 'no_cluster' to order alphabetically -#' @param order_columns Character, either 'z-score cutoff', 'hierarchical clustering' or 'alphabetical' +#' @param order_columns Character, either 'z-score cutoff', 'hierarchical clustering' or 'alphabetical' #' @param threshold the threshold for the z-scored expression in the signature matrix to consider #' a gene as being differentially expressed. Default: 1.5 #' @@ -254,22 +254,19 @@ plot_signatureClustered <- function(signature_mat, cell.types.ordered <- order(colnames(mat)) } - if(order_columns == 'z-score cutoff'){ + if (order_columns == "z-score cutoff") { genes <- c() for (c in cell.types.ordered) { highly.expr.genes <- names(which(mat[, c] > threshold)) genes <- union(genes, highly.expr.genes) } - + genes <- union(genes, rownames(mat)) - }else if(order_columns == 'hierarchical clustering'){ - + } else if (order_columns == "hierarchical clustering") { # use hierarchical ward D2 clustering based on euclidean distance - clustering <- hclust(dist(mat), method = 'ward.D2') + clustering <- hclust(dist(mat), method = "ward.D2") genes <- rownames(mat)[clustering$order] - - }else if(order_columns == 'alphabetical'){ - + } else if (order_columns == "alphabetical") { genes <- sort(rownames(mat)) } diff --git a/R/SignatureRefinements.R b/R/SignatureRefinements.R index f5a630b..ba61bc9 100644 --- a/R/SignatureRefinements.R +++ b/R/SignatureRefinements.R @@ -116,26 +116,26 @@ removeUnspecificGenes <- function(signature_mat, signature_mat <- as.matrix(signature_mat) - to_keep <- sapply(1:nrow(signature_mat), function(i){ + to_keep <- sapply(1:nrow(signature_mat), function(i) { row <- signature_mat[i, ] # has colnames! drop FALSE is mandatory !!!!! - + # calculate bins to prevent error breaks <- seq(floor(min(row)), ceiling(max(row)), length.out = number_of_bins + 1) - + # cut into bins, seperate for each gene bins <- cut(row, breaks = breaks, labels = labels, include.lowest = TRUE) - + nHighBins <- sum(bins == "high") # not working when labels is something else - + # this value needs to be greater than one, depending of the step in the pipeline there arent # any rows producing zeros left but that is not the case for all signatures if (nHighBins <= max_count & nHighBins > 0) { return(TRUE) - }else{ + } else { return(FALSE) } }) - + refinedSignature <- signature_mat[to_keep, ]