Skip to content

Commit 796f543

Browse files
committed
Gene expression heatmap: Removed annotation for metadata columns with only 1 or all unique values; removed sample names if there are more than 20 samples
1 parent 57bf448 commit 796f543

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

R/DEsummaryFuns.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ expression_heatmap <- function(
2020
expression.matrix.subset,
2121
top.annotation.ids = NULL,
2222
metadata,
23-
type = c('Z-score', 'Log2 Expression', 'Expression')
23+
type = c('Z-score', 'Log2 Expression', 'Expression'),
24+
show.columns.names = TRUE
2425
){
2526
heatmat <- as.matrix(expression.matrix.subset)
2627

2728
type <- type[1]
2829
heatmat <- rescale_matrix(heatmat, type)
30+
if(!show.columns.names){colnames(heatmat <- NULL)}
2931

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

R/DEsummaryPanel.R

Lines changed: 15 additions & 5 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"),
@@ -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 = 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)