Commit 0349dd9d authored by Carine Rey's avatar Carine Rey
Browse files

change plot article

parent ce84ac24
......@@ -616,7 +616,7 @@ print(df_only_auc)
########################################################################
plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffix="") {
plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NULL, suffix="") {
nb_c = length(unique(df_out$couple))
colors = c(c("#984EA3","#4AA947","#377EB8","#E41A1C","#F5BE5B","#90EE90","#8B6914","#BFBFBF","#0000FF","#FFC0CB","#FFA500","#FFFF00")[1:nb_c], c("#7F7F7F","#ADD8E6"))
......@@ -626,6 +626,7 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
if (! is.null(meths)) {
df_out = df_out[df_out$methode %in%meths,]
df_d = df_d[df_d$methode %in%meths,]
df_auc = df_auc[df_auc$methode %in%meths,]
df_recall_sup09_per_meth = df_recall_sup09_per_meth[df_recall_sup09_per_meth$methode %in%meths,]
meths = meths[meths %in% df_out$methode]
} else {
......@@ -736,60 +737,121 @@ 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","to_be_rm3","to_be_rm4"))
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 ("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"
}
if ("NULL3" %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_rm3"
}
if ("NULL4" %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_rm4"
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) {
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm"
}
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"
}
if ("NULL3" %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_rm3"
}
if ("NULL4" %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_rm4"
}
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=sensitivity, y=precision98_02, col = methode))
plot = plot + theme_bw()
plot = plot + labs(x="Sensitivity (= Recall)", y="Precision")
plot = plot + theme(legend.position="top")
plot = plot + ylim(c(0,1)) + xlim(c(0,1))
plot = plot + guides(fill=FALSE)
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 = 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 ")
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 + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot
}
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)
plot = ggplot(tmp_df, aes(x=sensitivity, y=precision98_02, col = methode))
plot = plot + theme_bw()
plot = plot + labs(x="Sensitivity (= Recall)", y="Precision")
plot = plot + theme(legend.position="top")
plot = plot + ylim(c(0,1)) + xlim(c(0,1))
plot = plot + guides(fill=FALSE)
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 = 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 ")
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_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)))
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 = plot + theme_bw()
plot = plot + labs(x="", y="AUC")
plot = plot + theme(legend.position="top")
plot = plot + ylim(c(0,1))
plot = plot + guides(fill=FALSE)
plot = plot + scale_color_manual(values=colors2)
#plot = plot + geom_point(size=1, alpha=alpha)
plot = plot + geom_point(na.rm=TRUE, position=position_dodge(width=0.5),size=1.5,alpha=1)
plot = plot + theme(axis.text.x = element_text(angle =45, hjust = 1))
plot = plot + facet_grid(. ~ group, scales = "free", space = "free")
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)))
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))
plot = plot + theme_bw()
plot = plot + labs(x="", y="best_R_90_P")
plot = plot + theme(legend.position="top")
plot = plot + ylim(c(0,1))
plot = plot + guides(fill=FALSE)
plot = plot + scale_color_manual(values=colors2)
#plot = plot + geom_point(size=1, alpha=alpha)
plot = plot + geom_point(na.rm=TRUE, position=position_dodge(width=0.5),size=1.5,alpha=1)
plot = plot + theme(axis.text.x = element_text(angle =45, hjust = 1))
plot = plot + facet_grid(. ~ group, scales = "free", space = "free")
plot
}
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(couple_i)
plot1 = plot_PR_c(couple_plot1)
plot2 = plot_PR_c(couple_plot2)
plot3 = plot_PR_c(couple_plot3)
plot4 = plot_PR_c(couple_plot4)
plot5 = plot_AUC_c(couple_i)
plot6 = plot_Best_R_c(couple_i)
legend_PR = get_legend(plot + theme(legend.position="top",
legend.text = element_text(size=10),
......@@ -798,6 +860,13 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
colour ="black")) +
guides( colour = guide_legend(override.aes = list(alpha = 1,size = 3), nrow=1))
)
legend_AUC = get_legend(plot5 + theme(legend.position="top",
legend.text = element_text(size=10),
legend.title = element_text(size=0),
legend.background = element_rect(fill="white", size=0.5, linetype="solid",
colour ="black")) +
guides( colour = guide_legend(override.aes = list(alpha = 1,size = 3), nrow=1))
)
plot_recall_precision_papier_ok = plot_grid(legend_PR,
plot1 + theme(legend.position="none"),
......@@ -807,6 +876,8 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
plot3 + theme(legend.position="none"),
NULL,
plot4 + theme(legend.position="none"),
NULL,
plot5 + theme(legend.position="none"),
ncol = 1, scale = 1,
labels = c("",
"Only Pressure Shift",
......@@ -815,10 +886,30 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
"",
"Pressure Shift in a context of global change of Selection Efficacy",
"",
"Pressure Shift+CSE"),
"Pressure Shift+CSE",
"",
"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.2, 0.7,0.05,0.7,0.05,0.7,0.05,0.7),
rel_heights = c(0.15, 0.6,0.05,0.8,0.05,0.8),
hjust = 0, vjust = 0)
......@@ -1132,9 +1223,9 @@ plot_out = function(df_out, df_d , df_recall_sup09_per_meth, meths = NULL, suffi
plot_out(df_out, df_d, df_recall_sup09_per_meth, suffix="")
plot_out(df_out, df_d, df_auc, df_recall_sup09_per_meth, suffix="")
condensed_meths = c("PCOC","Diffsel_mean","Identical_LG08","Mutinomial_1MinusLRT","Tdg09_1MinusLRT","Msd_1MinusP","Msd_0.05_1MinusP","Topological_LG08")
plot_out(df_out, df_d, df_recall_sup09_per_meth, meths=condensed_meths, suffix="_condensed")
plot_out(df_out, df_d, df_auc, df_recall_sup09_per_meth, meths=condensed_meths, suffix="_condensed")
write.table(df_d, file=paste0(opt$out,".complete_d.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!
Please register or to comment