Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importfix #71

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Imports:
circlize,
BioQC,
shinyWidgets
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Encoding: UTF-8
Remotes:
github::omnideconv/omnideconv
Expand All @@ -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)
5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/BenchmarkingPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions R/DeconvExplorer-pkg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 21 additions & 18 deletions R/DeconvExplorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
Expand Down Expand Up @@ -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(
Expand All @@ -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"
)
),
Expand All @@ -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",
Expand Down Expand Up @@ -512,43 +513,45 @@ 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)
),
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"
)
)
)
),
fluidRow(
column(
width = 12,
InteractiveComplexHeatmap::originalHeatmapOutput("clusteredHeatmapOneSignature",
width = "1250px", height = "450px", containment = TRUE
width = "1250px", height = "450px", containment = TRUE
)
)
),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -760,7 +763,7 @@ DeconvExplorer <- function(deconvexp_bulk = NULL,
)
)

refUnspecificPopover <-
refUnspecificPopover <-
shinyBS::bsPopover(
id = "refUnspecificQ",
title = "",
Expand Down Expand Up @@ -818,8 +821,8 @@ refUnspecificPopover <-
shinyBS::bsPopover(
id = "refManuallyQ",
title = "",
content =
)
content =
)

# Info Boxes --------------------------------------------------------------
info_overview <- shinydashboard::box(
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 6 additions & 8 deletions R/SignatureExplorationPlots.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down Expand Up @@ -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))
}

Expand Down
14 changes: 7 additions & 7 deletions R/SignatureRefinements.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ]

Expand Down
2 changes: 2 additions & 0 deletions man/plot_signatureClustered.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading