Commit 0009f51e by Carine Rey

### try calculate auc

parent 5c6f471b
 ... ... @@ -366,15 +366,45 @@ 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)] 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 R_tmp = R for (i in seq(1,length(P)-1)) { R_i = R[i] + (R[i+1] - R[i]) * 0.001 P_i = P[i+1] P_tmp = c(P_tmp, P_i) R_tmp = c(R_tmp, R_i) } P = P_tmp[order(R_tmp)] R = R_tmp[order(R_tmp)] } auc = auc(x = R, y = P, dens = 1) best_R_90_P = max(0,R[P>=0.9]) 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) 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) })) df_auc = df_auc[order(df_auc\$couple),] condensed_meths = c("PCOC","Diffsel_mean","Identical_LG08","Mutinomial_1MinusLRT","Tdg09_1MinusLRT","Msd_1MinusP","Msd_0.05_1MinusP","Topological_LG08") df_auc = subset(df_auc, methode %in% condensed_meths) df_auc\$auc_rank = unlist(tapply(df_auc\$auc,df_auc\$couple, function(x){rank(-x)})) df_auc\$auc2_rank = unlist(tapply(df_auc\$auc2,df_auc\$couple, function(x){rank(-x)})) df_auc\$best_R_90_P_rank = unlist(tapply(df_auc\$best_R_90_P,df_auc\$couple,function(x){rank(-x)})) print(df_auc) ######################################################################## ... ... @@ -558,7 +588,7 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi plot = plot + guides(fill=FALSE) + theme(legend.position="top") plot = plot + labs(x=x_labs, y=y_labs) plot = plot + ylim(c(0,1)) + xlim(c(0,1)) plot = plot + geom_step(size=1, alpha=alpha) plot = plot + geom_step(size=1,direction="vh", alpha=alpha) 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 + facet_grid(. ~ methode, scales="free") ... ... @@ -674,7 +704,7 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi plot = plot + guides(fill=FALSE) + theme(legend.position="top") plot = plot + labs(x=x_labs, y=y_labs) #+ ylim(y_lim) #plot = plot + geom_point(size=0.5, alpha=alpha) plot = plot + geom_step(size=1, alpha=alpha) plot = plot + geom_step(size=1, direction="vh",alpha=alpha) plot = plot + scale_color_manual(values=colors) #plot = plot + geom_hline( data = df_max_mcc_per_method_2, aes(yintercept = MCC), alpha=alpha, show.legend = NA) plot = plot + geom_vline( data = df_recall_sup09_per_meth, aes(xintercept = threshold, col=couple), size = 0.5, show.legend = NA,linetype="dashed") ... ... @@ -834,5 +864,6 @@ write.table(df_d, file=paste0(opt\$out,".complete_d.tsv"), row.names=FALSE, quote write.table(df_out, file=paste0(opt\$out,".complete.tsv"), row.names=FALSE, quote=F, sep = "\t") write.table(df_auc, file=paste0(opt\$out,".auc.tsv"), row.names=FALSE, quote=F, sep = "\t") write.table(subset(df_auc, methode %in% condensed_meths), file=paste0(opt\$out,".auc_condensed.tsv"), row.names=FALSE, quote=F, sep = "\t") write.table(df_auc, file=paste0(opt\$out,".auc_condensed.tsv"), row.names=FALSE, quote=F, sep = "\t") write.table(df_max_mcc_per_method, file=paste0(opt\$out,".max_MCC_per_meth.tsv"), row.names=FALSE, quote=F, sep = "\t") write.table(df_recall_sup09_per_meth, file=paste0(opt\$out,".recall09_per_meth.tsv"), row.names=FALSE, quote=F, sep = "\t")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!