Mercurial > repos > davidvanzessen > shm_csr
comparison shm_csr.r @ 39:a24f8c93583a draft
Uploaded
author | davidvanzessen |
---|---|
date | Thu, 22 Dec 2016 09:39:27 -0500 |
parents | 8d1c4c75f81b |
children | 1cf60ae234b4 |
comparison
equal
deleted
inserted
replaced
38:05c62efdc393 | 39:a24f8c93583a |
---|---|
300 | 300 |
301 if(any(transition2$value != 0)){ #having a transition table filled with 0 is bad | 301 if(any(transition2$value != 0)){ #having a transition table filled with 0 is bad |
302 print("Plotting heatmap and transition") | 302 print("Plotting heatmap and transition") |
303 png(filename=paste("transitions_stacked_", name, ".png", sep="")) | 303 png(filename=paste("transitions_stacked_", name, ".png", sep="")) |
304 p = ggplot(transition2, aes(factor(reorder(id, order.x)), y=value, fill=factor(reorder(variable, order.y)))) + geom_bar(position="fill", stat="identity", colour="black") #stacked bar | 304 p = ggplot(transition2, aes(factor(reorder(id, order.x)), y=value, fill=factor(reorder(variable, order.y)))) + geom_bar(position="fill", stat="identity", colour="black") #stacked bar |
305 p = p + xlab("From base") + ylab("") + ggtitle("Mutations frequency from base to base") + guides(fill=guide_legend(title=NULL)) | 305 p = p + xlab("From base") + ylab("") + ggtitle("Bargraph transition information") + guides(fill=guide_legend(title=NULL)) |
306 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) + scale_fill_manual(values=c("A" = "blue4", "G" = "lightblue1", "C" = "olivedrab3", "T" = "olivedrab4")) | 306 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) + scale_fill_manual(values=c("A" = "blue4", "G" = "lightblue1", "C" = "olivedrab3", "T" = "olivedrab4")) |
307 #p = p + scale_colour_manual(values=c("A" = "black", "G" = "black", "C" = "black", "T" = "black")) | 307 #p = p + scale_colour_manual(values=c("A" = "black", "G" = "black", "C" = "black", "T" = "black")) |
308 print(p) | 308 print(p) |
309 dev.off() | 309 dev.off() |
310 png(filename=paste("transitions_heatmap_", name, ".png", sep="")) | 310 png(filename=paste("transitions_heatmap_", name, ".png", sep="")) |
311 p = ggplot(transition2, aes(factor(reorder(variable, -order.y)), factor(reorder(id, -order.x)))) + geom_tile(aes(fill = value)) + scale_fill_gradient(low="white", high="steelblue") #heatmap | 311 p = ggplot(transition2, aes(factor(reorder(variable, -order.y)), factor(reorder(id, -order.x)))) + geom_tile(aes(fill = value)) + scale_fill_gradient(low="white", high="steelblue") #heatmap |
312 p = p + xlab("To base") + ylab("From Base") + ggtitle("Mutations frequency from base to base") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=13, colour="black")) | 312 p = p + xlab("To base") + ylab("From Base") + ggtitle("Heatmap transition information") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) |
313 print(p) | 313 print(p) |
314 dev.off() | 314 dev.off() |
315 } else { | 315 } else { |
316 #print("No data to plot") | 316 #print("No data to plot") |
317 } | 317 } |
386 | 386 |
387 pc = ggplot(genesForPlot, aes(x = factor(1), y=Freq, fill=Gene)) | 387 pc = ggplot(genesForPlot, aes(x = factor(1), y=Freq, fill=Gene)) |
388 pc = pc + geom_bar(width = 1, stat = "identity") + scale_fill_manual(labels=genesForPlot$label, values=c("IGA1" = "lightblue1", "IGA2" = "blue4")) | 388 pc = pc + geom_bar(width = 1, stat = "identity") + scale_fill_manual(labels=genesForPlot$label, values=c("IGA1" = "lightblue1", "IGA2" = "blue4")) |
389 pc = pc + coord_polar(theta="y") + scale_y_continuous(breaks=NULL) | 389 pc = pc + coord_polar(theta="y") + scale_y_continuous(breaks=NULL) |
390 pc = pc + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black"), axis.title=element_blank(), axis.text=element_blank(), axis.ticks=element_blank()) | 390 pc = pc + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black"), axis.title=element_blank(), axis.text=element_blank(), axis.ticks=element_blank()) |
391 pc = pc + xlab(" ") + ylab(" ") + ggtitle(paste("IGA subclasses", "( n =", sum(genesForPlot$Freq), ")")) | 391 pc = pc + xlab(" ") + ylab(" ") + ggtitle(paste("IGA subclass distribution", "( n =", sum(genesForPlot$Freq), ")")) |
392 write.table(genesForPlot, "IGA_pie.txt", sep="\t",quote=F,row.names=F,col.names=T) | 392 write.table(genesForPlot, "IGA_pie.txt", sep="\t",quote=F,row.names=F,col.names=T) |
393 | 393 |
394 png(filename="IGA.png") | 394 png(filename="IGA.png") |
395 print(pc) | 395 print(pc) |
396 dev.off() | 396 dev.off() |
407 | 407 |
408 pc = ggplot(genesForPlot, aes(x = factor(1), y=Freq, fill=Gene)) | 408 pc = ggplot(genesForPlot, aes(x = factor(1), y=Freq, fill=Gene)) |
409 pc = pc + geom_bar(width = 1, stat = "identity") + scale_fill_manual(labels=genesForPlot$label, values=c("IGG1" = "olivedrab3", "IGG2" = "red", "IGG3" = "gold", "IGG4" = "darkred")) | 409 pc = pc + geom_bar(width = 1, stat = "identity") + scale_fill_manual(labels=genesForPlot$label, values=c("IGG1" = "olivedrab3", "IGG2" = "red", "IGG3" = "gold", "IGG4" = "darkred")) |
410 pc = pc + coord_polar(theta="y") + scale_y_continuous(breaks=NULL) | 410 pc = pc + coord_polar(theta="y") + scale_y_continuous(breaks=NULL) |
411 pc = pc + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black"), axis.title=element_blank(), axis.text=element_blank(), axis.ticks=element_blank()) | 411 pc = pc + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black"), axis.title=element_blank(), axis.text=element_blank(), axis.ticks=element_blank()) |
412 pc = pc + xlab(" ") + ylab(" ") + ggtitle(paste("IGG subclasses", "( n =", sum(genesForPlot$Freq), ")")) | 412 pc = pc + xlab(" ") + ylab(" ") + ggtitle(paste("IGG subclass distribution", "( n =", sum(genesForPlot$Freq), ")")) |
413 write.table(genesForPlot, "IGG_pie.txt", sep="\t",quote=F,row.names=F,col.names=T) | 413 write.table(genesForPlot, "IGG_pie.txt", sep="\t",quote=F,row.names=F,col.names=T) |
414 | 414 |
415 png(filename="IGG.png") | 415 png(filename="IGG.png") |
416 print(pc) | 416 print(pc) |
417 dev.off() | 417 dev.off() |
428 | 428 |
429 p = ggplot(dat.clss, aes(best_match, percentage_mutations)) | 429 p = ggplot(dat.clss, aes(best_match, percentage_mutations)) |
430 p = p + geom_point(aes(colour=best_match), position="jitter") + geom_boxplot(aes(middle=mean(percentage_mutations)), alpha=0.1, outlier.shape = NA) | 430 p = p + geom_point(aes(colour=best_match), position="jitter") + geom_boxplot(aes(middle=mean(percentage_mutations)), alpha=0.1, outlier.shape = NA) |
431 p = p + xlab("Subclass") + ylab("Frequency") + ggtitle("Frequency scatter plot") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) | 431 p = p + xlab("Subclass") + ylab("Frequency") + ggtitle("Frequency scatter plot") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) |
432 p = p + scale_fill_manual(values=c("IGA" = "blue4", "IGA1" = "lightblue1", "IGA2" = "blue4", "IGG" = "olivedrab3", "IGG1" = "olivedrab3", "IGG2" = "red", "IGG3" = "gold", "IGG4" = "darkred", "IGM" = "darkviolet", "IGE" = "darkorange", "all" = "blue4")) | 432 p = p + scale_fill_manual(values=c("IGA" = "blue4", "IGA1" = "lightblue1", "IGA2" = "blue4", "IGG" = "olivedrab3", "IGG1" = "olivedrab3", "IGG2" = "red", "IGG3" = "gold", "IGG4" = "darkred", "IGM" = "darkviolet", "IGE" = "darkorange", "all" = "blue4")) |
433 p = p + scale_colour_manual(values=c("IGA" = "blue4", "IGA1" = "lightblue1", "IGA2" = "blue4", "IGG" = "olivedrab3", "IGG1" = "olivedrab3", "IGG2" = "red", "IGG3" = "gold", "IGG4" = "darkred", "IGM" = "darkviolet", "IGE" = "darkorange", "all" = "blue4")) | 433 p = p + scale_colour_manual(guide = guide_legend(title = "Subclass"), values=c("IGA" = "blue4", "IGA1" = "lightblue1", "IGA2" = "blue4", "IGG" = "olivedrab3", "IGG1" = "olivedrab3", "IGG2" = "red", "IGG3" = "gold", "IGG4" = "darkred", "IGM" = "darkviolet", "IGE" = "darkorange", "all" = "blue4")) |
434 | 434 |
435 png(filename="scatter.png") | 435 png(filename="scatter.png") |
436 print(p) | 436 print(p) |
437 dev.off() | 437 dev.off() |
438 | 438 |
452 | 452 |
453 frequency_bins_data$frequency = round(frequency_bins_data$frequency_count / frequency_bins_data$class_sum * 100, 2) | 453 frequency_bins_data$frequency = round(frequency_bins_data$frequency_count / frequency_bins_data$class_sum * 100, 2) |
454 | 454 |
455 p = ggplot(frequency_bins_data, aes(frequency_bins, frequency)) | 455 p = ggplot(frequency_bins_data, aes(frequency_bins, frequency)) |
456 p = p + geom_bar(aes(fill=best_match_class), stat="identity", position="dodge") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) | 456 p = p + geom_bar(aes(fill=best_match_class), stat="identity", position="dodge") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) |
457 p = p + xlab("Frequency ranges") + ylab("Frequency") + ggtitle("Mutation Frequencies by class") + scale_fill_manual(values=c("IGA" = "blue4", "IGG" = "olivedrab3", "IGM" = "darkviolet", "IGE" = "darkorange", "all" = "blue4")) | 457 p = p + xlab("Frequency ranges") + ylab("Frequency") + ggtitle("Mutation Frequencies by class") + scale_fill_manual(guide = guide_legend(title = "Class"), values=c("IGA" = "blue4", "IGG" = "olivedrab3", "IGM" = "darkviolet", "IGE" = "darkorange", "all" = "blue4")) |
458 | 458 |
459 png(filename="frequency_ranges.png") | 459 png(filename="frequency_ranges.png") |
460 print(p) | 460 print(p) |
461 dev.off() | 461 dev.off() |
462 | 462 |