Mercurial > repos > davidvanzessen > shm_csr
comparison pattern_plots.r @ 39:a24f8c93583a draft
Uploaded
author | davidvanzessen |
---|---|
date | Thu, 22 Dec 2016 09:39:27 -0500 |
parents | 05c62efdc393 |
children | 1cf60ae234b4 |
comparison
equal
deleted
inserted
replaced
38:05c62efdc393 | 39:a24f8c93583a |
---|---|
54 | 54 |
55 data1 = data1[order(data1$Type),] | 55 data1 = data1[order(data1$Type),] |
56 | 56 |
57 write.table(data1, plot1.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 57 write.table(data1, plot1.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) |
58 | 58 |
59 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)) | 59 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)) + ggtitle("Percentage of mutations in AID and pol eta motives") |
60 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")) | 60 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")) |
61 #p = p + scale_colour_manual(values=c("RGYW.WRCY" = "black", "TW.WA" = "blue4")) | 61 #p = p + scale_colour_manual(values=c("RGYW.WRCY" = "black", "TW.WA" = "blue4")) |
62 png(filename=plot1.png, width=480, height=300) | 62 png(filename=plot1.png, width=510, height=300) |
63 print(p) | 63 print(p) |
64 dev.off() | 64 dev.off() |
65 | 65 |
66 data2 = dat[c(1, 5:8),] | 66 data2 = dat[c(1, 5:8),] |
67 | 67 |
91 | 91 |
92 data2 = data2[order(data2$Type),] | 92 data2 = data2[order(data2$Type),] |
93 | 93 |
94 write.table(data2, plot2.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 94 write.table(data2, plot2.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) |
95 | 95 |
96 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") | 96 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") + ggtitle("Relative mutation patterns") |
97 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")) | 97 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")) |
98 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) | 98 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) |
99 png(filename=plot2.png, width=480, height=300) | 99 png(filename=plot2.png, width=480, height=300) |
100 print(p) | 100 print(p) |
101 dev.off() | 101 dev.off() |
120 data3["A/T",is.infinite(unlist(data3["A/T",]))] = 0 | 120 data3["A/T",is.infinite(unlist(data3["A/T",]))] = 0 |
121 | 121 |
122 data3 = melt(t(data3[8:10,])) | 122 data3 = melt(t(data3[8:10,])) |
123 names(data3) = c("Class", "Type", "value") | 123 names(data3) = c("Class", "Type", "value") |
124 | 124 |
125 chk = is.na(data1$data3) | 125 chk = is.na(data3$value) |
126 if(any(chk)){ | 126 if(any(chk)){ |
127 data3[chk, "value"] = 0 | 127 data3[chk, "value"] = 0 |
128 } | 128 } |
129 | 129 |
130 data3 = data3[order(data3$Type),] | 130 data3 = data3[order(data3$Type),] |
131 | 131 |
132 write.table(data3, plot3.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) | 132 write.table(data3, plot3.txt, quote=F, sep="\t", na="", row.names=F, col.names=T) |
133 | 133 |
134 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)) | 134 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)) + ggtitle("Absolute mutation patterns") |
135 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")) | 135 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")) |
136 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) | 136 #p = p + scale_colour_manual(values=c("A/T" = "blue4", "G/C transversions" = "gray74", "G/C transitions" = "black")) |
137 png(filename=plot3.png, width=480, height=300) | 137 png(filename=plot3.png, width=480, height=300) |
138 print(p) | 138 print(p) |
139 dev.off() | 139 dev.off() |