26
|
1 library(ggplot2)
|
|
2
|
|
3 args <- commandArgs(trailingOnly = TRUE)
|
|
4
|
|
5 input = args[1]
|
|
6 outfile = args[2]
|
|
7
|
|
8 dat = read.table(input, header=F, sep=",")
|
|
9 dat=as.numeric(dat[1,])
|
|
10 dat_sum = sum(dat)
|
|
11
|
|
12 dat_freq = dat / dat_sum * 100
|
|
13 dat_dt = data.frame(i=1:length(dat_freq), freq=dat_freq)
|
|
14
|
|
15 m = ggplot(dat_dt, aes(x=i, y=freq)) + theme(axis.text.x = element_text(angle = 90, hjust = 1))
|
|
16 m = m + geom_histogram(stat="identity", colour = "black", fill = "darkgrey", alpha=0.8) + scale_x_continuous(breaks=1:length(dat_freq), labels=1:length(dat_freq))
|
|
17 write.table(dat_dt, paste(dirname(outfile), "/aa_histogram.txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)
|
|
18
|
|
19 png(filename=outfile, width=1280, height=720)
|
|
20 print(m)
|
|
21 dev.off()
|