R.ggplot2 - k821209/pipelines GitHub Wiki
์นผ๋ผ ํ ๋ง๋ค
http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
library(ggplot2)
data<-read.table('file.Rin',header=F,sep='\t')
Peak annotation
> head(data)
V1 V2
1 Aly 0.2766870
2 Aly 0.0920515
3 Aly 0.5407250
4 Aly 0.6232970
5 Aly 0.6338910
6 Aly 0.9712740
library(ggplot2)
library(grid)
library(plyr)
densMode <- function(x){
td <- density(x)
maxDens <- which.max(td$y)
list(x=td$x[maxDens], y=td$y[maxDens])
}
xdat <- ddply(data,"V1",transform,val_mean=signif(densMode(V2)$x,3), med.x = signif(densMode(V2)$x,3), med.y=signif(densMode(V2)$y,3))
hp <- ggplot(data=data, aes(x=V2)) + geom_density() + geom_vline(aes(xintercept=val_mean),xdat, color="red",linetype="dashed",size=1) + theme_bw()
hp<- hp +
facet_grid(V1 ~ .) +
geom_text(data = xdat, aes(x=med.x,y=med.y,label=val_mean,size=10)) + xlim(0,1)
hp
bar plot
#repeat_stat_ver2.Rin
Copia 31 556 1138 30932 Aly 1.51548848794 0.0322779523166
Solo-LTR 761 4556 408 26932 Aly 11.0257815593 2.86558074588e-322
Gypsy 21 376 1148 31112 Aly 1.51362221069 0.0753685608702
Other 39 768 1130 30720 Aly 1.38053097345 0.0550579190245
Solo-LTR 838 2692 281 23605 Ath 26.1496962134 0.0
Copia 13 129 1106 26168 Ath 2.38434472994 0.00815830574331
Other 10 157 1109 26140 Ath 1.5013238529 0.232988344777
Gypsy 3 33 1116 26264 Ath 2.1394591072 0.180586291765
> df <- read.table('repeat_stat_ver2.Rin',header = FALSE)
> ggplot(df,aes(x=V6,y=-log10(V8),fill=V1)) + geom_bar(stat="identity") + facet_grid(V1 ~ .)
scatter plot
#data
A. lyrata 32657.00 534.00 1169.00
A. thaliana 27416.00 499.00 1119.00
B. rapa 40905.00 637.00 1376.00
C. clementina 24533.00 808.00 2238.00
C. rubella 26521.00 449.00 1022.00
E. grandis 36376.00 2136.00 6509.00
F. vesca 32831.00 453.00 996.00
G. max 56044.00 1131.00 2862.00
> p <- ggplot(df_tandem,aes(x=V4,y=V3,fill=V1,color=V1)) + geom_point(size=4)
> p + geom_text(data= df_tandem, aes(x=V4+400,y=V3,label=V1,size=10))
+ theme(legend.text=element_text(size=15,face = "italic")) # SIZE, FONT
+ theme(axis.text.x = element_text(size = rel(2), angle = 00)) # x axis text