Skip to content

Commit f238145

Browse files
committed
Restored previous gene annotation heatmap commit
1 parent 61bd27e commit f238145

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

R/DEsummaryFuns.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' rows correspond to genes and columns correspond to samples
77
#' @param top.annotation.ids a vector of column indices denoting which columns
88
#' of the metadata should become heatmap annotations
9-
#' @param show.columns.names whether to show the column names below the heatmap;
9+
#' @param show.column.names whether to show the column names below the heatmap;
1010
#' default is TRUE
1111
#' @return The heatmap as detailed in the ComplexHeatmap package.
1212
#' @export
@@ -25,12 +25,14 @@ expression_heatmap <- function(
2525
expression.matrix.subset,
2626
top.annotation.ids = NULL,
2727
metadata,
28-
type = c('Z-score', 'Log2 Expression', 'Expression')
28+
type = c('Z-score', 'Log2 Expression', 'Expression'),
29+
show.column.names = TRUE
2930
){
3031
heatmat <- as.matrix(expression.matrix.subset)
3132

3233
type <- type[1]
3334
heatmat <- rescale_matrix(heatmat, type)
35+
if(!show.column.names){colnames(heatmat <- NULL)}
3436

3537
if(!is.null(top.annotation.ids)){
3638
qual.col.pals = dplyr::filter(RColorBrewer::brewer.pal.info, .data$category == 'qual')

R/DEsummaryPanel.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ DEsummaryPanelUI <- function(id, metadata){
2828
onStatus = FALSE
2929
),
3030
checkboxInput(ns("pca.show.labels"), label = "Show sample labels", value = FALSE),
31-
checkboxInput(ns('pca.show.ellipses'),label = "Show ellipses around groups",value=TRUE),
32-
textInput(ns('plotPCAFileName'), 'File name for PCA plot download', value ='PCAPlotDE.png'),
31+
checkboxInput(ns('pca.show.ellipses'), label = "Show ellipses around groups", value = TRUE),
32+
textInput(ns('plotPCAFileName'), 'File name for PCA plot download', value = 'PCAPlotDE.png'),
3333
downloadButton(ns('downloadPCAPlot'), 'Download PCA Plot'),
3434

3535
status = "info",
@@ -42,8 +42,7 @@ DEsummaryPanelUI <- function(id, metadata){
4242
radioButtons(ns('heatmap.processing'), label = "Heatmap values",
4343
choices = c('Expression','Log2 Expression','Z-score'),
4444
selected = 'Z-score'),
45-
shinyjqui::orderInput(ns('heatmap.annotations'), label = "Show annotations",
46-
items = colnames(metadata)[c(ncol(metadata), seq_len(ncol(metadata) - 1))][-2]),
45+
shinyjqui::orderInput(ns('heatmap.annotations'), label = "Show annotations", items = colnames(metadata)),
4746
selectInput(ns("geneName"), "Additional genes to include:", multiple = TRUE, choices = character(0)),
4847
div("\nIf no genes are selected in the DE panel or here then the top 50 DE genes are chosen.\n"),
4948
div(style="margin-bottom:10px"),
@@ -55,7 +54,7 @@ DEsummaryPanelUI <- function(id, metadata){
5554
icon = icon("gear", verify_fa = FALSE),
5655
tooltip = shinyWidgets::tooltipOptions(title = "Click to see inputs!")
5756
),
58-
plotOutput(ns('heatmap'),height=400),
57+
plotOutput(ns('heatmap'), height = 400),
5958
)
6059
}
6160

@@ -99,6 +98,16 @@ DEsummaryPanelServer <- function(id, expression.matrix, metadata, DEresults, ann
9998
})
10099
output[['pca']] <- renderPlot(pca.plot())
101100

101+
observe({
102+
items <- colnames(metadata())
103+
include.exclude <- apply(metadata(), 2, function(x){
104+
l <- length(unique(x))
105+
(l > 1) & (l < length(x))
106+
})
107+
items <- colnames(metadata())[include.exclude]
108+
items <- items[c(length(items), seq_len(length(items) - 1))]
109+
shinyjqui::updateOrderInput(session, "heatmap.annotations", items = items)
110+
})
102111
heatmap.plot <- reactive({
103112
selectedGenes = DEresults()$selectedGenes()
104113
if(length(selectedGenes)){
@@ -122,7 +131,8 @@ DEsummaryPanelServer <- function(id, expression.matrix, metadata, DEresults, ann
122131
expression.matrix.subset = subsetExpression[, meta[, 1]],
123132
top.annotation.ids = match(input[['heatmap.annotations']], colnames(meta)),
124133
metadata = meta,
125-
type = input[["heatmap.processing"]]
134+
type = input[["heatmap.processing"]],
135+
show.column.names = (nrow(meta) <= 20)
126136
)
127137
return(myplot)
128138
}) %>%

0 commit comments

Comments
 (0)