TF_Family.R 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/YZGROUP/personalbio/transcriptome/software/R-3.4.2-1/bin/Rscript
  2. argv=commandArgs(TRUE)
  3. #setwd("C:/Users/lenovo/Desktop")
  4. #argv=c("TF.out.count.txt","TF.out.count")
  5. if(length(argv)==0){
  6. cat("USAGE:\n")
  7. cat(" $0 <TF.count.txt> <TF.count_prefix>\n\n")
  8. q()
  9. n
  10. }
  11. library(ggplot2)
  12. file_in=argv[1]
  13. pdf=paste(argv[2],".pdf",sep="")
  14. png=paste(argv[2],".png",sep="")
  15. #file_in="InDels_length_stat.summary"
  16. dt=read.table(file_in,head=T,sep="\t")
  17. dt=dt[order(dt[,2],decreasing=TRUE),]
  18. dt[,1]=factor(as.character(dt[,1]),levels=as.character(dt[,1]))
  19. q=ggplot(dt, aes(x = Family, y = Count))+
  20. geom_bar(stat="identity",width=0.7,fill="blue")+
  21. ylab("Count")+xlab("TF Family")+
  22. scale_fill_brewer(palette = "Set2")+
  23. theme(axis.text.x = element_text(angle=0),
  24. legend.title = element_blank(),
  25. panel.border = element_blank(),
  26. panel.grid.major.x = element_blank()) +
  27. #再加上坐标轴(无刻度、无标签
  28. #theme(axis.line = element_line(size=1, colour = "black"))
  29. theme_bw()+
  30. theme(strip.text = element_text(size = 10, color = "black", face = "bold"))+
  31. #修改坐标轴刻度标签
  32. theme(axis.text = element_text(size = 10, color = "black", face = "bold"))+
  33. #修改坐标轴标签
  34. theme(axis.title = element_text(size = 10, color = "black", face = "bold"))+
  35. #修改坐标轴标签
  36. theme(axis.text.x = element_text(size = 7,angle=90, color = "black",vjust=0.4,hjust=1, face = "bold"))+
  37. #对legend的内容做修改
  38. theme(legend.text= element_text(size=10, color="black", face = "bold", vjust=0.5, hjust=0.5)) + scale_y_continuous(expand = c(0.02,0.02))
  39. #对legend的title做修改
  40. #theme(legend.title= element_text(size=15, color="black", face = "bold", vjust=0.5, hjust=0.5))
  41. q
  42. ggsave(pdf,width=8,height=5)
  43. ggsave(png,width=8,height=5)