From 8433e8ab8f46ac2f6b40e4893da4894f957bbdcf Mon Sep 17 00:00:00 2001 From: Schultheis Date: Tue, 17 Apr 2018 13:01:18 +0200 Subject: [PATCH] create_heatmap: always create a colorramp to prevent continuous color mapping error --- R/function.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/function.R b/R/function.R index f7d7ed4..778d523 100644 --- a/R/function.R +++ b/R/function.R @@ -563,8 +563,10 @@ create_heatmap <- function(data, unitlabel='auto', row.label=T, row.custom.label # if(!is.null(winsorize.colors)) { breaks <- seq(winsorize.colors[1], winsorize.colors[2], length = length(colors)) - colors <- circlize::colorRamp2(breaks, colors) + } else { + breaks <- seq(min(apply(data[, -1], 2, function(x) {min(x, na.rm = TRUE)})), max(apply(data[, -1], 2, function(x) {max(x, na.rm = TRUE)})), length = length(colors)) } + colors <- circlize::colorRamp2(breaks, colors) #convert data to data.frame so rownames can be used for annotation prep.data <- as.data.frame(data[, -1])