getwd()
setwd("../../rmap/Scripts-HTR/4.MotifComposition/")
filehtselex="motif_SL_length.table"
outprefix="SL-length_dist"
library(ggplot2)
library(extrafont)
outname=paste(outprefix,tstring,".pdf",sep="")
tstring=gsub(" .*$","",Sys.time(),perl=TRUE)
outname=paste(outprefix,tstring,".pdf",sep="")
rhtselex=read.table(filehtselex,sep="\t")
nrhtselex=data.frame(rhtselex,"RHT-SELEX")
colnames(nrhtselex)=c("motif","stem","loop","Experiment")
head(nrhtselex,5)
library(reshape2)
melt(nrhtselex)
colnames(rhtselex)=c("motif","stem","loop")
nrhtselex=melt(rhtselex)
head(nrhtselex,5)
colnames(nrhtselex)=c("motif","tag","length")
ggplot(combinedset,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Motif width")+
theme(legend.position=c(0.5,0.98),legend.direction = "horizontal",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Motif width")+
theme(legend.position=c(0.5,0.98),legend.direction = "horizontal",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
p=
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Motif width")+
theme(legend.position=c(0.8,0.98),legend.direction = "horizontal",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
p
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Motif width")+
theme(legend.position=c(0.8,0.98),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Length distribution of stem and loop")+
theme(legend.position=c(0.8,0.98),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Length distribution of stem and loop")+
theme(legend.position=c(0.8,0.9),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
colnames(rhtselex)=c("motif","Stem","Loop")
nrhtselex=melt(rhtselex)
colnames(nrhtselex)=c("motif","tag","Length")
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Length distribution of stem and loop")+
theme(legend.position=c(0.8,0.9),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
colnames(rhtselex)=c("motif","Stem","Loop")
colnames(rhtselex)=c("motif","Stem","Loop")
colnames(rhtselex)=c("motif","Stem","Loop")
nrhtselex=melt(rhtselex)
colnames(nrhtselex)=c("motif","tag","Length")
ggplot(nrhtselex,aes(length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Length distribution of stem and loop")+
theme(legend.position=c(0.8,0.9),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
ggplot(nrhtselex,aes(Length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1")+scale_y_continuous("Counts")+ggtitle("Length distribution of stem and loop")+
theme(legend.position=c(0.8,0.9),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
ggplot(nrhtselex,aes(Length,fill=tag))+geom_histogram(alpha=0.5,stat="bin",binwidth=1,position="identity",linetype=0)+scale_fill_brewer(palette="Pastel1",direction = -1)+scale_y_continuous("Counts")+ggtitle("Length distribution of stem and loop")+
theme(legend.position=c(0.8,0.9),legend.direction = "vertical",legend.title=element_blank(),panel.background=element_blank(),axis.line.y=element_line(size=1,colour="grey",linetype="solid"),axis.line.x=element_line(size=1,colour="grey",linetype="solid"),axis.text=element_text(size=12),axis.title=element_text(size=14),legend.text=element_text(size=12),legend.background=element_blank(),title=element_text(size=14),plot.title=element_text(hjust=0.5),text=element_text(family = "Arial Narrow"))
