-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_gender_differences_dragana_analysis.R
46 lines (40 loc) · 1.75 KB
/
plot_gender_differences_dragana_analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require("ggrepel")
df1 = readxl::read_xlsx("/Volumes/GoogleDrive/My Drive/Phd/VarioPath/statistical analysis/Single_var_het_carriers_results_FBC_sex_sep.xlsx", sheet = 1)
df1$ID = paste(df1$CHROM, df1$POS, df1$REF, df1$ALT,
sep = "_")
set.seed(1)
for (var in grep( glob2rx("*_effect_F"), colnames(df1), value = T ) ) {
var2 = str_replace(var, pattern = "F", replacement = "M")
p1 = ggplot(df1[which(
as.numeric(unlist(df1[,grep(var,colnames(df1)) + 2])) <= 0.05 &
as.numeric(unlist(df1[,grep(var2,colnames(df1)) + 2])) <= 0.05),],
aes(
x= as.numeric(
unlist(df1[which(
as.numeric(unlist(df1[,grep(var,colnames(df1)) + 2])) <= 0.05 &
as.numeric(unlist(df1[,grep(var2,colnames(df1)) + 2])) <= 0.05),
var])
),
y = as.numeric(
unlist(df1[which(
as.numeric(unlist(df1[,grep(var,colnames(df1)) + 2])) <= 0.05 &
as.numeric(unlist(df1[,grep(var2,colnames(df1)) + 2])) <= 0.05),
var2])
)
) ) +
geom_point() +
geom_text_repel( data = df1[which(
as.numeric(unlist(df1[,grep(var,colnames(df1)) + 2])) <= 0.05 &
as.numeric(unlist(df1[,grep(var2,colnames(df1)) + 2])) <= 0.05),],
aes(label = GENE),
size = 3.5 ) +
geom_vline( xintercept = 0) +
geom_hline(yintercept = 0) +
geom_abline(slope = 1, intercept = 0) +
theme_minimal()
ggsave(paste( "/Volumes/GoogleDrive/My Drive/Phd/VarioPath/statistical analysis/gender_plot_dragana_analysisi_20210606/",
var, "_forest_plot.png"
),
plot = p1, device = "png", units = "cm", limitsize = FALSE, dpi = "retina", width = 10, height = 10
)
}