Commit 4a30f0cc authored by Carine Rey's avatar Carine Rey
Browse files

improve plot

parent d10933f3
......@@ -8,6 +8,7 @@ library("reshape2")
library("ggplot2")
library("cowplot")
library("flux")
library("plyr")
date = format(Sys.time(), format="%Y-%m-%d %X")
......@@ -490,8 +491,8 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
)
print("plot recall_precision")
if (length(meths) <= 9 & all(c("H0 NeG1/HaPC NeG1_NeC_4", "H0/HaPC NeG1","H0/HaPC NeG2","H0/HaPC NeG4","H0/H0 NeG4/NeG4_NeC_1","H0/H0 NeG1/NeG1_NeC_4", "H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4") %in% df_out$couple)) {
couple_i = c("H0 NeG1/HaPC NeG1_NeC_4", "H0/HaPC NeG1","H0/HaPC NeG2","H0/HaPC NeG3","H0/HaPC NeG4","H0/HaPC NeG5","H0/H0 NeG5/NeG5_NeC_1","H0/H0 NeG1/NeG1_NeC_5", "H0/HaPC NeG5_NeC_1","H0/HaPC NeG1_NeC_5","H0/H0 NeG5/NeG4_NeC_1","H0/H0 NeG3/NeG1_NeC_4", "H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4")
if (length(meths) <= 9 & all(c("H0 NeG1/HaPC NeG1_NeC_4","H0 NeG1/HaPC NeG1_NeC_4", "H0/HaPC NeG1","H0/HaPC NeG2","H0/HaPC NeG4","H0/H0 NeG4/NeG4_NeC_1","H0/H0 NeG1/NeG1_NeC_4", "H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4") %in% df_out$couple)) {
couple_i = c("H0 NeG1/HaPC NeG1_NeC_4", "H0 NeG1/HaPC NeG1_NeC_4", "H0/HaPC NeG1","H0/HaPC NeG2","H0/HaPC NeG3","H0/HaPC NeG4","H0/HaPC NeG5","H0/H0 NeG5/NeG5_NeC_1","H0/H0 NeG1/NeG1_NeC_5", "H0/HaPC NeG5_NeC_1","H0/HaPC NeG1_NeC_5","H0/H0 NeG5/NeG4_NeC_1","H0/H0 NeG3/NeG1_NeC_4", "H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4")
plot = ggplot(subset(df_out, couple %in% couple_i), aes(x=sensitivity, y=precision98_02, col = methode))
plot = plot + theme_bw()
plot = plot + labs(x="Sensitivity (= Recall)", y="Precision (98/2)")
......@@ -530,12 +531,14 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
)
plot_PR_c = function(couple_l) {
tmp_df = subset(df_out,couple%in%couple_l)
tmp_df$couple = factor( tmp_df$couple, levels=c(levels( tmp_df$couple),"to_be_rm","to_be_rm2"))
if ("NULL" %in% couple_l) {
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm"
}
if ("NUL2L" %in% couple_l) {
if ("NULL2" %in% couple_l) {
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm2"
}
......@@ -548,16 +551,29 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
plot = plot + scale_color_manual(values=colors2)
#plot = plot + geom_point(size=1, alpha=alpha)
plot = plot + geom_step(direction="vh", size=1, alpha=alpha)
if (length(couple_l) < 5) {
#add AUC values
df_auc_label = subset(df_auc, couple %in% tmp_df$couple)
df_auc_label = df_auc_label[df_auc_label$auc2 >= 0.001,]
from_r=c(1,2,3,4,5,6,7,8,9)
to_y = 0.8 - 0.1 * from_r
df_auc_label$y = mapvalues(df_auc_label$auc2_rank, from=from_r, to=to_y)
df_auc_label$label = substr(as.character(df_auc_label$auc2), 1,5)
df_auc_leg = data.frame(couple = unique(tmp_df$couple), x = 0.9, y = 0.8, label = "AUC ")
plot = plot + geom_label(data=df_auc_label, aes(x=0.9, y=y, label=label, col=methode))
plot = plot + geom_label(data=df_auc_leg, aes(x=x, y=y, label=label), col="black")
}
plot = plot + geom_hline( aes(yintercept = 0.9), col="black" , size = 0.5, show.legend = NA,linetype="dashed")
plot = plot + facet_grid(. ~ couple )
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot}
plot = plot_PR_c(c("H0/HaPC NeG","H0 NeG1/HaPC NeG1_NeC_4","H0/HaPC NeG2","H0/HaPC NeG4","H0/H0 NeG4/NeG4_NeC_1","H0/H0 NeG1/NeG1_NeC_4", "H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4"))
plot1 = plot_PR_c(c("H0 NeG1/HaPC NeG1_NeC_4","NULL","NULL2"))
plot2 = plot_PR_c(c("H0/HaPC NeG1","H0/HaPC NeG2","H0/HaPC NeG4"))
plot3 = plot_PR_c(c("H0/H0 NeG4/NeG4_NeC_1","H0/H0 NeG1/NeG1_NeC_4","NULL"))
plot4 = plot_PR_c(c("H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4","NULL"))
plot1 = plot_PR_c(c("H0/HaPC NeG1","H0/HaPC NeG2","H0/HaPC NeG4"))
plot2 = plot_PR_c(c("H0/H0 NeG4/NeG4_NeC_1","H0/H0 NeG1/NeG1_NeC_4","NULL"))
plot3 = plot_PR_c(c("H0/HaPC NeG4_NeC_1","H0/HaPC NeG1_NeC_4","NULL"))
plot4 = plot_PR_c(c("H0 NeG1/HaPC NeG1_NeC_4","NULL","NULL2"))
legend_PR = get_legend(plot + theme(legend.position="top",
legend.text = element_text(size=10),
......@@ -573,10 +589,10 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
plot3 + theme(legend.position="none"),
plot4 + theme(legend.position="none"),
ncol = 1, scale = 1,
labels = c("","Pressure Shift+CSE", "Only Pressure Shift","Only Change in Selection Efficacy","Pressure Shift in a context of global change of Selection Efficacy"),
labels = c("","Only Pressure Shift","Only Change in Selection Efficacy","Pressure Shift in a context of global change of Selection Efficacy","Pressure Shift+CSE"),
align = "h",
rel_heights = c( 0.3, 0.7,0.7,0.7,0.7),
rel_heights = c( 0.1, 0.7,0.7,0.7,0.7),
hjust = 0, vjust = 0)
......@@ -584,7 +600,7 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
save_plot(paste0(opt$out,suffix,".recall_precision_ok.pdf"),
plot_recall_precision_papier_ok,
ncol = 2.5,
nrow = 3.5,
nrow = 4.2,
base_aspect_ratio = 1,
limitsize = FALSE
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment