Robbin Nameki, Anamay Shetty et al. August 2021
The following script describes the process of conducting gene-set pathway enrichment analysis using the R package ClusterProfiler. This analysis takes a gene-set (in this case pathway gene-sets from the GO data base) and asks whether the gene-set is enriched in a ranked list (in this case chromMAGMA genes ranked by RNA expression weighted P-values). The gseGO() functions takes a bit to run.
This document can also be adapted to analyze conventional MAGMA gene-lists
library(tidyverse)
library(clusterProfiler)
library(enrichplot)
library(ggplot2)
library(DESeq2)
library(reshape2)
library(biomaRt)
library(UpSetR)
library(ggpubr)
source('Rscripts/Utils.R' )
## Warning: package 'valr' was built under R version 4.0.5
##
## Attaching package: 'valr'
## The following object is masked from 'package:SummarizedExperiment':
##
## values
## The following object is masked from 'package:GenomicRanges':
##
## values
## The following object is masked from 'package:IRanges':
##
## values
## The following object is masked from 'package:S4Vectors':
##
## values
The identifiers in the weighted gene-lists are converted to entrezGeneIDs to match the identifiers in the GO database. HLA genes are removed to reduce bias to these highly active regions.
#Getting EntrezGeneIDs
ensembl <- useEnsembl_GRCh37()
bm <- getBM(attributes=c('ensembl_gene_id', 'external_gene_name', 'entrezgene_id'),
filters = 'chromosome_name',
values = c(1:22,'X'),
mart = ensembl)
bm.unique_external_gene_name <- bm[!duplicated(bm[,'external_gene_name']),]
#Assigning EntrezGeneIDs to analysis
Gene_Level_Weighted_chromMAGMA <- read_gene_level_weighted()
gene_level.ensembl <- merge(Gene_Level_Weighted_chromMAGMA, bm.unique_external_gene_name,by = 'external_gene_name')
gene_level.ensembl.entrez <- gene_level.ensembl[!gene_level.ensembl$entrezgene_id =='',]
#Taking out HLA genes from dataframe
HLA_genes <- read_HLA_genes()
gene_level.ensembl.entrez.noHLA <- gene_level.ensembl.entrez[!(gene_level.ensembl.entrez$external_gene_name %in% HLA_genes$hgnc_symbol),]
histotype = c('HGSOC','LGSOC','CCOC','NMOC','MOC','EnOC')
for(i in histotype) {
#chromMAGMA
assign(paste0('chromMAGMA_',i),
gene_level.ensembl.entrez.noHLA %>%
filter(FEATURE == 'chromMAGMA') %>%
filter(GWAS_TYPE == paste(i))%>%
dplyr::select(entrezgene_id,weighted_P,external_gene_name) %>%
arrange(desc(weighted_P))
)
}
#chromMAGMA_List
chromMAGMA.geneList.CCOC <- chromMAGMA_CCOC[,2]
names(chromMAGMA.geneList.CCOC) = as.character(chromMAGMA_CCOC[,1])
chromMAGMA.geneList.CCOC = sort(chromMAGMA.geneList.CCOC, decreasing = TRUE)
chromMAGMA.geneList.EnOC <- chromMAGMA_EnOC[,2]
names(chromMAGMA.geneList.EnOC) = as.character(chromMAGMA_EnOC[,1])
chromMAGMA.geneList.EnOC = sort(chromMAGMA.geneList.EnOC, decreasing = TRUE)
chromMAGMA.geneList.HGSOC <- chromMAGMA_HGSOC[,2]
names(chromMAGMA.geneList.HGSOC) = as.character(chromMAGMA_HGSOC[,1])
chromMAGMA.geneList.HGSOC = sort(chromMAGMA.geneList.HGSOC, decreasing = TRUE)
chromMAGMA.geneList.LGSOC <- chromMAGMA_LGSOC[,2]
names(chromMAGMA.geneList.LGSOC) = as.character(chromMAGMA_LGSOC[,1])
chromMAGMA.geneList.LGSOC = sort(chromMAGMA.geneList.LGSOC, decreasing = TRUE)
chromMAGMA.geneList.MOC <- chromMAGMA_MOC[,2]
names(chromMAGMA.geneList.MOC) = as.character(chromMAGMA_MOC[,1])
chromMAGMA.geneList.MOC = sort(chromMAGMA.geneList.MOC, decreasing = TRUE)
chromMAGMA.geneList.NMOC <- chromMAGMA_NMOC[,2]
names(chromMAGMA.geneList.NMOC) = as.character(chromMAGMA_NMOC[,1])
chromMAGMA.geneList.NMOC = sort(chromMAGMA.geneList.NMOC, decreasing = TRUE)
organism = 'org.Hs.eg.db'
#BiocManager::install(organism, character.only = TRUE)
library(organism, character.only = TRUE)
## Loading required package: AnnotationDbi
##
## Attaching package: 'AnnotationDbi'
## The following object is masked from 'package:clusterProfiler':
##
## select
## The following object is masked from 'package:dplyr':
##
## select
##
organism.2 = org.Hs.eg.db
chromMAGMA.CCOC.gse <- gseGO(geneList= chromMAGMA.geneList.CCOC,
ont ="ALL",
keyType = "ENTREZID",
nPerm = 10000,
minGSSize = 3,
maxGSSize = 800,
pvalueCutoff = 0.05,
verbose = TRUE,
OrgDb = organism.2,
pAdjustMethod = "BH")
## preparing geneSet collections...
## GSEA analysis...
## leading edge analysis...
## done...
chromMAGMA.EnOC.gse <- gseGO(geneList= chromMAGMA.geneList.EnOC,
ont ="ALL",
keyType = "ENTREZID",
nPerm = 10000,
minGSSize = 3,
maxGSSize = 800,
pvalueCutoff = 0.05,
verbose = TRUE,
OrgDb = organism.2,
pAdjustMethod = "BH")
## preparing geneSet collections...
## GSEA analysis...
## leading edge analysis...
## done...
chromMAGMA.HGSOC.gse <- gseGO(geneList= chromMAGMA.geneList.HGSOC,
ont ="ALL",
keyType = "ENTREZID",
nPerm = 10000,
minGSSize = 3,
maxGSSize = 800,
pvalueCutoff = 0.05,
verbose = TRUE,
OrgDb = organism.2,
pAdjustMethod = "BH")
## preparing geneSet collections...
## GSEA analysis...
## leading edge analysis...
## done...
chromMAGMA.LGSOC.gse <- gseGO(geneList= chromMAGMA.geneList.LGSOC,
ont ="ALL",
keyType = "ENTREZID",
nPerm = 10000,
minGSSize = 3,
maxGSSize = 800,
pvalueCutoff = 0.05,
verbose = TRUE,
OrgDb = organism.2,
pAdjustMethod = "BH")
## preparing geneSet collections...
## GSEA analysis...
## leading edge analysis...
## done...
chromMAGMA.MOC.gse <- gseGO(geneList= chromMAGMA.geneList.MOC,
ont ="ALL",
keyType = "ENTREZID",
nPerm = 10000,
minGSSize = 3,
maxGSSize = 800,
pvalueCutoff = 0.05,
verbose = TRUE,
OrgDb = organism.2,
pAdjustMethod = "BH")
## preparing geneSet collections...
## GSEA analysis...
## leading edge analysis...
## done...
chromMAGMA.NMOC.gse <- gseGO(geneList= chromMAGMA.geneList.NMOC,
ont ="ALL",
keyType = "ENTREZID",
nPerm = 10000,
minGSSize = 3,
maxGSSize = 800,
pvalueCutoff = 0.05,
verbose = TRUE,
OrgDb = organism.2,
pAdjustMethod = "BH")
## preparing geneSet collections...
## GSEA analysis...
## leading edge analysis...
## done...
##output saved to one file.
##rbinding these dataframes makes ST4
#saveRDS(chromMAGMA.CCOC.gse, 'Data/GSEgo')
#saveRDS(chromMAGMA.EnOC.gse, 'Data/GSEgo')
#saveRDS(chromMAGMA.HGSOC.gse, 'Data/GSEgo')
#saveRDS(chromMAGMA.LGSOC.gse, 'Data/GSEgo')
#saveRDS(chromMAGMA.MOC.gse, 'Data/GSEgo')
#saveRDS(chromMAGMA.NMOC.gse, 'Data/GSEgo')
file_location <- "Data/GSEgo"
format_output_df <- function(file_location) {
as_tibble(read_rds(file_location)@result) %>%
separate_rows(core_enrichment, sep = "/") %>%
dplyr::select("ENTREZEGENE_ID" = core_enrichment, Description, ID, setSize, NES, p.adjust, ONTOLOGY)
}
tibble(histotype = str_remove(list.files(file_location), ".gse.RDS"),
file_location = list.files(file_location, full.names = TRUE)) %>%
group_by(histotype) %>%
dplyr::mutate(results = map(file_location, format_output_df)) %>%
dplyr::select(-file_location) %>%
unnest(results) %>%
write_tsv("Data/cleaned_pathway_gsea_output.5.25.21.txt")
#getting list for upset
chromMAGMA.CCOC.gse.df <- as.data.frame(chromMAGMA.CCOC.gse@result) %>%
filter(setSize >= 25)
chromMAGMA.CCOC.gse.df$GWAS_TYPE <- 'CCOC'
chromMAGMA.EnOC.gse.df <- as.data.frame(chromMAGMA.EnOC.gse@result)%>%
filter(setSize >= 25)
chromMAGMA.EnOC.gse.df$GWAS_TYPE <- 'EnOC'
chromMAGMA.HGSOC.gse.df <- as.data.frame(chromMAGMA.HGSOC.gse@result)%>%
filter(setSize >= 25)
chromMAGMA.HGSOC.gse.df$GWAS_TYPE <- 'HGSOC'
chromMAGMA.LGSOC.gse.df <- as.data.frame(chromMAGMA.LGSOC.gse@result)%>%
filter(setSize >= 25)
chromMAGMA.LGSOC.gse.df$GWAS_TYPE <- 'LGSOC'
chromMAGMA.MOC.gse.df <- as.data.frame(chromMAGMA.MOC.gse@result)%>%
filter(setSize >= 25)
chromMAGMA.MOC.gse.df$GWAS_TYPE <- 'MOC'
chromMAGMA.NMOC.gse.df <- as.data.frame(chromMAGMA.NMOC.gse@result)%>%
filter(setSize >= 25)
chromMAGMA.NMOC.gse.df$GWAS_TYPE <- 'NMOC'
#ST4
ST4 <- rbind(chromMAGMA.CCOC.gse.df,
chromMAGMA.EnOC.gse.df,
chromMAGMA.HGSOC.gse.df,
chromMAGMA.LGSOC.gse.df,
chromMAGMA.MOC.gse.df,
chromMAGMA.NMOC.gse.df)
head(ST4)
## ONTOLOGY ID
## GO:0000075 BP GO:0000075
## GO:0000082 BP GO:0000082
## GO:0000086 BP GO:0000086
## GO:0000118 CC GO:0000118
## GO:0000122 BP GO:0000122
## GO:0000123 CC GO:0000123
## Description setSize
## GO:0000075 cell cycle checkpoint 206
## GO:0000082 G1/S transition of mitotic cell cycle 233
## GO:0000086 G2/M transition of mitotic cell cycle 233
## GO:0000118 histone deacetylase complex 67
## GO:0000122 negative regulation of transcription by RNA polymerase II 787
## GO:0000123 histone acetyltransferase complex 79
## enrichmentScore NES pvalue p.adjust qvalues rank
## GO:0000075 0.4056375 1.408791 9.999e-05 0.004833249 0.004279958 6147
## GO:0000082 0.3927576 1.371395 9.999e-05 0.004833249 0.004279958 6378
## GO:0000086 0.4315876 1.506978 9.999e-05 0.004833249 0.004279958 5631
## GO:0000118 0.5755047 1.857590 9.999e-05 0.004833249 0.004279958 4907
## GO:0000122 0.3516234 1.272903 9.999e-05 0.004833249 0.004279958 5128
## GO:0000123 0.4849788 1.587304 9.999e-05 0.004833249 0.004279958 5458
## leading_edge
## GO:0000075 tags=55%, list=36%, signal=36%
## GO:0000082 tags=54%, list=38%, signal=34%
## GO:0000086 tags=52%, list=33%, signal=35%
## GO:0000118 tags=69%, list=29%, signal=49%
## GO:0000122 tags=40%, list=30%, signal=29%
## GO:0000123 tags=58%, list=32%, signal=40%
## core_enrichment
## GO:0000075 9125/4194/57551/6154/598/9344/5514/65123/4849/1647/55755/7465/9656/55571/1739/5934/5883/1017/1432/27183/80198/4998/1027/7508/23019/3550/9337/29980/6790/79858/5546/51720/1111/406991/84861/79968/4361/6659/1112/84126/60561/988/80279/146956/11200/7157/440275/2033/197342/51451/25949/1026/55743/5371/891/699/9984/84101/7756/6419/7158/57805/5781/81620/5111/56984/5925/581/701/26058/1843/55055/545/7832/6152/51065/8091/85456/5325/84126/10498/10769/25988/9575/5591/9183/3364/1030/144455/51343/9587/4193/9735/5810/84444/11073/5884/3276/54962/6118/51322/8883/7517/4850/995/55159/57060/91603/1874/6194/3265/7483/8379/348654
## GO:0000082 9125/26057/57695/4194/6154/23476/4174/4849/1647/55904/1654/4176/7465/55571/3400/5934/1021/1017/6198/51379/4678/1104/4998/1027/9113/91/5720/23019/9337/6790/8454/301/993/10657/406991/8558/8554/3398/6659/5557/10106/11200/7157/3688/23595/2033/199/1019/1018/6502/23649/4171/1026/54617/10197/7298/5962/5371/891/8462/26271/4172/6117/5001/56257/5777/9134/10263/81620/5111/207/4173/1981/5925/581/11319/26058/10385/84515/328/5932/1031/7832/54107/51065/6881/9314/85456/5325/10498/10769/25988/5426/5591/1030/144455/4193/4609/3276/596/4331/1032/6118/23133/6868/894/4850/29117/995/55159/57060/1956/1874/3373/79960/6194/11040/4149/2146/26524/1029/4848/123879/84967/997
## GO:0000086 9814/25942/10142/57551/5706/9344/7277/23476/22974/8481/55755/5691/1454/5715/7465/1017/6604/4957/54850/27183/1453/5707/4998/1778/9113/5700/1639/5720/3320/1785/5890/9702/8493/29980/55142/6790/8454/10776/79866/5692/994/993/10657/9525/406991/79441/4361/5710/1112/60561/5500/80279/808/7531/11200/8766/1019/5566/9793/6502/51451/5518/25949/5689/1026/5704/10197/5108/6500/23354/891/84930/26271/57504/6873/93323/5688/115106/10806/84131/351/55125/4751/808/4660/22994/7283/5719/1069/55920/7846/2029/10133/5699/5685/22981/5708/54820/9833/8091/3364/4204/55031/1030/5087/5718/79831/5693/5885/5717/11073/5884/10763/4331/9024/219771/10733/80321/60672/8883/79959/995
## GO:0000118 1457/55869/55929/9759/23468/25942/10847/1108/57649/54815/9612/25855/10524/7764/8295/91748/23493/5928/2122/57634/64426/10902/9611/1107/23309/3065/473/57504/51564/83933/10933/8204/3066/79718/8607/9219/10856/9112/5931/6886/53615/10284/79595/8841/9734/51341
## GO:0000122 6928/55869/6310/55929/9759/4194/23468/25942/4088/6597/23405/2186/688/1786/10915/1906/84159/10507/1499/57649/3280/26155/84504/54815/11142/57659/6239/11278/7068/7316/8239/7422/6668/84619/4601/3068/5469/7421/200014/23269/166/5970/10628/3400/7767/165/6778/1739/4690/80014/1021/7703/1017/64324/5460/4205/3428/4799/9612/7022/1387/5467/6421/25855/10524/2263/1051/463/56998/7764/5245/1788/51385/811/10370/10664/94104/2120/165918/84934/55553/23019/652/6208/79759/8545/54880/3005/10401/3192/3725/2354/22980/7707/5663/2099/2908/2274/10443/22882/23493/639/23028/8289/51523/23327/221937/5987/8554/3398/5971/25937/7227/1958/2023/122953/146198/51497/6774/26137/55662/100529215/55122/342371/57621/7157/155061/2063/3727/79813/3607/10499/8440/201163/467/2033/9975/64426/4781/7528/23186/7009/55689/121536/9611/64412/22890/23309/6720/6945/2302/3065/9960/65251/5465/1877/4783/7329/7555/79365/10155/6256/9925/6829/51547/1871/8462/9730/57507/7727/169792/153090/6929/857/2308/2005/4089/26145/23013/7430/3059/57504/54623/4854/10795/11171/9646/8609/51564/167465/83933/84759/51058/56257/57594/5771/55192/51741/7323/8204/7311/6615/4208/3146/9139/23286/4775/5916/3066/5111/79718/7755/7699/2874/51274/5925/4084/2114/60468/4212/23051/57680/80317/57466/6672/6872/54862/11218/9219/4774/10468/7704/25836/7071/8553/9400/10174/7832/22938/2100/10589/1942/5813/7593/7695/3096/4261/6662/163050/6657/5155/4152/27063/5966/2309/3726/9112/3297/5931/7020/51592/4929/25850/23512/23492/8726/283571/6497/8091/9314/145258/60436/3661/5494/3090/25988/9096/55729/6886/64207/84324/3181/64750/79648/53615/6932/57491/4773/6911/2260/28996/79595/8841/10919/9734/4204/55646/51341/144455/162979/4591/5981/64321/80314/25920/93649/4790/7067/6498/4193/2874/57600/4609/23429/1487
## GO:0000123 55929/2648/51773/55167/9898/1387/27154/10524/84289/6878/8295/6885/339287/8464/84148/23338/11143/112869/57634/55683/2033/10902/60/64769/55689/7994/23774/23522/6873/10933/9913/11091/8193/8607/10856/27097/6874/54107/26009/6881/55257/80314/10445/3054/55274/54934
## GWAS_TYPE
## GO:0000075 CCOC
## GO:0000082 CCOC
## GO:0000086 CCOC
## GO:0000118 CCOC
## GO:0000122 CCOC
## GO:0000123 CCOC
pathway.list <- list(
CCOC = chromMAGMA.CCOC.gse.df$Description,
EnOC = chromMAGMA.EnOC.gse.df$Description,
HGSOC = chromMAGMA.HGSOC.gse.df$Description,
LGSOC = chromMAGMA.LGSOC.gse.df$Description,
MOC = chromMAGMA.MOC.gse.df$Description
)
#upset plot
library(UpSetR)
upset(fromList(pathway.list),
nsets = length(pathway.list),
#$empty.intersections = 'on',
order.by ='freq')
#extracting binary results within upset plot
fromList <- function (input) {
# Same as original fromList()...
elements <- unique(unlist(input))
data <- unlist(lapply(input, function(x) {
x <- as.vector(match(elements, x))
}))
data[is.na(data)] <- as.integer(0)
data[data != 0] <- as.integer(1)
data <- data.frame(matrix(data, ncol = length(input), byrow = F))
data <- data[which(rowSums(data) != 0), ]
names(data) <- names(input)
# ... Except now it conserves your original value names!
row.names(data) <- elements
return(data)
}
annotated_pathway <- fromList(pathway.list)
annotated_pathway$Description <- rownames(annotated_pathway)
annotated_pathway$binary <- paste(annotated_pathway$CCOC,
annotated_pathway$EnOC,
annotated_pathway$HGSOC,
annotated_pathway$LGSOC,
annotated_pathway$MOC)
annotated_pathway$anno <- ifelse(annotated_pathway$binary %in% "1 0 0 0 0",'CCOC Specific',
ifelse(annotated_pathway$binary %in% "0 1 0 0 0",'EnOC Specific',
ifelse(annotated_pathway$binary %in% "0 0 1 0 0",'HGSOC Specific',
ifelse(annotated_pathway$binary %in% "0 0 0 1 0",'LGSOC Specific',
ifelse(annotated_pathway$binary %in% "0 0 0 0 1",'MOC Specific',
ifelse(annotated_pathway$binary %in% "1 1 1 1 1",'All Common','NA'))))))
annotated_pathway <- annotated_pathway %>% filter(!anno == 'NA')
annotated_pathway<- annotated_pathway[order(annotated_pathway$anno),]
#dotplot
transcription <- annotated_pathway %>%
filter(anno == 'All Common') %>%
filter(str_detect(Description,"transcription"))
splicing <- annotated_pathway %>%
filter(anno == 'All Common') %>%
filter(str_detect(Description,"splic"))
chromatin <- annotated_pathway %>%
filter(anno == 'All Common') %>%
filter(str_detect(Description,"chromatin"))
dotpot_Des <- rbind(transcription,splicing,chromatin)
all_pathway <- rbind(as.data.frame(chromMAGMA.CCOC.gse@result) %>% mutate(histotype = 'CCOC'),
as.data.frame(chromMAGMA.EnOC.gse@result) %>% mutate(histotype = 'EnOC'),
as.data.frame(chromMAGMA.HGSOC.gse@result) %>% mutate(histotype = 'HGSOC'),
as.data.frame(chromMAGMA.LGSOC.gse@result) %>% mutate(histotype = 'LGSOC'),
as.data.frame(chromMAGMA.MOC.gse@result) %>% mutate(histotype = 'MOC')
) %>%
dplyr::select(histotype,Description, p.adjust,NES) %>%
mutate(NEG_LOG10P = -log10(p.adjust)) %>%
filter(Description %in% dotpot_Des$Description) %>%
group_by(histotype) %>%
dplyr::select(histotype,Description,NEG_LOG10P, NES)
ggplot(all_pathway,aes(factor(histotype),Description)) +
geom_point(aes(colour=NEG_LOG10P,size=NES)) +
scale_colour_gradient(low="blue", high="red") +
theme_bw() +
theme(axis.text=element_text(size=7),
axis.title=element_text(size=7,face="bold")) +
theme(axis.text.x = element_text(size = 12, angle = 90)) +
scale_size_continuous(range = c(0,6))
CCOC_enriched <- annotated_pathway %>%
filter(anno == 'CCOC Specific')
chromMAGMA.CCOC.enriched <- chromMAGMA.CCOC.gse.df %>%
filter(Description %in% CCOC_enriched$Description) %>%
mutate(NEG_LOG10_P = -log10(p.adjust)) %>%
top_n(10, NES)
chromMAGMA.CCOC.enriched$Description <- str_trunc(chromMAGMA.CCOC.enriched$Description, 50)
chromMAGMA.CCOC.enriched$Description <- factor(chromMAGMA.CCOC.enriched$Description, levels=chromMAGMA.CCOC.enriched[order(chromMAGMA.CCOC.enriched$NEG_LOG10_P,decreasing=T),]$Description)
CCOC.plot <- ggplot(chromMAGMA.CCOC.enriched,aes(x = NEG_LOG10_P,
y = Description)) +
geom_col(fill = 'red') +
coord_flip()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
theme(axis.title.x=element_blank(),
axis.title.y=element_blank()) +
xlim(0,2.5)
#EnOC
EnOC_enriched <- annotated_pathway %>%
filter(anno == 'EnOC Specific')
chromMAGMA.EnOC.enriched <- chromMAGMA.EnOC.gse.df %>%
filter(Description %in% EnOC_enriched$Description) %>%
mutate(NEG_LOG10_P = -log10(p.adjust)) %>%
top_n(10, NES)
chromMAGMA.EnOC.enriched$Description <- str_trunc(chromMAGMA.EnOC.enriched $Description, 50)
chromMAGMA.EnOC.enriched$Description <- factor(chromMAGMA.EnOC.enriched $Description, levels=chromMAGMA.EnOC.enriched[order(chromMAGMA.EnOC.enriched $NEG_LOG10_P,decreasing=T),]$Description)
EnOC.plot <- ggplot(chromMAGMA.EnOC.enriched ,
aes(x = NEG_LOG10_P,
y = Description)) +
geom_col(fill = 'blue')+
coord_flip()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(axis.title.x=element_blank(),
axis.title.y=element_blank())+
xlim(0,2.5)
#HGSOC
HGSOC_enriched <- annotated_pathway %>%
filter(anno == 'HGSOC Specific')
chromMAGMA.HGSOC.enriched <- chromMAGMA.HGSOC.gse.df %>%
filter(Description %in% HGSOC_enriched$Description) %>%
mutate(NEG_LOG10_P = -log10(p.adjust)) %>%
top_n(10, NES)
chromMAGMA.HGSOC.enriched$Description <- str_trunc(chromMAGMA.HGSOC.enriched$Description, 50)
chromMAGMA.HGSOC.enriched$Description <- factor(chromMAGMA.HGSOC.enriched$Description, levels=chromMAGMA.HGSOC.enriched[order(chromMAGMA.HGSOC.enriched$NEG_LOG10_P,decreasing=T),]$Description)
HGSOC.plot <- ggplot(chromMAGMA.HGSOC.enriched,
aes(x = NEG_LOG10_P,
y = Description)) +
geom_col(fill = 'green') +
coord_flip() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(axis.title.x=element_blank(),
axis.title.y=element_blank())+
xlim(0,2.5)
#LGSOC
LGSOC_enriched <- annotated_pathway %>%
filter(anno == 'LGSOC Specific')
chromMAGMA.LGSOC.enriched <- chromMAGMA.LGSOC.gse.df %>%
filter(Description %in% LGSOC_enriched$Description) %>%
mutate(NEG_LOG10_P = -log10(p.adjust)) %>%
top_n(10, NES)
chromMAGMA.LGSOC.enriched$Description <- str_trunc(chromMAGMA.LGSOC.enriched$Description, 50)
chromMAGMA.LGSOC.enriched <- chromMAGMA.LGSOC.enriched %>%
distinct(Description, .keep_all = TRUE)
chromMAGMA.LGSOC.enriched$Description <- factor(chromMAGMA.LGSOC.enriched$Description, levels=chromMAGMA.LGSOC.enriched[order(chromMAGMA.LGSOC.enriched$NEG_LOG10_P,decreasing=T),]$Description)
LGSOC.plot <- ggplot(chromMAGMA.LGSOC.enriched,
aes(x = NEG_LOG10_P,
y = Description)) +
geom_col(fill = 'orange')+
coord_flip()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(axis.title.x=element_blank(),
axis.title.y=element_blank())+
xlim(0,2.5)
#MOC
MOC_enriched <- annotated_pathway %>%
filter(anno == 'MOC Specific')
chromMAGMA.MOC.enriched <- chromMAGMA.MOC.gse.df %>%
filter(Description %in% MOC_enriched$Description) %>%
mutate(NEG_LOG10_P = -log10(p.adjust)) %>%
top_n(10, NES)
chromMAGMA.MOC.enriched$Description <- str_trunc(chromMAGMA.MOC.enriched$Description, 50)
chromMAGMA.MOC.enriched$Description <- factor(chromMAGMA.MOC.enriched$Description, levels=chromMAGMA.MOC.enriched[order(chromMAGMA.MOC.enriched$NEG_LOG10_P,decreasing=T),]$Description)
MOC.plot <- ggplot(chromMAGMA.MOC.enriched,
aes(x = NEG_LOG10_P,
y = Description)) +
geom_bar(stat="identity", fill = 'purple')+
coord_flip()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
theme(axis.title.x=element_blank(),
axis.title.y=element_blank())+
xlim(0,2.5)
ggarrange(CCOC.plot,
EnOC.plot,
HGSOC.plot,
LGSOC.plot,
MOC.plot,
ncol = 5,
nrow = 1)