Question: Customizing gplots heatmap.2 - color range for heatmap and legend for RowSideColors
gravatar for Kurinji Pandiyan
6.7 years ago by
Kurinji Pandiyan30 wrote:
Dear All, I am using package gplots - heatmap.2 - function to plot some data. I would really appreciate your help customizing my heatmap in terms of - 1. *adjusting color range on heatmap.2* - I am using color "greenred" and would like this to consistently range from 0-1. Because one of my datasets does not have values ranging all the way to one, the color scale has been adjusted from 0-0.5, with red being 0.5. This is confusing as it is not consistent with all the other heatmaps where red indicates a value of 1. I would like to change the range of the color scale to always be the same, regardless of dataset - always 0 being green and red being 1, with a gradation of black in between (which greenred does by default anyway) 2. *obtaining a legend for RowSideColors* - I am also trying to use a specific column of my dataframe, which has 6 different levels of annotation, to plot RowSideColors - I was able to do this: x <http:""/> <- y[,c(3,9:10)] # 3 is the column with the levels of interest - for coloring - and is labeled "USCS" z <http:""/>.ma <- as.matrix(y[,9:10]) mycol <- c("red", "green", "blue", "purple", "yellow", "black") <http:""/>, col=greenred, scale = "none", trace="none",keysize = 1.5, main = list("Accessibility Plot", cex = 1.5), margins = c(5,5), cexCol = 1, Rowv = "NULL", RowSideColors=mycol[as.integer( x <http:""/>$USCS)]) This worked well - only issue is, I am not sure how it picked which color to which value. I was eventually able to figure it out with a small sample set but it will be nice to not have to figure it out and to just use code to produce a legend with color and level name. Please let me know how to produce a legend with the colors used for RowSideColors. I would greatly appreciate someone's input. Thanks, Kurinji Graduate Student [[alternative HTML version deleted]]
ADD COMMENTlink written 6.7 years ago by Kurinji Pandiyan30
Please log in to add an answer.


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