Mercurial > repos > davidvanzessen > mutation_analysis
comparison aa_histogram.r @ 105:e4957ad476a2 draft
Uploaded
author | davidvanzessen |
---|---|
date | Thu, 23 Jun 2016 03:58:03 -0400 |
parents | 603a10976e9c |
children | 01c9993865af |
comparison
equal
deleted
inserted
replaced
104:603a10976e9c | 105:e4957ad476a2 |
---|---|
18 print("---------------- freq data.frame ----------------") | 18 print("---------------- freq data.frame ----------------") |
19 | 19 |
20 dat_freq = mutations.at.position / aa.at.position | 20 dat_freq = mutations.at.position / aa.at.position |
21 dat_dt = data.frame(i=1:length(dat_freq), freq=dat_freq) | 21 dat_dt = data.frame(i=1:length(dat_freq), freq=dat_freq) |
22 | 22 |
23 print("---------------- weird stuff ----------------") | |
24 | |
25 options(width=220) | |
26 | |
27 print(dat[,20:40]) | |
28 | |
29 print(dat_dt) #need this or it will fail???? | |
30 | |
31 print("---------------- plot ----------------") | 23 print("---------------- plot ----------------") |
32 | |
33 #also need these two, I don't even know... | |
34 print(paste("dat_freq", length(dat_freq))) | |
35 print(paste("dat_dt", nrow(dat_dt))) | |
36 | 24 |
37 m = ggplot(dat_dt, aes(x=i, y=freq)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) | 25 m = ggplot(dat_dt, aes(x=i, y=freq)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) |
38 m = m + geom_bar(stat="identity", colour = "black", fill = "darkgrey", alpha=0.8) + scale_x_continuous(breaks=1:length(dat_freq), labels=1:length(dat_freq)) | 26 m = m + geom_bar(stat="identity", colour = "black", fill = "darkgrey", alpha=0.8) + scale_x_continuous(breaks=1:length(dat_freq), labels=1:length(dat_freq)) |
39 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") | 27 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") |
40 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") | 28 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") |
43 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") | 31 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") |
44 m = m + expand_limits(y=c(-0.1,1)) + xlab("AA position") + ylab("Frequency") + ggtitle(paste(gene, "AA mutation frequency")) | 32 m = m + expand_limits(y=c(-0.1,1)) + xlab("AA position") + ylab("Frequency") + ggtitle(paste(gene, "AA mutation frequency")) |
45 | 33 |
46 print("---------------- write/print ----------------") | 34 print("---------------- write/print ----------------") |
47 | 35 |
48 print("writing dat_dt") #need this | |
49 write.table(dat_dt, paste(dirname(outfile), "/aa_histogram_", gene, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T) | 36 write.table(dat_dt, paste(dirname(outfile), "/aa_histogram_", gene, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T) |
50 print("writing png") #also need this, file is haunted | |
51 png(filename=outfile, width=1280, height=720) | 37 png(filename=outfile, width=1280, height=720) |
52 print(m) | 38 print(m) |
53 dev.off() | 39 dev.off() |