I am trying to create a plot like the following:
I have roughly got the left plot us
To get the side plot, you would probably need to transform the data. Here's a rough start (using the tt
data from above)
p1<-ggplot(tt, aes(x=Gene, y=tumour.sample)) +
geom_tile(aes(fill=Effect)) +
theme(axis.text.x = element_text(angle = -90, hjust = 0)) +
scale_fill_discrete(guide=F)
#transform and summarize
rs<-do.call(rbind, Map(function(a,b) {
data.frame(s=b, i=seq_along(a), eff=sort(a))},
lapply(split(tt, tt$tumour.sample), '[[', "Effect"),
levels(factor(tt$tumour.sample))))
#make side plot
p2<-ggplot(rs, aes(x=i, y=s)) +
geom_tile(aes(fill=eff)) +
theme(axis.text.y=element_blank(), axis.title.y=element_blank())
#print both plots
grid.arrange(p1, p2, ncol=2)