Question: Heatmap value gradient
0
gravatar for ngcatung0
3 months ago by
ngcatung020
ngcatung020 wrote:

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))
ADD COMMENTlink modified 3 months ago by ashish420 • written 3 months ago by ngcatung020
0
gravatar for ashish
3 months ago by
ashish420
ashish420 wrote:

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 COMMENTlink written 3 months ago by ashish420
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1419 users visited in the last hour