comparison shm_csr.r @ 42:1cf60ae234b4 draft

Uploaded
author davidvanzessen
date Tue, 28 Mar 2017 08:25:36 -0400
parents a24f8c93583a
children 77a7ac76c7b9
comparison
equal deleted inserted replaced
41:b8ac74723ab0 42:1cf60ae234b4
305 p = p + xlab("From base") + ylab("") + ggtitle("Bargraph transition information") + 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
311 ggsave(paste("transitions_stacked_", name, ".pdf", sep=""))
312
310 png(filename=paste("transitions_heatmap_", name, ".png", sep="")) 313 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 314 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("Heatmap transition information") + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=16, colour="black")) 315 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) 316 print(p)
314 dev.off() 317 dev.off()
318
319 ggsave(paste("transitions_heatmap_", name, ".pdf", sep=""))
315 } else { 320 } else {
316 #print("No data to plot") 321 #print("No data to plot")
317 } 322 }
318 } 323 }
319 324
392 write.table(genesForPlot, "IGA_pie.txt", sep="\t",quote=F,row.names=F,col.names=T) 397 write.table(genesForPlot, "IGA_pie.txt", sep="\t",quote=F,row.names=F,col.names=T)
393 398
394 png(filename="IGA.png") 399 png(filename="IGA.png")
395 print(pc) 400 print(pc)
396 dev.off() 401 dev.off()
402
403 ggsave("IGA.pdf", pc)
397 } 404 }
398 405
399 print("Plotting IGG piechart") 406 print("Plotting IGG piechart")
400 407
401 genesForPlot = dat[grepl("IGG", dat$best_match),]$best_match 408 genesForPlot = dat[grepl("IGG", dat$best_match),]$best_match
413 write.table(genesForPlot, "IGG_pie.txt", sep="\t",quote=F,row.names=F,col.names=T) 420 write.table(genesForPlot, "IGG_pie.txt", sep="\t",quote=F,row.names=F,col.names=T)
414 421
415 png(filename="IGG.png") 422 png(filename="IGG.png")
416 print(pc) 423 print(pc)
417 dev.off() 424 dev.off()
425
426 ggsave("IGG.pdf", pc)
418 } 427 }
419 428
420 print("Plotting scatterplot") 429 print("Plotting scatterplot")
421 430
422 dat$percentage_mutations = round(dat$VRegionMutations / dat$VRegionNucleotides * 100, 2) 431 dat$percentage_mutations = round(dat$VRegionMutations / dat$VRegionNucleotides * 100, 2)
434 443
435 png(filename="scatter.png") 444 png(filename="scatter.png")
436 print(p) 445 print(p)
437 dev.off() 446 dev.off()
438 447
448 ggsave("scatter.pdf", p)
449
439 write.table(dat[,c("Sequence.ID", "best_match", "VRegionMutations", "VRegionNucleotides", "percentage_mutations")], "scatter.txt", sep="\t",quote=F,row.names=F,col.names=T) 450 write.table(dat[,c("Sequence.ID", "best_match", "VRegionMutations", "VRegionNucleotides", "percentage_mutations")], "scatter.txt", sep="\t",quote=F,row.names=F,col.names=T)
440 451
441 print("Plotting frequency ranges plot") 452 print("Plotting frequency ranges plot")
442 453
443 dat$best_match_class = substr(dat$best_match, 0, 3) 454 dat$best_match_class = substr(dat$best_match, 0, 3)
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")) 468 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 469
459 png(filename="frequency_ranges.png") 470 png(filename="frequency_ranges.png")
460 print(p) 471 print(p)
461 dev.off() 472 dev.off()
473
474 ggsave("frequency_ranges.pdf", p)
462 475
463 frequency_bins_data_by_class = frequency_bins_data 476 frequency_bins_data_by_class = frequency_bins_data
464 477
465 frequency_bins_data_by_class = frequency_bins_data_by_class[order(frequency_bins_data_by_class$best_match_class, frequency_bins_data_by_class$frequency_bins),] 478 frequency_bins_data_by_class = frequency_bins_data_by_class[order(frequency_bins_data_by_class$best_match_class, frequency_bins_data_by_class$frequency_bins),]
466 479