Mercurial > repos > davidvanzessen > shm_csr
comparison pattern_plots.r @ 5:012a738edf5a draft
Uploaded
| author | davidvanzessen | 
|---|---|
| date | Tue, 01 Nov 2016 10:15:37 -0400 | 
| parents | faae21ba5c63 | 
| children | 81453585dfc3 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 4:477e95b098fd | 5:012a738edf5a | 
|---|---|
| 20 | 20 | 
| 21 dat = read.table(input.file, header=F, sep=",", quote="", stringsAsFactors=F, fill=T, row.names=1) | 21 dat = read.table(input.file, header=F, sep=",", quote="", stringsAsFactors=F, fill=T, row.names=1) | 
| 22 | 22 | 
| 23 | 23 | 
| 24 | 24 | 
| 25 classes = c("IGA", "IGA1", "IGA2", "IGG", "IGG1", "IGG2", "IGG3", "IGG4", "IGM") | 25 classes = c("IGA", "IGA1", "IGA2", "IGG", "IGG1", "IGG2", "IGG3", "IGG4", "IGM", "IGE") | 
| 26 xyz = c("x", "y", "z") | 26 xyz = c("x", "y", "z") | 
| 27 new.names = c(paste(rep(classes, each=3), xyz, sep="."), paste("un", xyz, sep="."), paste("all", xyz, sep=".")) | 27 new.names = c(paste(rep(classes, each=3), xyz, sep="."), paste("un", xyz, sep="."), paste("all", xyz, sep=".")) | 
| 28 | 28 | 
| 29 names(dat) = new.names | 29 names(dat) = new.names | 
| 30 | 30 | 
| 43 data1 = data1[order(data1$Type),] | 43 data1 = data1[order(data1$Type),] | 
| 44 | 44 | 
| 45 write.table(data1, plot1.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 45 write.table(data1, plot1.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 
| 46 | 46 | 
| 47 p = ggplot(data1, aes(Class, value)) + geom_bar(aes(fill=Type), stat="identity", position="dodge", colour = "black") + ylab("% of mutations") + guides(fill=guide_legend(title=NULL)) | 47 p = ggplot(data1, aes(Class, value)) + geom_bar(aes(fill=Type), stat="identity", position="dodge", colour = "black") + ylab("% of mutations") + guides(fill=guide_legend(title=NULL)) | 
| 48 p = p + theme(panel.background = element_rect(fill = "white", colour="black"),text = element_text(size=13, colour="black")) + scale_fill_manual(values=c("RGYW.WRCY" = "white", "TW.WA" = "blue4")) | 48 p = p + theme(panel.background = element_rect(fill = "white", colour="black"),text = element_text(size=15, colour="black"), axis.text.x = element_text(angle = 45, hjust = 1)) + scale_fill_manual(values=c("RGYW.WRCY" = "white", "TW.WA" = "blue4")) | 
| 49 #p = p + scale_colour_manual(values=c("RGYW.WRCY" = "black", "TW.WA" = "blue4")) | 49 #p = p + scale_colour_manual(values=c("RGYW.WRCY" = "black", "TW.WA" = "blue4")) | 
| 50 png(filename=plot1.png, width=480, height=300) | 50 png(filename=plot1.png, width=480, height=300) | 
| 51 print(p) | 51 print(p) | 
| 52 dev.off() | 52 dev.off() | 
| 53 | 53 | 
| 77 data2 = data2[order(data2$Type),] | 77 data2 = data2[order(data2$Type),] | 
| 78 | 78 | 
| 79 write.table(data2, plot2.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 79 write.table(data2, plot2.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 
| 80 | 80 | 
| 81 p = ggplot(data2, aes(x=Class, y=value, fill=Type)) + geom_bar(position="fill", stat="identity", colour = "black") + scale_y_continuous(labels=percent_format()) + guides(fill=guide_legend(title=NULL)) + ylab("% of mutations") | 81 p = ggplot(data2, aes(x=Class, y=value, fill=Type)) + geom_bar(position="fill", stat="identity", colour = "black") + scale_y_continuous(labels=percent_format()) + guides(fill=guide_legend(title=NULL)) + ylab("% of mutations") | 
| 82 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=13, colour="black")) + scale_fill_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "white")) | 82 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=15, colour="black"), axis.text.x = element_text(angle = 45, hjust = 1)) + scale_fill_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "white")) | 
| 83 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) | 83 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) | 
| 84 png(filename=plot2.png, width=480, height=300) | 84 png(filename=plot2.png, width=480, height=300) | 
| 85 print(p) | 85 print(p) | 
| 86 dev.off() | 86 dev.off() | 
| 87 | 87 | 
| 113 data3 = data3[order(data3$Type),] | 113 data3 = data3[order(data3$Type),] | 
| 114 | 114 | 
| 115 write.table(data3, plot3.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 115 write.table(data3, plot3.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 
| 116 | 116 | 
| 117 p = ggplot(data3, aes(Class, value)) + geom_bar(aes(fill=Type), stat="identity", position="dodge", colour = "black") + ylab("% of nucleotides") + guides(fill=guide_legend(title=NULL)) | 117 p = ggplot(data3, aes(Class, value)) + geom_bar(aes(fill=Type), stat="identity", position="dodge", colour = "black") + ylab("% of nucleotides") + guides(fill=guide_legend(title=NULL)) | 
| 118 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=13, colour="black")) + scale_fill_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "white")) | 118 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=15, colour="black"), axis.text.x = element_text(angle = 45, hjust = 1)) + scale_fill_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "white")) | 
| 119 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) | 119 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) | 
| 120 png(filename=plot3.png, width=480, height=300) | 120 png(filename=plot3.png, width=480, height=300) | 
| 121 print(p) | 121 print(p) | 
| 122 dev.off() | 122 dev.off() | 
| 123 | 123 | 
