Commit 7b31ec08 authored by hjulienne's avatar hjulienne

improve causality figure

parent 32d19200
Pipeline #10150 passed with stages
in 1 minute and 11 seconds
library("ggplot2")
library("cowplot")
library(data.table)
setwd("~/Project/raiss/Simulation/")
plot_list = list()
for( tag in c("one_positive", "two_positive", "two_opposite"))
{
causal = read.csv(paste0("./results/Beta_",tag,".csv"), header=FALSE)
Zscore = read.csv(paste0("./results/Zscore_",tag,".csv"), header=FALSE)
performance = read.csv(paste0("./results/amplitude_effect_", tag, ".csv"), header=FALSE)
names(performance) = c("amplitude", "correlation")
names(causal) =c("SNPid", "Beta")
causal["Zscore"] = Zscore[,2] * 25
c_long = melt(causal, id.var= "SNPid")
p1 = ggplot(c_long, aes(x=SNPid, y=value, color=variable)) + geom_point() + geom_line(size=1)
p1 = p1 +scale_colour_manual(values=c("orangered", 'royalblue1'))
legend_sig = get_legend(p1)
plot_list[[paste0(tag,"_signal")]] = p1 + ylab("") + theme(legend.position='none')
p2 =ggplot(performance, aes(x=amplitude, y=correlation)) + geom_point() + geom_line(color="royalblue1",size=1)
p= p2 + ylab("")
plot_list[[paste0(tag,"_perf")]] = p2 + ylim(0,1)
tag = "one_positive"
}
causal = read.csv("./results/Beta_one_positive.csv", header=FALSE)
Zscore = read.csv("./results/Zscore_one_positive.csv", header=FALSE)
upper_panel = plot_grid(plot_list[[1]],plot_list[[3]],
plot_list[[5]],align="h", nrow=1)
names(causal) =c("SNPid", "Beta")
legend_sig
upper_panel_with_leg = plot_grid(upper_panel, legend_sig, rel_widths=c(0.9, 0.1))
lower_panel = plot_grid(plot_list[[2]],
plot_list[[4]],plot_list[[6]],align="v")
upper_panel_with_leg
causal["Zscore"] = Zscore[,2]
c_long = melt(causal, id.var= "SNPid")
head(c_long)
p1 = ggplot(c_long, aes(x=SNPid, y=value, color=variable)) + geom_point() + geom_line(size=1)
P1 = p1 +scale_colour_manual(values=c("orangered", 'royalblue1'))
plot_grid(plot_grid(plot_list[[1]],plot_list[[3]],
plot_list[[5]],plot_list[[2]],
plot_list[[4]],plot_list[[6]],align="v"), legend_sig, rel_widths=c(0.9,0.1))
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