summaryrefslogtreecommitdiff
path: root/R/heatmap.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/heatmap.R')
-rw-r--r--R/heatmap.R8
1 files changed, 5 insertions, 3 deletions
diff --git a/R/heatmap.R b/R/heatmap.R
index 77721ce..c40946f 100644
--- a/R/heatmap.R
+++ b/R/heatmap.R
@@ -75,6 +75,8 @@ heatmap <- function(R, title = NULL, labels = FALSE){
rownames(M) <- R_list$rnames
df <- reshape2::melt(M, na.rm = TRUE)
colnames(df) <- c('i', 'j', 'value')
+ df$i <- as.numeric(df$i)
+ df$j <- as.numeric(df$j)
# And plot it
p <- ggplot2::ggplot(
@@ -82,6 +84,8 @@ heatmap <- function(R, title = NULL, labels = FALSE){
ggplot2::aes(x = .data$j, y = .data$i, fill = .data$value)
) +
ggplot2::geom_tile() +
+ ggplot2::scale_y_reverse() +
+ ggplot2::coord_fixed(clip = 'off') +
ggplot2::scale_fill_gradient2(
low = 'red',
mid = 'white',
@@ -91,8 +95,6 @@ heatmap <- function(R, title = NULL, labels = FALSE){
name = NULL,
guide = 'none'
) +
- ggplot2::scale_y_reverse() +
- ggplot2::coord_fixed(clip = 'off') +
ggplot2::theme_void()
if(!is.null(title)){
@@ -112,7 +114,7 @@ heatmap <- function(R, title = NULL, labels = FALSE){
row_label_df <- data.frame(
j = seq_len(n)[-n],
i = seq_len(n)[-n],
- label = R_list$cnames[-n]
+ label = R_list$rnames[-n]
)
max_nchar <- max(nchar(R_list$cnames))