Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 2f69d022 authored by Carine Rey's avatar Carine Rey
Browse files

add plot B'' = delta FP between NeC var

parent a062c9ca
...@@ -351,49 +351,49 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi ...@@ -351,49 +351,49 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
print("plot recall_precision") print("plot recall_precision")
if (length(meths) <= 7) { if (length(meths) <= 7) {
plot = ggplot(df_out, aes(x=sensitivity, y=precision98_02, col = methode)) plot = ggplot(df_out, aes(x=sensitivity, y=precision98_02, col = methode))
plot = plot + theme_bw() plot = plot + theme_bw()
plot = plot + labs(x="Sensitivity (= Recall)", y="Precision (98/2)") plot = plot + labs(x="Sensitivity (= Recall)", y="Precision (98/2)")
plot = plot + theme(legend.position="top") plot = plot + theme(legend.position="top")
plot = plot + ylim(c(0,1)) + xlim(c(0,1)) plot = plot + ylim(c(0,1)) + xlim(c(0,1))
plot = plot + guides(fill=FALSE) plot = plot + guides(fill=FALSE)
plot = plot + scale_color_manual(values=colors2) plot = plot + scale_color_manual(values=colors2)
#plot = plot + geom_point(size=1, alpha=alpha) #plot = plot + geom_point(size=1, alpha=alpha)
plot = plot + geom_step(direction="vh", size=0.5, alpha=alpha) plot = plot + geom_step(direction="vh", size=0.5, alpha=alpha)
plot = plot + geom_hline( aes(yintercept = 0.9), col="black" , size = 0.5, show.legend = NA,linetype="dashed") 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(. ~ couple )
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1)) plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
legend_PR = get_legend(plot + theme(legend.position="top", legend_PR = get_legend(plot + theme(legend.position="top",
legend.text = element_text(size=10), legend.text = element_text(size=10),
legend.title = element_text(size=0), legend.title = element_text(size=0),
plot.margin = unit(x = c(0, 0, 0, 0), units = "cm"), plot.margin = unit(x = c(0, 0, 0, 0), units = "cm"),
legend.background = element_rect(fill="white", size=0.5, linetype="solid", legend.background = element_rect(fill="white", size=0.5, linetype="solid",
colour ="black")) + colour ="black")) +
guides( colour = guide_legend(override.aes = list(alpha = 1,size = 3), nrow=2)) guides( colour = guide_legend(override.aes = list(alpha = 1,size = 3), nrow=2))
) )
plot_recall_precision_papier = plot_grid(legend_PR, plot + theme(legend.position="none"), ncol = 1, scale = 1, plot_recall_precision_papier = plot_grid(legend_PR, plot + theme(legend.position="none"), ncol = 1, scale = 1,
labels = c("",""), labels = c("",""),
align = "h", align = "h",
rel_heights = c( 0.3, 0.7), rel_heights = c( 0.3, 0.7),
hjust = 0, vjust = 1) hjust = 0, vjust = 1)
save_plot(paste0(opt$out,suffix,".recall_precision.pdf"), save_plot(paste0(opt$out,suffix,".recall_precision.pdf"),
plot_recall_precision_papier, plot_recall_precision_papier,
ncol = 0.6* length(unique(df_out_melt$couple)), ncol = 0.6* length(unique(df_out_melt$couple)),
nrow = 1, nrow = 1,
base_aspect_ratio = 1, base_aspect_ratio = 1,
limitsize = FALSE limitsize = FALSE
) )
} else { } else {
plot_recall_precision_papier = NULL plot_recall_precision_papier = NULL
} }
print("plot FPR") print("plot FPR")
#dcast
x_labs = "Threshold" x_labs = "Threshold"
y_labs = "FP Rate (1 -Spe)" y_labs = "FP Rate (1 -Spe)"
df_out_melt2 = subset(df_out_melt,couple%in%c("H0/HaPC NeG5", "H0/HaPC NeG5_NeC_div2" , "H0/HaPC NeG5_NeC_x2")) df_out_melt2 = subset(df_out_melt,couple%in%c("H0/HaPC NeG5", "H0/HaPC NeG5_NeC_div2" , "H0/HaPC NeG5_NeC_x2"))
...@@ -402,34 +402,110 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi ...@@ -402,34 +402,110 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
df_out_melt2$FPR = 1 - df_out_melt2$value df_out_melt2$FPR = 1 - df_out_melt2$value
if (length(df_out_melt2$methode) > 0){ if (length(df_out_melt2$methode) > 0){
df_recall_sup09_per_meth2 = subset(df_recall_sup09_per_meth, couple %in%c("H0/HaPC NeG5", "H0/HaPC NeG5_NeC_div2" , "H0/HaPC NeG5_NeC_x2")) df_recall_sup09_per_meth2 = subset(df_recall_sup09_per_meth, couple %in%c("H0/HaPC NeG5", "H0/HaPC NeG5_NeC_div2" , "H0/HaPC NeG5_NeC_x2"))
df_recall_sup09_per_meth2$couple = gsub("/HaPC ","",df_recall_sup09_per_meth2$couple) df_recall_sup09_per_meth2$couple = gsub("/HaPC ","",df_recall_sup09_per_meth2$couple)
plot = ggplot(df_out_melt2, aes(x=threshold, y=FPR, col=couple)) plot = ggplot(df_out_melt2, aes(x=threshold, y=FPR, col=couple))
plot = plot + theme_bw() plot = plot + theme_bw()
plot = plot + theme(legend.position="top", plot = plot + theme(legend.position="top",
legend.background = element_rect(fill="white", size=0.5, linetype="solid", colour ="black")) + legend.background = element_rect(fill="white", size=0.5, linetype="solid", colour ="black")) +
guides(colour = guide_legend(override.aes = list(alpha = 1), nrow=2)) guides(colour = guide_legend(override.aes = list(alpha = 1), nrow=2))
plot = plot + guides(fill=FALSE) + theme(legend.position="top") plot = plot + guides(fill=FALSE) + theme(legend.position="top")
plot = plot + labs(x=x_labs, y=y_labs) plot = plot + labs(x=x_labs, y=y_labs)
plot = plot + ylim(c(0,1)) + xlim(c(0,1)) plot = plot + ylim(c(0,1)) + xlim(c(0,1))
plot = plot + geom_step(size=1, alpha=alpha) plot = plot + geom_step(size=1, alpha=alpha)
plot = plot + scale_color_manual(values=colors) plot = plot + scale_color_manual(values=colors)
plot = plot + geom_vline( data = df_recall_sup09_per_meth2 , aes(xintercept = threshold, col=couple), size = 0.5, show.legend = NA,linetype="dashed") plot = plot + geom_vline( data = df_recall_sup09_per_meth2 , aes(xintercept = threshold, col=couple), size = 0.5, show.legend = NA,linetype="dashed")
plot = plot + facet_grid(. ~ methode, scales="free") plot = plot + facet_grid(. ~ methode, scales="free")
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1)) plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot_FPR = plot plot_FPR = plot
save_plot(paste0(opt$out,suffix,".FPR.pdf"), save_plot(paste0(opt$out,suffix,".FPR.pdf"),
plot_FPR, plot_FPR,
ncol = 0.4 * length(unique(df_out_melt$methode)), ncol = 0.4 * length(unique(df_out_melt$methode)),
nrow = 1, nrow = 1,
base_aspect_ratio = 1.5, base_aspect_ratio = 1.5,
limitsize = FALSE limitsize = FALSE
) )
if (length(unique(df_out_melt2$couple)) == 3){
print(head(df_out_melt2))
df_out_melt2_dcast = dcast(df_out_melt2, methode + threshold ~ couple, value.var="FPR" )
print(head(df_out_melt2_dcast))
print(df_out_melt2_dcast)
# complete values for not existing threshold between couple
complete_value=function(df, col_name) {
print(colnames(df))
print(col_name)
df = df [,c("methode","threshold",col_name)]
colnames(df) = c("methode","threshold","value")
fix_val = function(r,df_no_na) {
x = r["value"]
t = r["threshold"]
if (is.na(x)) {
t_n = df_no_na$t [ df_no_na$t < t ]
t_n = t_n [length(t_n)]
x = df_no_na$value[df_no_na$t == t_n]
}
return(x)
}
df_ok = do.call(rbind, lapply(split(df,df$methode),
function(df_meth) {
df_no_na = df_meth[! is.na(df_meth$value),]
df_meth$value = apply(df_meth[,c(2,3)],1,fix_val,df_no_na=df_no_na)
return(df_meth)
}))
return(df_ok[,3])
}
df_out_melt2_dcast$H0NeG5 = complete_value(df_out_melt2_dcast, "H0NeG5")
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")
print(df_out_melt2_dcast)
df_out_melt2_dcast$d_H0NeG5_NeC_x2_H0NeG5 = df_out_melt2_dcast$H0NeG5_NeC_x2 - df_out_melt2_dcast$H0NeG5
df_out_melt2_dcast$d_H0NeG5_NeC_div2_H0NeG5 = df_out_melt2_dcast$H0NeG5_NeC_div2 - df_out_melt2_dcast$H0NeG5
print(df_out_melt2_dcast)
df_out_melt2_dcast_melt = melt(df_out_melt2_dcast[,c("methode", "threshold","d_H0NeG5_NeC_x2_H0NeG5","d_H0NeG5_NeC_div2_H0NeG5")], id.vars= c("methode", "threshold"))
print(head(df_out_melt2_dcast_melt))
df_out_melt2_dcast_melt$variable = factor(df_out_melt2_dcast_melt$variable, levels = c("H0NeG5","H0NeG5_NeC_x2","H0NeG5_NeC_div2","d_H0NeG5_NeC_x2_H0NeG5","d_H0NeG5_NeC_div2_H0NeG5"))
df_recall_sup09_per_meth3 = subset(df_recall_sup09_per_meth2, couple %in%c("H0NeG5"))
df_recall_sup09_per_meth3$variable = df_recall_sup09_per_meth3$couple
df_recall_sup09_per_meth3$variable = factor(df_recall_sup09_per_meth3$variable, levels = c("H0NeG5","H0NeG5_NeC_x2","H0NeG5_NeC_div2","d_H0NeG5_NeC_x2_H0NeG5","d_H0NeG5_NeC_div2_H0NeG5"))
x_labs = "Threshold"
y_labs = "Delta FP Rate"
plot = ggplot()
plot = plot + theme_bw()
plot = plot + theme(legend.position="top",
legend.background = element_rect(fill="white", size=0.5, linetype="solid", colour ="black")) +
guides(colour = guide_legend(override.aes = list(alpha = 1), nrow=2))
plot = plot + guides(fill=FALSE) + theme(legend.position="top")
plot = plot + labs(x=x_labs, y=y_labs)
plot = plot + ylim(c(-1,1)) + xlim(c(0,1))
plot = plot + geom_vline(data = df_recall_sup09_per_meth3 , aes(xintercept = threshold, col=variable), size = 0.5, show.legend = NA,linetype="dashed")
plot = plot + geom_step(data = df_out_melt2_dcast_melt, aes(x=threshold, y=value, col=variable), size=1, alpha=alpha)
plot = plot + scale_color_manual(values=colors[c(2,3,1)])
plot = plot + facet_grid(. ~ methode, scales="free")
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot_FPR2 = plot
} else {
plot_FPR2 = NULL
}
} else { } else {
plot_FPR = NULL plot_FPR = NULL
plot_FPR2 = NULL
} }
...@@ -552,16 +628,16 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi ...@@ -552,16 +628,16 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
# nrow=7 # nrow=7
# ) # )
plot = plot_grid(plot_recall_precision,plot_recall_precision_papier,plot_max_MCC,plot_FPR, plot = plot_grid(plot_recall_precision,plot_recall_precision_papier,plot_max_MCC,plot_FPR,plot_FPR2,
labels = c("A", "A'", "B","B'"), labels = c("A", "A'", "B","B'","B''"),
rel_heights = c(length(unique(df_out$couple))*0.8,2,4,2), rel_heights = c(length(unique(df_out$couple))*0.8,2,4,2,2),
nrow=4 nrow=5
) )
save_plot(paste0(opt$out,suffix,".pdf"), save_plot(paste0(opt$out,suffix,".pdf"),
plot, plot,
ncol = 0.4* length(unique(df_out_melt$methode)), ncol = 0.4* length(unique(df_out_melt$methode)),
nrow = length(unique(df_out$couple)) * 0.5 + 1 + 1 +1 , nrow = length(unique(df_out$couple)) * 0.5 + 1 + 1 +1 +1,
base_aspect_ratio = 1, base_aspect_ratio = 1,
limitsize = FALSE 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