Heatmap value gradient
Hi,
I am trying to create a heatmap that doesn't use gradient for values. There are only 2 numbers: 3 and 1. I want 3 to be a specific color and 1 to be another color. And this would also be reflected in the heatmap too.
data.heatmap <- ggplot(data = Good1_Poor3, mapping = aes (x = sample_id, y = Gene)) + geom_tile(aes(fill = response..Good1_Int2_Poor3.)) + scale_fill_gradient2() +
theme(axis.text.y = element_text(size = 4))
• 1,511 views
•
link
1 answer
You need to change atleast two things here
- write
qplotinstead ofggplot. - add
scale_fill_manual(values=c("3"="green", "1"="red"))at the end of your command
It should look like this:
qplot(data=Good1_Poor3,
x=sample_id,
y=Gene,
fill=factor(response),
geom="tile")+scale_fill_manual(values=c("3"="green", "1"="red"))
• 0 views
•
link
Log in to answer this question.