Commit 1a767716 authored by Carine Rey's avatar Carine Rey
Browse files

update figures

parent 8839c5a0
...@@ -697,7 +697,7 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL ...@@ -697,7 +697,7 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
print(couple_i [!couple_i %in% df_out$couple]) print(couple_i [!couple_i %in% df_out$couple])
print(all( couple_i %in% df_out$couple)) print(all( couple_i %in% df_out$couple))
if (length(meths) <= 9 & all( couple_i %in% df_out$couple)) { if (length(meths) <= 9 & sum( couple_i %in% df_out$couple)>= 1) {
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)")
...@@ -736,109 +736,151 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL ...@@ -736,109 +736,151 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
) )
plot_PR_c = function(couple_l) { plot_PR_c = function(couple_l) {
if (sum(couple_l%in%df_out$couple) > 0) {
tmp_df = subset(df_out,couple%in%couple_l) print ("PAS OK")
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 = subset(df_out,couple%in%couple_l)
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],] 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"))
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm" if ("NULL" %in% couple_l) {
} tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
if ("NULL2" %in% couple_l) { tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm"
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],] }
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm2" if ("NULL2" %in% couple_l) {
} tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
if ("NULL3" %in% couple_l) { tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm2"
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],] }
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm3" if ("NULL3" %in% couple_l) {
} tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
if ("NULL4" %in% couple_l) { tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm3"
tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],] }
tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm4" if ("NULL4" %in% couple_l) {
} tmp_df[dim(tmp_df)[1]+1,] = tmp_df[dim(tmp_df)[1],]
from_m=c("PCOC","Mutinomial_1MinusLRT", "Msd_0.05_1MinusP", "Identical_LG08", "Tdg09_1MinusLRT","Topological_LG08","diffsel_mean") tmp_df$couple[dim(tmp_df)[1]] = "to_be_rm4"
to_m=c("PCOC","Mutinomial", "msd", "Identical", "TDG09","Topological","diffsel") }
tmp_df$methode = mapvalues(tmp_df$methode, from=from_m, to=to_m) from_m=c("PCOC","Mutinomial_1MinusLRT", "Msd_0.05_1MinusP", "Identical_LG08", "Tdg09_1MinusLRT","Topological_LG08","Diffsel_mean")
tmp_df$methode = factor(tmp_df$methode, levels=to_m) to_m=c("PCOC","Mutinomial", "msd", "Identical", "TDG09","Topological","diffsel")
tmp_df$methode = mapvalues(tmp_df$methode, from=from_m, to=to_m)
from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4) tmp_df$methode = factor(tmp_df$methode, levels=to_m)
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") from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
couple_plot3_to = c("PC & GCSE NeSG1 NeSC 4","PC & GCSE NeSG4 NeSC 8","PC & GCSE NeSG8 NeSC 1") couple_plot1_to = c("PC NeS 1","PC NeS 4","PC NeS 8")
couple_plot4_to = c("PC & CCSE NeSG1 NeSC 4","PC & CCSE NeSG4 NeSC 8","PC & CCSE NeSG8 NeSC 1") couple_plot2_to = c("CCSE NeSA1 NeSC 4","CCSE NeSA4 NeSC 8","CCSE NeSA8 NeSC 1")
to_c= c(couple_plot1_to,couple_plot2_to,couple_plot3_to,couple_plot4_to) couple_plot3_to = c("PC & GCSE NeSA1 NeSC 4","PC & GCSE NeSA4 NeSC 8","PC & GCSE NeSA8 NeSC 1")
tmp_df$coupleF = mapvalues(tmp_df$couple, from=from_c, to=to_c) couple_plot4_to = c("PC & CCSE NeSA1 NeSC 4","PC & CCSE NeSA4 NeSC 8","PC & CCSE NeSA8 NeSC 1")
tmp_df$coupleF = factor(tmp_df$coupleF, levels =unique(c(couple_plot1_to,couple_plot2_to,couple_plot4_to,couple_plot3_to))) 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)
plot = ggplot(tmp_df, aes(x=sensitivity, y=precision98_02, col = methode)) tmp_df$coupleF = factor(tmp_df$coupleF, levels =unique(c(couple_plot1_to,couple_plot2_to,couple_plot4_to,couple_plot3_to)))
plot = plot + theme_bw()
plot = plot + labs(x="Sensitivity (= Recall)", y="Precision") plot = ggplot(tmp_df, aes(x=sensitivity, y=precision98_02, col = methode))
plot = plot + theme(legend.position="top") plot = plot + theme_bw()
plot = plot + ylim(c(0,1)) + xlim(c(0,1)) plot = plot + labs(x="Sensitivity (= Recall)", y="Precision")
plot = plot + guides(fill=FALSE) plot = plot + theme(legend.position="top")
plot = plot + scale_color_manual(values=colors2) plot = plot + ylim(c(0,1)) + xlim(c(0,1))
#plot = plot + geom_point(size=1, alpha=alpha) plot = plot + guides(fill=FALSE)
plot = plot + geom_step(direction="vh", size=1, alpha=alpha) plot = plot + scale_color_manual(values=colors2)
#plot = plot + geom_point(size=1, alpha=alpha)
if (length(couple_l) < 8) { plot = plot + geom_step(direction="vh", size=1, alpha=alpha)
#add AUC values
df_auc_label = subset(df_auc, couple %in% tmp_df$couple) if (length(couple_l) < 8) {
df_auc_label$coupleF = mapvalues(df_auc_label$couple, from=from_c, to=to_c) #add AUC values
df_auc_label = df_auc_label[df_auc_label$auc2 >= 0.001,] df_auc_label = subset(df_auc, couple %in% tmp_df$couple)
from_r=c(1,2,3,4,5,6,7,8,9) df_auc_label$coupleF = mapvalues(df_auc_label$couple, from=from_c, to=to_c)
to_y = 0.8 - 0.1 * from_r df_auc_label = df_auc_label[df_auc_label$auc2 >= 0.001,]
df_auc_label$y = mapvalues(df_auc_label$auc2_rank, from=from_r, to=to_y) from_r=c(1,2,3,4,5,6,7,8,9)
df_auc_label$methode = mapvalues(df_auc_label$methode, from=from_m, to=to_m) to_y = 0.8 - 0.1 * from_r
df_auc_label$label = substr(as.character(df_auc_label$auc2), 1,5) df_auc_label$y = mapvalues(df_auc_label$auc2_rank, from=from_r, to=to_y)
df_auc_leg = data.frame(coupleF = unique(tmp_df$coupleF), x = 0.9, y = 0.8, label = "AUC ") df_auc_label$methode = mapvalues(df_auc_label$methode, from=from_m, to=to_m)
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")) df_auc_label$label = substr(as.character(df_auc_label$auc2), 1,5)
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")) 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(. ~ coupleF )
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot
} else {
print ("OK")
plot = NULL
} }
plot = plot + geom_hline( aes(yintercept = 0.9), col="black" , size = 0.5, show.legend = NA,linetype="dashed")
plot = plot + facet_grid(. ~ coupleF )
plot = plot + theme(axis.text.x = element_text(angle = 45, hjust = 1))
plot plot
} }
plot_AUC_c = function(couple_l) { plot_AUC_c = function(couple_l,noA=F) {
if (sum(couple_l%in%df_out$couple) > 0) {
tmp_df = subset(df_auc,couple%in%couple_l)
tmp_df$group = "group0" tmp_df = subset(df_auc,couple%in%couple_l)
couple_NeSG1 = couple_l[grep("NeG1",couple_l)] tmp_df$group = "group0"
couple_NeSG4 = couple_l[grep("NeG4",couple_l)] #couple_NeSG1 = couple_l[grep("NeG1",couple_l)]
couple_NeSG8 = couple_l[grep("NeG8",couple_l)] #couple_NeSG4 = couple_l[grep("NeG4",couple_l)]
tmp_df$group[tmp_df$couple%in%couple_NeSG1] = "NeSG1" #couple_NeSG8 = couple_l[grep("NeG8",couple_l)]
tmp_df$group[tmp_df$couple%in%couple_NeSG4] = "NeSG4" #tmp_df$group[tmp_df$couple%in%couple_NeSG1] = "NeSG1"
tmp_df$group[tmp_df$couple%in%couple_NeSG8] = "NeSG8" #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_simuA = c("H0/HaPC NeG1","H0/HaPC NeG4","H0/HaPC NeG8")
couple_plot3_to = c("PC & GCSE NeSC 4","PC & GCSE NeSC 8","PC & GCSE NeSC 1") couple_simuB = c("H0/H0 NeG1/NeG1_NeC_4","H0/H0 NeG4/NeG4_NeC_8","H0/H0 NeG8/NeG8_NeC_1")
couple_plot4_to = c("PC & CCSE NeSC 4","PC & CCSE NeSC 8","PC & CCSE NeSC 1") couple_simuC = c("H0/HaPC NeG1","H0/HaPC NeG8_NeC_1","H0/HaPC NeG4","H0/HaPC NeG1_NeC_4","H0/HaPC NeG8", "H0/HaPC NeG4_NeC_8")
to_c= c(couple_plot1_to,couple_plot2_to,couple_plot3_to,couple_plot4_to) couple_simuD = c("H0/HaPC NeG1","H0/HaPC NeG4","H0/HaPC NeG8", "H0 NeG1/HaPC NeG1_NeC_4","H0 NeG4/HaPC NeG4_NeC_8","H0 NeG8/HaPC NeG8_NeC_1")
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)))
tmp_df$group[tmp_df$couple%in%couple_simuA] = "PC"
from_m=c("PCOC","Mutinomial_1MinusLRT", "Msd_0.05_1MinusP", "Identical_LG08", "Tdg09_1MinusLRT","Topological_LG08","diffsel_mean") tmp_df2 = tmp_df[tmp_df$couple%in%couple_simuA,]
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) if (all(couple_simuB%in%tmp_df$couple)) {
tmp_df$group[tmp_df$couple%in%couple_simuB] = "CCSE"
plot = ggplot(tmp_df, aes(x=coupleX, y=auc2, col = methode)) tmp_df2 = rbind(tmp_df2,tmp_df[tmp_df$couple%in%couple_simuB,])
plot = plot + theme_bw() }
plot = plot + labs(x="", y="AUC") if (all(couple_simuC%in%tmp_df$couple)) {
plot = plot + theme(legend.position="top") tmp_df$group[tmp_df$couple%in%couple_simuC] = "PC & GWCSE"
plot = plot + ylim(c(0,1)) if (noA) {
plot = plot + guides(fill=FALSE) tmp_df2 = tmp_df[tmp_df$couple%in%couple_simuC,]
plot = plot + scale_color_manual(values=colors2) } else {
#plot = plot + geom_point(size=1, alpha=alpha) tmp_df2 = rbind(tmp_df2,tmp_df[tmp_df$couple%in%couple_simuC,])
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") if (all(couple_simuD%in%tmp_df$couple)) {
tmp_df$group[tmp_df$couple%in%couple_simuD] = "PC & CCSE"
tmp_df2 = rbind(tmp_df2,tmp_df[tmp_df$couple%in%couple_simuD,])
}
tmp_df = tmp_df2
from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
couple_plot1_to = c("NeS 1","NeS 4","NeS 8")
couple_plot2_to = c("NeSA 1\nNeSC 4","NeSA 4\nNeSC 8","NeSA 8\nNeSC 1")
couple_plot3_to = c("NeSA 1\nNeSC 4","NeSA 4\nNeSC 8","NeSA 8\nNeSC 1")
couple_plot4_to = c("NeSA 1\nNeSC 4","NeSA 4\nNeSC 8","NeSA 8\nNeSC 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 =c("NeS 1","NeSA 8\nNeSC 1","NeS 4","NeSA 1\nNeSC 4","NeS 8","NeSA 4\nNeSC 8"))
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=coupleX, y=auc2, col = methode, shape = methode, fill=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 + scale_fill_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=3,alpha=1)
plot = plot + scale_shape_manual(values=c(16,18,10,7,17,25,15))
#plot = plot + theme(axis.text.x = element_text(angle =45, hjust = 1))
plot = plot + facet_grid(. ~ group, scales = "free", space = "free")
} else {
plot = NULL
}
plot plot
} }
plot_Best_R_c = function(couple_l) { plot_Best_R_c = function(couple_l) {
if (sum(couple_l%in%df_out$couple) == 0) {return(NULL)}
tmp_df = subset(df_auc,couple%in%couple_l) tmp_df = subset(df_auc,couple%in%couple_l)
tmp_df$group = "group0" tmp_df$group = "group0"
couple_NeSG1 = couple_l[grep("NeG1",couple_l)] couple_NeSG1 = couple_l[grep("NeG1",couple_l)]
...@@ -851,13 +893,13 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL ...@@ -851,13 +893,13 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4) from_c= c(couple_plot1,couple_plot2,couple_plot3,couple_plot4)
couple_plot1_to = c("PC","PC","PC") couple_plot1_to = c("PC","PC","PC")
couple_plot2_to = c("CCSE NeSC 4","CCSE NeSC 8","CCSE NeSC 1") 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_plot3_to = c("PC & GWCSE NeSC 4","PC & GWCSE NeSC 8","PC & GWCSE NeSC 1")
couple_plot4_to = c("PC & CCSE NeSC 4","PC & CCSE NeSC 8","PC & CCSE 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) 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 = 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))) 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") 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") 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 = mapvalues(tmp_df$methode, from=from_m, to=to_m)
tmp_df$methode = factor(tmp_df$methode, levels=to_m) tmp_df$methode = factor(tmp_df$methode, levels=to_m)
...@@ -880,10 +922,12 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL ...@@ -880,10 +922,12 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
plot = plot_PR_c(couple_i) plot = plot_PR_c(couple_i)
plot1 = plot_PR_c(couple_plot1) plot1 = plot_PR_c(couple_plot1)
plot1 = plot_PR_c(c("H0/HaPC NeG4","NULL2","NULL"))
plot2 = plot_PR_c(couple_plot2) plot2 = plot_PR_c(couple_plot2)
plot3 = plot_PR_c(couple_plot3) plot3 = plot_PR_c(couple_plot3)
plot4 = plot_PR_c(couple_plot4) plot4 = plot_PR_c(couple_plot4)
plot5 = plot_AUC_c(couple_i) plot5 = plot_AUC_c(c(couple_plot1,couple_plot2))
plot52 = plot_AUC_c(c(couple_plot1,couple_plot3,couple_plot4), noA = T)
plot6 = plot_Best_R_c(couple_i) plot6 = plot_Best_R_c(couple_i)
legend_PR = get_legend(plot + theme(legend.position="top", legend_PR = get_legend(plot + theme(legend.position="top",
...@@ -927,10 +971,10 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL ...@@ -927,10 +971,10 @@ plot_out = function(df_out, df_d , df_auc, df_recall_sup09_per_meth, meths = NUL
rel_heights = c( 0.2, 0.7,0.05,0.7,0.05,0.7,0.05,0.7,0.05,0.7), 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) hjust = 0, vjust = 0)
plot_recall_precision_papier_ok = plot_grid(legend_PR, plot_recall_precision_papier_ok = plot_grid(legend_AUC,
plot1 + theme(legend.position="none"), plot1 + theme(legend.position="none"),
plot5 + theme(legend.position="none"), plot5 + theme(legend.position="none"),
plot6 + theme(legend.position="none"), plot52 + theme(legend.position="none"),
ncol = 1, scale = 1, ncol = 1, scale = 1,
labels = c("", labels = c("",
"A", "A",
......
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