view aa_histogram.r @ 26:2433a1e110e1 draft

Uploaded
author davidvanzessen
date Wed, 08 Apr 2015 05:25:52 -0400
parents
children 57d197f149c3
line wrap: on
line source

library(ggplot2)

args <- commandArgs(trailingOnly = TRUE)

input = args[1]
outfile = args[2]

dat = read.table(input, header=F, sep=",")
dat=as.numeric(dat[1,])
dat_sum = sum(dat)

dat_freq = dat / dat_sum * 100
dat_dt = data.frame(i=1:length(dat_freq), freq=dat_freq)

m = ggplot(dat_dt, aes(x=i, y=freq)) + theme(axis.text.x = element_text(angle = 90, hjust = 1))
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))
write.table(dat_dt, paste(dirname(outfile), "/aa_histogram.txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)

png(filename=outfile, width=1280, height=720)
print(m)
dev.off()