Skip to content

Commit cd074f3

Browse files
committed
QC JSI heatmap: Removed metadata columns that have only 1 or all unique values; Made colour vector wrap around if more than the total is needed
1 parent 32445e3 commit cd074f3

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

R/QCpanel.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ QCpanelUI <- function(id, metadata){
1515
'Quality checks',
1616
tags$h1("Jaccard Similarity Index Heatmap"),
1717
shinyWidgets::dropdownButton(
18-
shinyjqui::orderInput(ns('jaccard.annotations'), label = "Show annotations",
19-
items = colnames(metadata)[c(ncol(metadata), seq_len(ncol(metadata) - 1))][-2]),
18+
shinyjqui::orderInput(ns('jaccard.annotations'), label = "Show annotations", items = colnames(metadata)),
2019
sliderInput(ns('jaccard.n.abundant'), label = '# of (most abundant) genes',
2120
min = 50, value = 500, max = 5000, step = 50, ticks = FALSE),
2221
checkboxInput(ns("jaccard.show.values"), label = "Show JSI values", value = FALSE),
@@ -73,6 +72,16 @@ QCpanelServer <- function(id, expression.matrix, metadata, anno){
7372
})
7473

7574
moduleServer(id, function(input, output, session){
75+
observe({
76+
items <- colnames(metadata())
77+
include.exclude <- apply(metadata(), 2, function(x){
78+
l <- length(unique(x))
79+
(l > 1) & (l < length(x))
80+
})
81+
items <- colnames(metadata())[include.exclude]
82+
items <- items[c(length(items), seq_len(length(items) - 1))]
83+
shinyjqui::updateOrderInput(session, "jaccard.annotations", items = items)
84+
})
7685
jaccard.plot <- reactive({
7786
meta <- lapply(metadata(), function(x) factor(x, levels = unique(x))) %>%
7887
as.data.frame() %>%

R/QCplotFuns.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jaccard_heatmap <- function(
7171
vec <- c(vec, col.vector[colind])
7272
names(vec)[i] <- values[i]
7373
colind <- colind + 1
74+
if(colind > length(col.vector)){colind <- colind %% length(col.vector)}
7475
}
7576
top.annotation.colour.list[[colnames(metadata)[top.annotation.ids[annos]]]] <- vec
7677
}

0 commit comments

Comments
 (0)