-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ngerstner
committed
Apr 13, 2022
1 parent
8340144
commit 9ebf49a
Showing
34 changed files
with
1,563 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
################################################## | ||
## Project: DexStim Mouse Brain | ||
## Date: 21.11.2021 | ||
## Author: Nathalie | ||
################################################## | ||
# GO Enrichment plot for manuscript | ||
# Unique DE and hub genes in PFC | ||
|
||
# set working directory to source file location | ||
setwd("~/Documents/ownCloud/DexStim_RNAseq_Mouse/scripts/07_PlotsManuscript") | ||
|
||
library(readxl) | ||
library(dplyr) | ||
library(stringr) | ||
library(ggplot2) | ||
|
||
|
||
# 1. GO enrichment unique DE and hub genes in PFC | ||
|
||
data_hub <- read_xlsx(path = "~/Documents/ownCloud/DexStim_RNAseq_Mouse/manuscript/Figures/Figure II_PFC/FUMA_diff unique hubgenes_gene2func67664/PFC diff unique hubgenes_FUMA.xlsx", | ||
sheet = "GO bp") | ||
|
||
data_DE <- read_xlsx(path = "~/Documents/ownCloud/DexStim_RNAseq_Mouse/manuscript/Figures/Figure II_PFC/DE PFC/FUMA_gene2func66314/PFC unique DE genes _FUMA.xlsx", | ||
sheet = "GO bp") | ||
|
||
|
||
# data for left panel with top 14 terms for DE | ||
top_DE <- data_DE %>% | ||
dplyr::filter(N_overlap_A > 24) | ||
top_DE <- top_DE[order(top_DE$`my adj p BH`, decreasing = FALSE),][1:14,] | ||
|
||
top_DE_hub <- data_hub %>% | ||
filter(GeneSet %in% top_DE$GeneSet) | ||
|
||
top_DE_comb <- bind_rows("de" = top_DE, "hub" = top_DE_hub, .id = "group") | ||
|
||
|
||
# data for right panel with top 14 terms for hubs | ||
top_hub <- data_hub %>% | ||
dplyr::filter(N_overlap_A > 2) | ||
top_hub <- top_hub[order(top_hub$`my adj p BH`, decreasing = FALSE),][1:14,] | ||
|
||
top_hub_DE <- data_DE %>% | ||
filter(GeneSet %in% top_hub$GeneSet) | ||
|
||
missing_term <- setdiff(top_hub$GeneSet, top_hub_DE$GeneSet) | ||
add_entry <- data.frame("GeneSet" = missing_term) | ||
top_hub_DE <- bind_rows(top_hub_DE, add_entry) | ||
|
||
top_hub_comb <- bind_rows("hub" = top_hub, "de" = top_hub_DE, .id = "group") | ||
|
||
|
||
# combine everything into one df for plotting | ||
top_data <- bind_rows("de" = top_DE_comb, "hub" = top_hub_comb, .id = "panel") | ||
# remove the "GO_" from GO terms | ||
top_data$GeneSet <- str_replace_all(top_data$GeneSet, '^GO_', ' ') | ||
# remove the "_" from GO terms | ||
top_data$GeneSet <- str_replace_all(top_data$GeneSet, "_", " ") | ||
# only capitalize first letter per word | ||
top_data$GeneSet <- str_to_title(top_data$GeneSet) | ||
# of and to should start with lower case | ||
top_data$GeneSet <- str_replace_all(top_data$GeneSet, "Of", "of") | ||
top_data$GeneSet <- str_replace_all(top_data$GeneSet, "To", "to") | ||
|
||
# labeller function for facet titles | ||
facet_names <- c( | ||
'de'="Top 14 GO terms for DE genes", | ||
'hub'="Top 14 GO terms for hub genes" | ||
) | ||
|
||
# barplot | ||
g <- ggplot(top_data, aes(x = GeneSet, y = `[-log10 fdr`, fill = group)) + | ||
geom_bar(position = position_dodge2(reverse=TRUE), stat="identity") + | ||
|
||
scale_colour_manual(values = c("grey", "black"), guide = FALSE) + | ||
scale_fill_manual(name = "Geneset", | ||
values = c("orange", "darkred"), | ||
labels = c("DE genes", "hub genes")) + | ||
coord_flip() + | ||
scale_x_discrete(limits = rev) + | ||
xlab("GOterm") + | ||
ylab("-log10(FDR)") + | ||
ggtitle("GO terms enriched for unique DE and hub genes in PFC") + | ||
facet_wrap(~panel, scales="free", labeller = as_labeller(facet_names)) + | ||
theme_light() + | ||
theme(text = element_text(size= 14)) | ||
print(g) | ||
ggsave("01_FigureII_C.pdf", g, width = 14, height = 8) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
################################################## | ||
## Project: DexStim Mouse Brain | ||
## Date: 22.11.2021 | ||
## Author: Nathalie | ||
################################################## | ||
# Pathway enrichment plot for manuscript | ||
# Abcd1 and neighbourhood in diff network of PFC | ||
|
||
library(readxl) | ||
|
||
# 1. Pathway enrichment for Abcd1 and neighbours | ||
|
||
data <- read_xlsx(path = "~/Documents/ownCloud/DexStim_RNAseq_Mouse/manuscript/Figures/Figure II_PFC/Abcd1 gene neighbourhood_FUMA_gene2func67210/Abcd1_diffnetwork_FUMA.xlsx", | ||
sheet = "KEGG AND REACTOME") | ||
|
||
data <- arrange(data, desc(`[-log10FDR]`)) | ||
data <- data[1:20,] | ||
|
||
|
||
# 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 ") | ||
data$GeneSet <- str_replace_all(data$GeneSet, " Into ", " into ") | ||
# Ii from "Polymerase II" back to upper case | ||
data$GeneSet <- str_replace_all(data$GeneSet, "Reactome", "Reactome:") | ||
data$GeneSet <- str_replace_all(data$GeneSet, "Kegg", "KEGG:") | ||
# 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 = `[-log10FDR]`) ) + | ||
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(1.9,1,1)) | ||
|
||
ggexport(comb, filename = "02_FigureII_F.pdf", width = 14, height = 8) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
################################################## | ||
## 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) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
################################################## | ||
## Project: DexStim Mouse Brain | ||
## Date: 29.11.2021 | ||
## Author: Nathalie | ||
################################################## | ||
# GO enrichment plot for manuscript | ||
# vCA1 unique DE genes with neighbours enrichments | ||
|
||
|
||
library(readxl) | ||
library(dplyr) | ||
library(stringr) | ||
library(ggpubr) | ||
|
||
# 1. GO enrichment for vCA unique DE genes and their diff neighbours | ||
|
||
data <- read_xlsx(path = "~/Documents/ownCloud/DexStim_RNAseq_Mouse/manuscript/Figures/Figure III_vCA1/network vCA1/Unique DEs and their diff neighbours_FUMA_gene2func67313/vCA1 Unique DE genes+diff neighbours_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 ") | ||
data$GeneSet <- str_replace_all(data$GeneSet, " Into ", " into ") | ||
# 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(1.8,1,1)) | ||
|
||
ggexport(comb, filename = "03_FigureIII_C.pdf", width = 12, height = 8) |
Oops, something went wrong.