Commit 0a6c5655 authored by Carine Rey's avatar Carine Rey
Browse files

change plot article

parent 0349dd9d
......@@ -33,27 +33,27 @@ option_list = list(
make_option(c("--HaPC_NeG5_NeC_x2_res" ) , type="character", default=NA, help="merged_results HaPC_NeG5_NeC_x2_res" , metavar="character"),
make_option(c("--H0_NeG5_NeC_div2_res" ) , type="character", default=NA, help="merged_results H0_NeG5_NeC_div2_res" , metavar="character"),
make_option(c("--H0_NeG5_NeC_x2_res" ) , type="character", default=NA, help="merged_results H0_NeG5_NeC_x2_res" , metavar="character"),
make_option(c("--HaPC_NeG5_NeC_1_res" ) , type="character", default=NA, help="merged_results HaPC_NeG5_NeC_1_res" , metavar="character"),
make_option(c("--H0_NeG5_NeC_1_res" ) , type="character", default=NA, help="merged_results H0_NeG5_NeC_1_res" , metavar="character"),
make_option(c("--HaPC_NeG1_NeC_5_res" ) , type="character", default=NA, help="merged_results HaPC_NeG1_NeC_5_res" , metavar="character"),
make_option(c("--H0_NeG1_NeC_5_res" ) , type="character", default=NA, help="merged_results H0_NeG1_NeC_5_res" , metavar="character"),
make_option(c("--HaPC_NeG8_NeC_1_res" ) , type="character", default=NA, help="merged_results HaPC_NeG8_NeC_1_res" , metavar="character"),
make_option(c("--H0_NeG8_NeC_1_res" ) , type="character", default=NA, help="merged_results H0_NeG8_NeC_1_res" , metavar="character"),
make_option(c("--HaPC_NeG1_NeC_8_res" ) , type="character", default=NA, help="merged_results HaPC_NeG1_NeC_8_res" , metavar="character"),
make_option(c("--H0_NeG1_NeC_8_res" ) , type="character", default=NA, help="merged_results H0_NeG1_NeC_8_res" , metavar="character"),
make_option(c("--HaPC_NeG16_NeC_1_res" ) , type="character", default=NA, help="merged_results HaPC_NeG16_NeC_1_res" , metavar="character"),
make_option(c("--H0_NeG16_NeC_1_res" ) , type="character", default=NA, help="merged_results H0_NeG16_NeC_1_res" , metavar="character"),
make_option(c("--HaPC_NeG1_NeC_16_res" ) , type="character", default=NA, help="merged_results HaPC_NeG1_NeC_16_res" , metavar="character"),
make_option(c("--H0_NeG1_NeC_16_res" ) , type="character", default=NA, help="merged_results H0_NeG1_NeC_16_res" , metavar="character"),
make_option(c("--HaPC_NeG4_NeC_1_res" ) , type="character", default=NA, help="merged_results HaPC_NeG4_NeC_1_res" , metavar="character"),
make_option(c("--H0_NeG4_NeC_1_res" ) , type="character", default=NA, help="merged_results H0_NeG4_NeC_1_res" , metavar="character"),
make_option(c("--HaPC_NeG1_NeC_4_res" ) , type="character", default=NA, help="merged_results HaPC_NeG1_NeC_4_res" , metavar="character"),
make_option(c("--H0_NeG1_NeC_4_res" ) , type="character", default=NA, help="merged_results H0_NeG1_NeC_4_res" , metavar="character"),
make_option(c("--HaPC_NeG4_NeC_8_res" ) , type="character", default=NA, help="merged_results HaPC_NeG4_NeC_8_res" , metavar="character"),
make_option(c("--H0_NeG4_NeC_8_res" ) , type="character", default=NA, help="merged_results H0_NeG4_NeC_8_res" , metavar="character"),
make_option(c("--HaPC_NeG8_NeC_4_res" ) , type="character", default=NA, help="merged_results HaPC_NeG8_NeC_4_res" , metavar="character"),
......@@ -65,7 +65,7 @@ option_list = list(
make_option(c("--H0_NeG2_NeC_4_res" ) , type="character", default=NA, help="merged_results H0_NeG2_NeC_4_res" , metavar="character"),
make_option(c("--HaPC_NeG4_NeC_2_res" ) , type="character", default=NA, help="merged_results HaPC_NeG4_NeC_2_res" , metavar="character"),
make_option(c("--H0_NeG4_NeC_2_res" ) , type="character", default=NA, help="merged_results H0_NeG4_NeC_2_res" , metavar="character"),
make_option(c("--H0_NeG5_indel_res" ) , type="character", default=NA, help="merged_results H0_NeG5_indel_res" , metavar="character"),
make_option(c("--HaPC_NeG5_indel_res" ) , type="character", default=NA, help="merged_results HaPC_NeG5_indel_res" , metavar="character"),
make_option(c("--HaPCOC" ) , type="character", default=NA, help="merged_results HaPCOC" , metavar="character"),
......@@ -559,17 +559,17 @@ df_auc = do.call(rbind, lapply(split(df_out,paste0(df_out$methode,df_out$couple)
P = x$precision98_02
R = R[! is.na(P)]
P = P[! is.na(P)]
P = P[order(R)]
P = P[order(R)]
R = R[order(R)]
auc = 0
auc2 = 0
best_R_90_P = NA
if (length(P) > 1) {
# add point for step curves
if (length(P) < 20) {
P_tmp = P
P_tmp = P
R_tmp = R
for (i in seq(1,length(P)-1)) {
R_i = R[i] + (R[i+1] - R[i]) * 0.001
......@@ -582,12 +582,12 @@ df_auc = do.call(rbind, lapply(split(df_out,paste0(df_out$methode,df_out$couple)
}
auc = auc(x = R, y = P, dens = 1)
best_R_90_P = max(0,R[P>=0.9])
P = c(P[1],P)
P = c(P[1],P)
R = c(0,R)
auc2 = auc(x = R, y = P, dens = 1)
}
df= data.frame(methode =x$methode[1] ,couple =x$couple[1] ,auc=auc,best_R_90_P=best_R_90_P,auc2=auc2)
return(df)
}))
......@@ -679,17 +679,17 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
limitsize = FALSE
)
print("plot recall_precision")
couple_plot1 = c("H0/HaPC NeG1","H0/HaPC NeG4","H0/HaPC NeG8")
couple_plot2 = c("H0/H0 NeG8/NeG8_NeC_1","H0/H0 NeG4/NeG4_NeC_8","H0/H0 NeG1/NeG1_NeC_4")
couple_plot3 = c("H0/HaPC NeG4_NeC_8","H0/HaPC NeG8_NeC_1","H0/HaPC NeG1_NeC_4")
couple_plot4 = c("H0 NeG1/HaPC NeG1_NeC_4","H0 NeG8/HaPC NeG8_NeC_1","H0 NeG4/HaPC NeG4_NeC_8")
couple_plot2 = c("H0/H0 NeG1/NeG1_NeC_4","H0/H0 NeG4/NeG4_NeC_8","H0/H0 NeG8/NeG8_NeC_1")
couple_plot3 = c("H0/HaPC NeG1_NeC_4", "H0/HaPC NeG4_NeC_8","H0/HaPC NeG8_NeC_1")
couple_plot4 = c("H0 NeG1/HaPC NeG1_NeC_4","H0 NeG4/HaPC NeG4_NeC_8","H0 NeG8/HaPC NeG8_NeC_1")
couple_i = c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
print(couple_i)
print( grep("H",couple_i))
couple_i = couple_i[grep("H",couple_i)]
print(couple_i)
......@@ -734,9 +734,9 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
base_aspect_ratio = 1,
limitsize = FALSE
)
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","to_be_rm3","to_be_rm4"))
if ("NULL" %in% couple_l) {
......@@ -759,6 +759,16 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
to_m=c("PCOC","Mutinomial", "msd", "Identical", "TDG09","Topological","diffsel")
tmp_df$methode = mapvalues(tmp_df$methode, from=from_m, to=to_m)
tmp_df$methode = factor(tmp_df$methode, levels=to_m)
from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
couple_plot1_to = c("PC NeSG1","PC NeSG4","PC NeSG8")
couple_plot2_to = c("CCSE NeSG1 NeSG1 NeSC 4","CCSE NeSG4 NeSC 8","CCSE NeSG8 NeSC 1")
couple_plot3_to = c("PC & GCSE NeSG1 NeSC 4","PC & GCSE NeSG4 NeSC 8","PC & GCSE NeSG8 NeSC 1")
couple_plot4_to = c("PC & CCSE NeSG1 NeSC 4","PC & CCSE NeSG4 NeSC 8","PC & CCSE NeSG8 NeSC 1")
to_c= c(couple_plot1_to,couple_plot2_to,couple_plot3_to,couple_plot4_to)
tmp_df$coupleF = mapvalues(tmp_df$couple, from=from_c, to=to_c)
tmp_df$coupleF = factor(tmp_df$coupleF, levels =unique(c(couple_plot1_to,couple_plot2_to,couple_plot4_to,couple_plot3_to)))
plot = ggplot(tmp_df, aes(x=sensitivity, y=precision98_02, col = methode))
plot = plot + theme_bw()
plot = plot + labs(x="Sensitivity (= Recall)", y="Precision")
......@@ -768,42 +778,53 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
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) < 8) {
#add AUC values
df_auc_label = subset(df_auc, couple %in% tmp_df$couple)
df_auc_label$coupleF = mapvalues(df_auc_label$couple, from=from_c, to=to_c)
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$methode = mapvalues(df_auc_label$methode, from=from_m, to=to_m)
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 ")
df_auc_leg = data.frame(coupleF = unique(tmp_df$coupleF), 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), size = 2.5,label.padding = unit(0.15, "lines"))
plot = plot + geom_label(data=df_auc_leg, aes(x=x, y=y, label=label), col="black", size = 2.5,label.padding = unit(0.15, "lines"))
}
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 + facet_grid(. ~ coupleF )
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot
}
plot_AUC_c = function(couple_l) {
tmp_df = subset(df_auc,couple%in%couple_l)
tmp_df$group = "group0"
tmp_df$group[tmp_df$couple%in%couple_plot1] = "group1"
tmp_df$group[tmp_df$couple%in%couple_plot2] = "group2"
tmp_df$group[tmp_df$couple%in%couple_plot3] = "group3"
tmp_df$group[tmp_df$couple%in%couple_plot4] = "group4"
tmp_df$couple = factor( tmp_df$couple, levels=c(levels( tmp_df$couple)))
couple_NeSG1 = couple_l[grep("NeG1",couple_l)]
couple_NeSG4 = couple_l[grep("NeG4",couple_l)]
couple_NeSG8 = couple_l[grep("NeG8",couple_l)]
tmp_df$group[tmp_df$couple%in%couple_NeSG1] = "NeSG1"
tmp_df$group[tmp_df$couple%in%couple_NeSG4] = "NeSG4"
tmp_df$group[tmp_df$couple%in%couple_NeSG8] = "NeSG8"
from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
couple_plot1_to = c("PC","PC","PC")
couple_plot2_to = c("CCSE NeSC 4","CCSE NeSC 8","CCSE NeSC 1")
couple_plot3_to = c("PC & GCSE NeSC 4","PC & GCSE NeSC 8","PC & GCSE NeSC 1")
couple_plot4_to = c("PC & CCSE NeSC 4","PC & CCSE NeSC 8","PC & CCSE NeSC 1")
to_c= c(couple_plot1_to,couple_plot2_to,couple_plot3_to,couple_plot4_to)
tmp_df$coupleX = mapvalues(tmp_df$couple, from=from_c, to=to_c)
tmp_df$coupleX = factor(tmp_df$coupleX, levels =unique(c(couple_plot1_to,couple_plot2_to,couple_plot4_to,couple_plot3_to)))
from_m=c("PCOC","Mutinomial_1MinusLRT", "Msd_0.05_1MinusP", "Identical_LG08", "Tdg09_1MinusLRT","Topological_LG08","diffsel_mean")
to_m=c("PCOC","Mutinomial", "msd", "Identical", "TDG09","Topological","diffsel")
tmp_df$methode = mapvalues(tmp_df$methode, from=from_m, to=to_m)
tmp_df$methode = factor(tmp_df$methode, levels=to_m)
plot = ggplot(tmp_df, aes(x=couple, y=auc2, col = methode))
plot = ggplot(tmp_df, aes(x=coupleX, y=auc2, col = methode))
plot = plot + theme_bw()
plot = plot + labs(x="", y="AUC")
plot = plot + theme(legend.position="top")
......@@ -817,23 +838,35 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
plot
}
plot_Best_R_c = function(couple_l) {
tmp_df = subset(df_auc,couple%in%couple_l)
tmp_df$group = "group0"
tmp_df$group[tmp_df$couple%in%couple_plot1] = "group1"
tmp_df$group[tmp_df$couple%in%couple_plot2] = "group2"
tmp_df$group[tmp_df$couple%in%couple_plot3] = "group3"
tmp_df$group[tmp_df$couple%in%couple_plot4] = "group4"
tmp_df$couple = factor( tmp_df$couple, levels=c(levels( tmp_df$couple)))
couple_NeSG1 = couple_l[grep("NeG1",couple_l)]
couple_NeSG4 = couple_l[grep("NeG4",couple_l)]
couple_NeSG8 = couple_l[grep("NeG8",couple_l)]
tmp_df$group[tmp_df$couple%in%couple_NeSG1] = "NeSG1"
tmp_df$group[tmp_df$couple%in%couple_NeSG4] = "NeSG4"
tmp_df$group[tmp_df$couple%in%couple_NeSG8] = "NeSG8"
from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
couple_plot1_to = c("PC","PC","PC")
couple_plot2_to = c("CCSE NeSC 4","CCSE NeSC 8","CCSE NeSC 1")
couple_plot3_to = c("PC & GCSE NeSC 4","PC & GCSE NeSC 8","PC & GCSE NeSC 1")
couple_plot4_to = c("PC & CCSE NeSC 4","PC & CCSE NeSC 8","PC & CCSE NeSC 1")
to_c= c(couple_plot1_to,couple_plot2_to,couple_plot3_to,couple_plot4_to)
tmp_df$coupleX = mapvalues(tmp_df$couple, from=from_c, to=to_c)
tmp_df$coupleX = factor(tmp_df$coupleX, levels =unique(c(couple_plot1_to,couple_plot2_to,couple_plot4_to,couple_plot3_to)))
from_m=c("PCOC","Mutinomial_1MinusLRT", "Msd_0.05_1MinusP", "Identical_LG08", "Tdg09_1MinusLRT","Topological_LG08","diffsel_mean")
to_m=c("PCOC","Mutinomial", "msd", "Identical", "TDG09","Topological","diffsel")
tmp_df$methode = mapvalues(tmp_df$methode, from=from_m, to=to_m)
tmp_df$methode = factor(tmp_df$methode, levels=to_m)
plot = ggplot(tmp_df, aes(x=couple, y=best_R_90_P, col = methode))
tmp_df$best_R_90_P[is.na(tmp_df$best_R_90_P)] = 0
plot = ggplot(tmp_df, aes(x=coupleX, y=best_R_90_P, col = methode))
plot = plot + theme_bw()
plot = plot + labs(x="", y="best_R_90_P")
plot = plot + labs(x="", y="Recall at 90% of precision")
plot = plot + theme(legend.position="top")
plot = plot + ylim(c(0,1))
plot = plot + guides(fill=FALSE)
......@@ -844,7 +877,7 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
plot = plot + facet_grid(. ~ group, scales = "free", space = "free")
plot
}
plot = plot_PR_c(couple_i)
plot1 = plot_PR_c(couple_plot1)
plot2 = plot_PR_c(couple_plot2)
......@@ -890,26 +923,22 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
"",
"TEST"),
align = "h",
rel_heights = c( 0.2, 0.7,0.05,0.7,0.05,0.7,0.05,0.7,0.05,0.7),
hjust = 0, vjust = 0)
plot_recall_precision_papier_ok = plot_grid(legend_PR,
plot1 + theme(legend.position="none"),
NULL,
plot5 + theme(legend.position="none"),
NULL,
plot6 + theme(legend.position="none"),
ncol = 1, scale = 1,
labels = c("",
"A",
"",
"B",
"",
"C"),
align = "h",
rel_heights = c(0.15, 0.6,0.05,0.8,0.05,0.8),
rel_heights = c(0.15, 0.6,0.75,0.75),
hjust = 0, vjust = 0)
......@@ -1004,10 +1033,10 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
df_out_melt2_dcast$H0NeG5 = complete_value(df_out_melt2_dcast, "H0NeG5")
df_out_melt2_dcast$H0NeG1 = complete_value(df_out_melt2_dcast, "H0NeG1")
#df_out_melt2_dcast$H0NeG5_NeC_x2 = complete_value(df_out_melt2_dcast, "H0NeG5_NeC_x2")
#df_out_melt2_dcast$H0NeG5_NeC_div2 = complete_value(df_out_melt2_dcast, "H0NeG5_NeC_div2")
df_out_melt2_dcast$H0NeG1_NeC_5 = complete_value(df_out_melt2_dcast, "H0NeG1_NeC_5")
df_out_melt2_dcast$H0NeG5_NeC_1 = complete_value(df_out_melt2_dcast, "H0NeG5_NeC_1")
......
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