diff --git a/build_R_figures.py b/build_R_figures.py index a14f93757f9b1d212dec99cb01ad74686e262033..95ce17c997a708ebdf2072393cf705aad9c13b33 100755 --- a/build_R_figures.py +++ b/build_R_figures.py @@ -38,6 +38,8 @@ with open(rscript_name, "w") as rscript: columns = [] columns_goods = [] columns_bads = [] + rscript.write("colors <- colorRampPalette(c(\"#ff0000\", \"#e6e600\", \"#00ff00\"));\n" + "colors <- colors(101);\n") for indiv in range(1, args.nb_inds+1): columns.append("gt_qual[,\"{0}__INDIV_{1}\"]".format(tool, indiv)) columns_goods.append("gt_qual_goods[,\"{0}__INDIV_{1}\"]".format(tool, indiv)) @@ -54,21 +56,28 @@ with open(rscript_name, "w") as rscript: "\t}}\n" + "}}\n").format(tool, indiv)) + colors = ["colors[round(mean(" + x + ", na.rm = T))+1]" for x in columns] + colors_goods = ["colors[round(mean(" + x + ", na.rm = T))+1]" for x in columns_goods] + colors_bads = ["colors[round(mean(" + x + ", na.rm = T))+1]" for x in columns_bads] + # All rscript.write("pdf(\"gt_quality_" + tool + ".pdf\", width=9, height=3);\n") rscript.write("par(mfrow=c(1,3));\n") - rscript.write("boxplot({0}, main=\"{1}\", xlab=\"individuals\", ylab=\"quality (%)\", ylim=c(0,100));\n". - format(", ".join(columns), tool.title() + " [ALL]")) + rscript.write( + "boxplot({0}, main=\"{1}\", xlab=\"individuals\", ylab=\"quality (%)\", ylim=c(0,100), border=c({2}));\n". + format(", ".join(columns), tool.title() + " [ALL]", ",".join(colors))) rscript.write("axis(side=1, seq(1,{0}));\n".format(args.nb_inds)) # Goods - rscript.write("boxplot({0}, main=\"{1}\", xlab=\"individuals\", ylab=\"quality (%)\", ylim=c(0,100));\n". - format(", ".join(columns_goods), tool.title() + " [GOODS]")) + rscript.write( + "boxplot({0}, main=\"{1}\", xlab=\"individuals\", ylab=\"quality (%)\", ylim=c(0,100), border=c({2}));\n". + format(", ".join(columns_goods), tool.title() + " [GOODS]", ",".join(colors_goods))) rscript.write("axis(side=1, seq(1,{0}));\n".format(args.nb_inds)) # Bads - rscript.write("boxplot({0}, main=\"{1}\", xlab=\"individuals\", ylab=\"quality (%)\", ylim=c(0,100));\n". - format(", ".join(columns_bads), tool.title() + " [BADS]")) + rscript.write( + "boxplot({0}, main=\"{1}\", xlab=\"individuals\", ylab=\"quality (%)\", ylim=c(0,100), border=c({2}));\n". + format(", ".join(columns_bads), tool.title() + " [BADS]", ",".join(colors_bads))) rscript.write("axis(side=1, seq(1,{0}));\n".format(args.nb_inds)) sv_file_io = open(svs_file, "r")