Mercurial > repos > davidvanzessen > argalaxy_tools
comparison aa_histogram.r @ 57:16c7fc1c4bf8 draft
Uploaded
author | davidvanzessen |
---|---|
date | Fri, 18 Mar 2016 07:50:34 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
56:2eb94c08e550 | 57:16c7fc1c4bf8 |
---|---|
1 library(ggplot2) | |
2 | |
3 args <- commandArgs(trailingOnly = TRUE) | |
4 | |
5 input = args[1] | |
6 outfile = args[2] | |
7 | |
8 print("---------------- read input ----------------") | |
9 | |
10 dat = read.table(input, sep="\t", fill=T, header=T, quote="") | |
11 | |
12 print("---------------- as numeric ----------------") | |
13 | |
14 mutations.at.position = as.numeric(dat[1,]) | |
15 aa.at.position = as.numeric(dat[2,]) | |
16 | |
17 print("---------------- freq data.frame ----------------") | |
18 | |
19 dat_freq = mutations.at.position / aa.at.position | |
20 dat_dt = data.frame(i=1:length(dat_freq), freq=dat_freq) | |
21 | |
22 print("---------------- weird stuff ----------------") | |
23 | |
24 options(width=220) | |
25 | |
26 print(dat[,20:40]) | |
27 | |
28 print(dat_dt) #need this or it will fail???? | |
29 | |
30 print("---------------- plot ----------------") | |
31 | |
32 m = ggplot(dat_dt, aes(x=i, y=freq)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) | |
33 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)) | |
34 m = m + annotate("segment", x = 0.5, y = -0.05, xend=26.5, yend=-0.05, colour="darkgreen", size=1) + annotate("text", x = 13, y = -0.1, label="FR1") | |
35 m = m + annotate("segment", x = 26.5, y = -0.07, xend=38.5, yend=-0.07, colour="darkblue", size=1) + annotate("text", x = 32.5, y = -0.15, label="CDR1") | |
36 m = m + annotate("segment", x = 38.5, y = -0.05, xend=55.5, yend=-0.05, colour="darkgreen", size=1) + annotate("text", x = 47, y = -0.1, label="FR2") | |
37 m = m + annotate("segment", x = 55.5, y = -0.07, xend=65.5, yend=-0.07, colour="darkblue", size=1) + annotate("text", x = 60.5, y = -0.15, label="CDR2") | |
38 m = m + annotate("segment", x = 65.5, y = -0.05, xend=104.5, yend=-0.05, colour="darkgreen", size=1) + annotate("text", x = 85, y = -0.1, label="FR3") | |
39 m = m + expand_limits(y=c(-0.1,1)) + xlab("AA position") + ylab("Frequency") + ggtitle("AA mutation frequency") | |
40 | |
41 print("---------------- write/print ----------------") | |
42 | |
43 write.table(dat_dt, paste(dirname(outfile), "/aa_histogram.txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T) | |
44 | |
45 png(filename=outfile, width=1280, height=720) | |
46 print(m) | |
47 dev.off() |