Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DiffBrainNet/04_PlotsManuscript/03_FigureIII_B.R
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
83 lines (71 sloc)
2.83 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################## | |
## Project: DexStim Mouse Brain | |
## Date: 29.11.2021 | |
## Author: Nathalie | |
################################################## | |
# GO enrichment plot for manuscript | |
# vCA1 unique DE genes enrichments | |
library(readxl) | |
library(dplyr) | |
library(stringr) | |
library(ggpubr) | |
# 1. GO enrichment for vCA unique DE genes | |
data <- read_xlsx(path = "~/Documents/ownCloud/DexStim_RNAseq_Mouse/manuscript/Figures/Figure III_vCA1/DE vCA1/FUMA_gene2func67310 (2)/vCA1 Unique DE genes_FUMA enrichments.xlsx", | |
sheet = "GO bp") | |
data <- arrange(data, desc(`[-log10 of FDR`)) | |
data <- data[1:20,] | |
# remove the "GO_" from GO terms | |
data$GeneSet <- str_replace_all(data$GeneSet, '^GO_', ' ') | |
# remove the "_" from GO terms | |
data$GeneSet <- str_replace_all(data$GeneSet, "_", " ") | |
# only capitalize first letter per word | |
data$GeneSet <- str_to_title(data$GeneSet) | |
# of and to should start with lower case | |
data$GeneSet <- str_replace_all(data$GeneSet, "Of", "of") | |
data$GeneSet <- str_replace_all(data$GeneSet, "To", "to") | |
data$GeneSet <- str_replace_all(data$GeneSet, " In ", " in ") | |
# GeneSet as factor | |
data$GeneSet <- factor(data$GeneSet, levels = data$GeneSet) | |
# bar plot gene ratio | |
gr <- ggplot(data, aes(x = GeneSet, y = `Genes ratio`) ) + | |
geom_bar(position = position_dodge2(reverse=TRUE), stat="identity", fill = "#0F5057") + | |
scale_fill_manual() + | |
theme_light() + | |
coord_flip() + | |
scale_x_discrete(limits = rev) + | |
theme(text = element_text(size= 14)) + | |
ylab("% Gene Ratio") + | |
labs(x = NULL) | |
# bar plot odds ratio | |
or <- ggplot(data, aes(x = GeneSet, y = `OR[log2(a*d)-log2(b*c)]`) ) + | |
geom_bar(position = position_dodge2(reverse=TRUE), stat="identity", fill = "#FAA916") + | |
scale_fill_manual() + | |
theme_light() + | |
coord_flip() + | |
scale_x_discrete(limits = rev) + | |
theme(text = element_text(size= 14)) + | |
ylab("Odds Ratio") + | |
labs(x = NULL) | |
# barplot fdr p-value | |
fdr <- ggplot(data, aes(x = GeneSet, y = `[-log10 of FDR`) ) + | |
geom_bar(position = position_dodge2(reverse=TRUE), stat="identity", fill = "#D45E60") + | |
geom_hline(yintercept = -log10(0.05),linetype="dashed", color = "red") + | |
theme_light() + | |
coord_flip() + | |
scale_x_discrete(limits = rev) + | |
theme(text = element_text(size= 14)) + | |
ylab("-log10(FDR)") + | |
labs(x = NULL) | |
# combined barplot | |
comb <- ggarrange(gr, | |
or + | |
theme(axis.text.y = element_blank(), | |
axis.ticks.y = element_blank(), | |
axis.title.y = element_blank() ), | |
fdr + | |
theme(axis.text.y = element_blank(), | |
axis.ticks.y = element_blank(), | |
axis.title.y = element_blank() ), | |
nrow = 1, | |
widths = c(2.5,1,1)) | |
ggexport(comb, filename = "03_FigureIII_B.pdf", width = 14, height = 8) |