I am try to make geom_tile plot and having difficulty trying to preserve the order of the tiles. Here is an example dataset
head(data2.2)
wt_mt_up GO ont
1285 10.692307 proline transport BP
784 10.319457 salicylic acid biosynthetic process BP
743 9.550895 systemic acquired resistance BP
1729 8.563280 response to endoplasmic reticulum stress BP
841 7.910318 defense response, incompatible interaction BP
1823 7.765033 defense response to bacterium BP
p2 <- ggplot(data2.2, aes(x=ont, y=GO, fill = wt_mt_up)) +
geom_tile() +
scale_fill_gradient(legend_title, low="white", high="red") + theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 12)) + theme(axis.text.y = element_text(hjust = 1, size = 12))
p2
As you can see in the output plot, eventhough GO = "proline transport" has a max value of 10.692307, it is somewhere in the middle of the plot. Same for the others. I ideally want them to stack from high to low values.