-
Notifications
You must be signed in to change notification settings - Fork 0
/
gene_set_analysis_heatmap.R
executable file
·39 lines (31 loc) · 1.31 KB
/
gene_set_analysis_heatmap.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
#!/usr/bin/env Rscript
library(dplyr)
library(ggplot2)
library(stringr)
setwd("/Users/vapp0002/Desktop/Magma/")
enrichment = read.table("PsychEncodeModulesEnrichments.txt", header = T)
enrichment = enrichment %>% mutate(TYPE = str_count(GWAS, "_"))
enrichment$TYPE = gsub("2", "Case vs Case Pairwise", enrichment$TYPE)
enrichment$TYPE = gsub("1", "Case vs Other Cases", enrichment$TYPE)
enrichment$TYPE = gsub("0", "Case vs Cohort", enrichment$TYPE)
enrichment$GWAS = gsub("_CC", "", enrichment$GWAS)
enrichment$GWAS = gsub("_", " vs ", enrichment$GWAS)
enrichment$VARIABLE = gsub("^ME", "", enrichment$VARIABLE)
enrichment$VARIABLE = as.numeric(enrichment$VARIABLE)
png("PsychEncodeModules_Enrichments.png",
res = 300,
width = 12,
height = 8,
units = "in")
ggplot(enrichment, aes(x = VARIABLE, y = GWAS, fill = BETA, size = -log10(P))) +
geom_point(shape = 21) +
theme_classic() +
scale_fill_gradient2(low = "blue", mid = "white", high = "red") +
theme(axis.text.x = element_text(angle = 45, hjust = 1, face = "bold"),
axis.text.y = element_text(face = "bold"),
legend.position = "bottom") +
xlab("") +
ylab("") +
facet_grid(TYPE ~ ., scales = "free", space = "free") +
scale_x_continuous(breaks = seq(1, 73, 1))
dev.off()