Reputation: 123
Example dataset has been given below. First column denotes ID and other three columns represent feature 1, feature 2, feature 3 respectively. N.B. Features values will be discrete always.
Id,f1,f2,f3
abc,1,1,2
def,1,1,3
ghi,2,3,1
I want to create a heatmap with tree. And similar ones will group together.
Example figure:
Upvotes: 0
Views: 216
Reputation: 15123
You may try
library(tidyverse)
df <- read.table(text = "Id,f1,f2,f3
abc,1,1,2
def,1,1,3
ghi,2,3,1", header = T, sep =',')
df %>% column_to_rownames(var = "Id") %>% as.matrix() %>% heatmap
I'm not sure it will work with your data, but using mtcars
dataset,
data <- as.matrix(mtcars)
heatmap(data, col= colorRampPalette(RColorBrewer::brewer.pal(8, "Blues"))(3), Colv = NA)
(3) next at colorRampPalette(RColorBrewer::brewer.pal(8, "Blues"))(3)
part indicates how many colors you will use.
Colv = NA
options removes upper tree and Rowv
will control tree on the left.
Upvotes: 2