From 28ad0ecf88c371783d4614f94e36f1d445a2ac03 Mon Sep 17 00:00:00 2001 From: hanna julienne <hanna.julienne@pasteur.fr> Date: Mon, 29 Apr 2019 15:57:26 +0200 Subject: [PATCH] corrected labels --- Simulation/causality_figure.R | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Simulation/causality_figure.R b/Simulation/causality_figure.R index 76a09cc..e4f2e5d 100644 --- a/Simulation/causality_figure.R +++ b/Simulation/causality_figure.R @@ -16,23 +16,24 @@ for( tag in c("one_causal", "two_causal", "two_opposite")) performance = read.csv(paste0("./results/amplitude_effect_", tag, ".csv"), header=TRUE) names(performance) = c("id", "amplitude", "correlation", "MAE", "correlation_large", "MAE_large") performance = data.table(performance) + head(performance) perf = performance[, .(mean(correlation), sd(correlation), mean(MAE), sd(MAE), mean(correlation_large), sd(correlation_large), mean(MAE_large), sd(MAE_large), count=.N), by=amplitude] - names(perf) = c("amplitude", "correlation", "sd_cor","MAE", "sd_mae", "correlation_large", "sd_correlation_large", "MAE_large", "sd_MAE_large","count") names(causal) =c("SNPid", "Beta") causal["Zscore"] = Zscore[,2] c_long = melt(causal, id.var= "SNPid") - p1 = ggplot(c_long[rev(order(c_long[,2])),], aes(x=SNPid, y=value, color=variable)) + geom_line(size=0.6) +geom_point(size=0.5) - p1 = p1 + scale_colour_manual(values=c("orangered", 'royalblue1'))+ theme(legend.position='top',legend.justification="center") + p1 = ggplot(c_long[rev(order(c_long[,2])),], aes(x=SNPid, y=value, color=variable)) + geom_line(size=0.6) + geom_point(size=0.5) + p1 = p1 + scale_colour_manual(values=c("orangered", 'royalblue1')) + theme(legend.position='top', legend.justification="center") + legend_sig = get_legend(p1) - pzscore = ggplot(causal, aes(x=SNPid, y=Zscore)) + geom_line(size=0.6, color="royalblue1") +geom_point(size=0.5, color="royalblue1") - pcause = ggplot(causal, aes(x=SNPid, y=Beta)) + geom_line(size=0.6, color="orangered") +geom_point(size=0.5, color="orangered") + pzscore = ggplot(causal, aes(x=SNPid, y=Zscore)) + geom_line(size=0.6, color="royalblue1") + geom_point(size=0.5, color="royalblue1") + pcause = ggplot(causal, aes(x=SNPid, y=Beta)) + geom_line(size=0.6, color="orangered") + geom_point(size=0.5, color="orangered") legend_sig = get_legend(p1) @@ -53,8 +54,9 @@ for( tag in c("one_causal", "two_causal", "two_opposite")) p2 =ggplot(perf, aes(x=amplitude, y=correlation)) + geom_point(data=performance, aes(x=amplitude, y=correlation), size=0.1, alpha=0.2) + geom_line(color="royalblue1",size=1) + geom_errorbar(aes(ymin=correlation-sd_cor/(count^0.5), ymax=correlation+sd_cor/(count^0.5)),color="royalblue1", position=position_dodge(0.05)) - p2 = p2 + ylab("") + p2 = p2 + ylab("") + xlab("SNP effect size at spike") p2 + if(tag != "one_causal") { plot_list[[paste0(tag,"_perf")]] = p2 + ylim(0,1) + ylab("") @@ -80,7 +82,7 @@ for( tag in c("one_causal", "two_causal", "two_opposite")) } upper_panel = plot_grid(plot_list[[1]],plot_list[[4]],plot_list[[7]], - plot_list[[2]],plot_list[[5]],plot_list[[8]], + plot_list[[2]],plot_list[[5]],plot_list[[8]], labels=c("A", "","", "B","",""),label_size=18, align="h", nrow=2) upper_panel_with_leg = plot_grid(legend_sig, upper_panel, rel_heights=c(0.06, 0.94), nrow=2) @@ -91,14 +93,13 @@ lower_panel = plot_grid(plot_list[[3]], tiff(filename = "Supp_fig_causal2.tiff", width = 900, height = 900, units = "px", pointsize = 12) - plot_grid(upper_panel_with_leg, lower_panel, rel_heights=c(0.65,0.35), labels=c("A", "B"), label_size=18, nrow=2) + plot_grid(upper_panel_with_leg, lower_panel, rel_heights=c(0.65,0.35), labels=c("", "C"), label_size=18, nrow=2) dev.off() panel_MAE = plot_list_for_reviewer[[tag]] - panel_neuneu = plot_grid(plot_list_for_reviewer[[1]] + ylab("MAE"),plot_list_for_reviewer[[4]],plot_list_for_reviewer[[7]], plot_list_for_reviewer[[2]] + ylab("Correlation_on_large"),plot_list_for_reviewer[[5]],plot_list_for_reviewer[[8]], - plot_list_for_reviewer[[3]]+ ylab("MAE_on_large"),plot_list_for_reviewer[[6]],plot_list_for_reviewer[[9]], + plot_list_for_reviewer[[3]] + ylab("MAE_on_large"),plot_list_for_reviewer[[6]],plot_list_for_reviewer[[9]], align="h", nrow=3) tiff(filename = "for_reviewer_info.tiff", -- GitLab