My data:
GFP_mywide<-bothdata[1:10,c(2,3,4)]
GFP_long<-melt(GFP_mywide, id =c('Entrez.Symbol'))
looks like this:
>GFP_long
Entrez.Symbol variable value
1 TRIP11 GFP_my 1.015
2 SIN3B GFP_my 0.336
3 SF3B1 GFP_my 0.315
4 PSMD14 GFP_my 0.254
5 RAD51 GFP_my 0.286
6 BARD1 GFP_my 0.157
7 BRCA1 GFP_my 0.275
8 BRCA1 GFP_my 0.230
9 U5200KD GFP_my 0.772
10 SETD5 GFP_my 0.364
11 TRIP11 GFP_wide 0.020
12 SIN3B GFP_wide 0.055
13 SF3B1 GFP_wide 0.071
14 PSMD14 GFP_wide 0.102
15 RAD51 GFP_wide 0.109
16 BARD1 GFP_wide 0.139
17 BRCA1 GFP_wide 0.146
18 BRCA1 GFP_wide 0.146
19 U5200KD GFP_wide 0.151
20 SETD5 GFP_wide 0.179
I want to create a heatmap when the values are sorted according to GFP_wide, so in the plot I will see the green becoming red for the GFP_wide, and GFP_my will be ordered by the same Entrez.Symbol. Until now I have a heatmap but can't find a way to sort the values based on GFP_wide. How do I do that?
This is my code and result:
ggplot(GFP_long, aes(x=Entrez.Symbol,y=variable,fill=value)) +
geom_tile(aes(fill = value))+
scale_fill_gradient(low="red", high="green")