Try to search your question here, if you can't find : Ask Any Question Now ?

Create a binary heatmap based on variables relationship

HomeCategory: stackoverflowCreate a binary heatmap based on variables relationship
Avatarbhawya asked 1 month ago

I have the dataframe below

DrugName <- c("as","df","fg","gh","jk")
value <- c("AD","AD","AD","AD","SEL")
MELT <- data.frame(DrugName, value)

and I want to create a heatmap that will have drug names as rows , and target symbols as columns (below the heatmap) and a grid square should be white if there is no association between a drug & a target
or black if there is an association between a drug & a target.
I use:

ggplot(MELT, aes(value, DrugName)) +
 geom_tile() +
 geom_tile(aes(fill = value), colour = "white") + 
 scale_fill_manual(values = c("white", "black"))

and I get:
enter image description here

I do not understand why the plot seems to have 3 column while the values are 2 and also why the coloring seems to be incorrect.

1 Answers
Best Answer
AvatarArben answered 1 month ago
Your Answer

5 + 7 =

Popular Tags

WP Facebook Auto Publish Powered By :