library(ggplot2) library(scales) library(gridExtra) library(grid) ################## ### BAR COLORS ### ################## gg_color_hue <- function(n) { hues = seq(15, 375, length = n + 1) hcl(h = hues, l = 65, c = 100)[1:n] } cols = gg_color_hue(8) uncorrected = cols[1] hapog = rep(cols[2], 6) hypo = rep(cols[3], 6) nextpolish = rep(cols[4], 6) ntedit = rep(cols[5], 6) pilon = rep(cols[6], 6) polca = rep(cols[7], 6) racon = rep(cols[8], 6) ####################### ### DATA FORMATTING ### ####################### dat = read.csv('metag.all.res') colnames(dat)[1] = "Tool" dat$Tool = factor(dat$Tool, levels=c("Uncorrected", "Hapo-G", "HyPo", "NextPolish", "ntEdit", "Pilon", "POLCA", "Racon")) dat$Round = factor(dat$Round, levels=as.character(unique(dat$Round))) ##################### ### MAPPED PAIRS ### ##################### ppairs_top = ggplot(data=dat, aes(x=Tool, y=perfectPairs, group=Round)) + geom_col(position=position_dodge2(width = 0.9, preserve = "single"), color="black", fill=c(uncorrected, hapog, hypo, nextpolish, ntedit, pilon, polca, racon)) + theme_bw() + theme(axis.text = element_text(size = 13), axis.title = element_text(size = 13),legend.text = element_text(size = 18),plot.title = element_text(size = 18)) + theme(legend.position = "none")+ xlab("") + ylab("") + scale_y_continuous(breaks=c(0, 140000000, 145000000, 150000000), labels=c("0", "140", "145", "150")) + coord_cartesian(ylim=c(140000000, 151000000)) ppairs_bottom = ggplot(data=dat, aes(x=Tool, y=perfectPairs, group=Round)) + geom_col(position=position_dodge2(width = 0.9, preserve = "single"), color="black", fill=c(uncorrected, hapog, hypo, nextpolish, ntedit, pilon, polca, racon)) + theme_bw() + theme(axis.text = element_text(size = 13), axis.title = element_text(size = 13),legend.text = element_text(size = 18),plot.title = element_text(size = 18)) + theme(legend.position = "none")+ xlab("") + ylab("") + scale_y_continuous(breaks=c(0, 25000000, 50000000, 75000000, 100000000, 125000000, 150000000, 175000000), labels=c("0", "25", "50", "75", "100", "125", "150", "175")) ppairs = grid.arrange(ppairs_top, ppairs_bottom, heights=c(2, 3), ncol=1, nrow=2, left=textGrob("Million of perfectly mapped pairs", rot=90, vjust=1, gp = gpar(fontsize = 18))) ##################### ### SPECIFIC KMERS### ##################### kmers_top = ggplot(data=dat, aes(x=Tool, y=specific, group=Round)) + geom_histogram(stat="identity", position=position_dodge2(width = 0.9, preserve = "single"), color="black", fill=c(uncorrected, hapog, hypo, nextpolish, ntedit, pilon, polca, racon)) + theme_bw() + theme(axis.text = element_text(size = 13), axis.title = element_text(size = 13),legend.text = element_text(size = 18),plot.title = element_text(size = 18)) + theme(legend.position = "none") + xlab("") + ylab("") + scale_y_continuous(breaks=c(0, 43500000, 43600000, 43700000, 43800000), labels=c("0", "43.5M", "43.6M", "43.7M", "43.8M")) + coord_cartesian(ylim=c(43500000, 43800000)) kmers_bottom = ggplot(data=dat, aes(x=Tool, y=specific, group=Round)) + geom_histogram(stat="identity", position=position_dodge2(width = 0.9, preserve = "single"), color="black", fill=c(uncorrected, hapog, hypo, nextpolish, ntedit, pilon, polca, racon)) + theme_bw() + theme(axis.text = element_text(size = 13), axis.title = element_text(size = 13),legend.text = element_text(size = 18),plot.title = element_text(size = 18)) + theme(legend.position = "none") + xlab("") + ylab("") + scale_y_continuous(breaks=c(0, 10000000, 20000000, 30000000, 40000000, 50000000), labels=c("0", "10M", "20M", "30M", "40M", "50M")) kmers = grid.arrange(kmers_top, kmers_bottom, heights=c(2, 3), ncol=1, nrow=2, left=textGrob("Number of specific 31-mers", rot=90, vjust=1, gp = gpar(fontsize = 18))) ################ ### RUN TIME ### ################ dat2 = subset(dat, dat$Tool != "Uncorrected") run_time = ggplot(data=dat2, aes(x=Tool, y=elapsed, fill=Tool, group=Round)) + geom_histogram(stat="identity", position=position_dodge(), color="black", fill=c(hapog, hypo, nextpolish, ntedit, pilon, polca, racon)) + theme_bw() + theme(axis.text = element_text(size = 16), axis.title = element_text(size = 16),legend.text = element_text(size = 18),plot.title = element_text(size = 18)) + theme(legend.position = "none") + xlab("") + ylab("Total running time (minutes)")+ scale_y_continuous(limits=c(0, 500)) ppairs <- arrangeGrob(ppairs, top = textGrob("A", x = unit(0, "npc"), y = unit(1, "npc"), just=c("left","top"), gp=gpar(col="black", fontsize=18, fontfamily="Times Roman"))) kmers <- arrangeGrob(kmers, top = textGrob("B", x = unit(0, "npc"), y = unit(1, "npc"), just=c("left","top"), gp=gpar(col="black", fontsize=18, fontfamily="Times Roman"))) run_time <- arrangeGrob(run_time, top = textGrob("C", x = unit(0, "npc"), y = unit(1, "npc"), just=c("left","top"), gp=gpar(col="black", fontsize=18, fontfamily="Times Roman"))) g <- grid.arrange(ppairs, kmers, run_time, ncol=2, nrow=2) ggsave(file="Figure_MetaG.png", plot=g, width=16, height=9)