library(ggplot2)
 
library(gridExtra)
#cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
 
oricbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
#
 
#, "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
 
# To use for fills, add
 
ls=0.8
 
pastelle <-c("#CC6666", "#9999CC", "#66CC99")
 
blackyellowgreen <- c("#000000", "#E69F00", "#009E73")
 
grayyellowgreen <- c("#999999", "#E69F00", "#009E73")
brewer1 <-c("#7fc97f","#beaed4","#fdc086")
 
brewer2 <-c("#666666","#a6761d","#66a61e")
 
final2 <- c("green", "yellow", "grey")
final <- c("grey40", "#E69F00","limegreen") #009E73
 
cbbPalette <- final
hr<-read.table("/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/hot-rpm.txt",header=T)
 
cr<-read.table("/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/cold-rpm.txt",header=T)
 
tr<-read.table("/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/ts-rpm.txt",header=T)
 
hr$replicate<-as.factor(hr$replicate)
 
cr$replicate<-as.factor(cr$replicate)
 
tr$replicate<-as.factor(tr$replicate)
hs<-read.table("/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/hot-speed.txt",header=T)
 
cs<-read.table("/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/cold-speed.txt",header=T)
 
ts<-read.table("/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/ts-speed.txt",header=T)
 
hs$replicate<-as.factor(hs$replicate)
 
cs$replicate<-as.factor(cs$replicate)
 
ts$replicate<-as.factor(ts$replicate)
theme_set(theme_bw())
 
 
maxrpm=max(tr$rpm)
 
minspeed=min(c(min(hs$u),min(ts$u)))
 
maxspeed=max(c(max(hs$u),max(ts$u)))
 
 
ghr<-ggplot(hr,aes(x=generations,y=rpm,color=replicate))+geom_line(size=ls)+geom_point()+ylim(0,maxrpm) +
 
theme(legend.position=c(0.85,0.2),axis.title.x=element_blank(),axis.text.x=element_blank()) + annotate("text", x = 2, y = 3800, label = "hot",size=8,color="red")+
 
scale_colour_manual(values=cbbPalette)
 
gtr<-ggplot(tr,aes(x=generations,y=rpm,color=replicate))+geom_line(size=ls)+geom_point()+ylim(0,maxrpm) +
 
theme(legend.position="none",axis.title.y=element_blank(),axis.text.y=element_blank(),axis.title.x=element_blank(),axis.text.x=element_blank())+
 
scale_x_continuous(breaks=c(0,10,20)) + annotate("text", x = 4, y = 3800, label = "hot",size=8,color="red")+ scale_colour_manual(values=cbbPalette)
gcr<-ggplot(cr,aes(x=generations,y=rpm,color=replicate))+geom_line(size=ls)+geom_point()+ylim(0,maxrpm) +
 
theme(legend.position="none",axis.title.y=element_blank(),axis.text.y=element_blank(),axis.title.x=element_blank(),axis.text.x=element_blank())+ annotate("text", x = 4, y = 3800, label = "cold",color="blue",size=8)+
 
scale_colour_manual(values=cbbPalette)
 
 
ghs<-ggplot(hs,aes(x=generations,y=u,color=replicate))+geom_line(size=ls)+geom_point()+ylim(minspeed,maxspeed) +
 
theme(legend.position="none")+ scale_colour_manual(values=cbbPalette)
gts<-ggplot(ts,aes(x=generations,y=u,color=replicate))+geom_line(size=ls)+geom_point()+ylim(minspeed,maxspeed) +
 
theme(legend.position="none",axis.title.y=element_blank(),axis.text.y=element_blank())+
 
scale_x_continuous(breaks=c(0,10,20))+scale_colour_manual(values=cbbPalette)
gcs<-ggplot(cs,aes(x=generations,y=u,color=replicate))+geom_line(size=ls)+geom_point()+ylim(minspeed,maxspeed) +
 
theme(legend.position="none",axis.title.y=element_blank(),axis.text.y=element_blank())+scale_colour_manual(values=cbbPalette)
 
 
 
grid.arrange(ghr,gtr,gcr,ghs,gts,gcs,ncol=3,nrow=2,widths=c(3,1,2),heights=c(1,1))
dev.copy2eps(file="/Volumes/Volume_4/analysis/ee-dsim-pele/analysis/2016-05-pabundance-fractionreads/graph-dat/invasionspeed/main-graph.eps")
 
dev.copy2eps(file="/Users/robertkofler/Desktop/main1-graph.eps")