I am new to R and have a question about heatmaps.
I have a list of proteins on the rows and in the columns their respective abundance in different conditions. This data are normalized, so in each row there is a 1 standing for the maximum and the rest of the values are between 1 and 0. I set 1 as red and 0 as white.
When I plot the heatmap with a scale though, I don't have a red square (=1) in each row, as it should be.
This is the code I have been using:
df <- read.table("my_data.txt", header = TRUE)
row.names(df) <- df$name
df <- df[, 2:21]
df_matrix <- data.matrix(df)
breaks = seq(0, max(df), length.out = 1000)
gradient1 = colorpanel( sum( breaks[-1]<=1 ), "white", "red" )
gradient2 = colorpanel( sum( breaks[-1]>1), "black", "red")
hm.colors = c(gradient1, gradient2)
df_heatmap <- heatmap(df_matrix,
Rowv=NA,
Colv=NA,
col=hm.colors,
scale = "column",
margins = c(5,10))
I also tried other options, like:
df_heatmap <- heatmap(df_matrix,
Rowv=NA,
Colv=NA,
col=heat.colors(256),
scale = "column",
margins = c(5,10))
If you have any suggestion on how to adjust it, it would be great. Thank you for the help!
dput(head(df))
to post a subset of your dataset and also the output image so that your problem is reproducible – Silence Dogoodggplot2
package – Mateusz1981