diff --git a/DESCRIPTION b/DESCRIPTION index 5024821..2a32a93 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 @@ -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) diff --git a/NAMESPACE b/NAMESPACE index 5cec841..4c73691 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) @@ -86,7 +85,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) @@ -100,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) 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() 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 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 e1fef8f..cc4b060 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 #' @@ -253,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, ] 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} }