Heatmap value gradient
1
0
Entering edit mode
4.2 years ago
ngcatung0 ▴ 20

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))
Genomics R DNA-seq Heatmap • 1.1k views
ADD COMMENT
0
Entering edit mode
4.2 years ago
ashish ▴ 680

You need to change atleast two things here

  1. write qplot instead of ggplot.
  2. 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"))
ADD COMMENT

Login before adding your answer.

Traffic: 1424 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6