MSigDBR - MattHuff/scRNASeq_011224 GitHub Wiki
Previous MSigDBR Documentation
Load Packages, Set Working Directory, and Obtain DE Genes
# Load Dependencies
library(CellChat)
library(circlize)
library(ComplexHeatmap)
library(NMF)
library(patchwork)
library(msigdbr)
library(clusterProfiler)
# Set Working Directory
setwd("~/Downloads/scRNASeq_011224/5_Seurat/")
# Get Significant Genes
combined_df_sign <- read.table(file = "outputs/de_out/Norris_Dge_FindMarkersMAST_Sign_run2.txt",
sep = "\t", header = TRUE)
Set Up Pathway Analysis
# Set up directories
pviz_dir <- "outputs/de_out/Pathway_enrichment/"
if(!dir.exists(pviz_dir)){dir.create(pviz_dir,recursive = T)}
# Set up DB
human_db <- msigdbr(species = "Homo sapiens")
msigdbr_t2g <- human_db %>%
dplyr::distinct(gs_name, gene_symbol) %>%
as.data.frame()
Run Pathway Enricher
cellTypes <- unique(combined_df_sign$celltype)
for (cell in cellTypes) {
cur_df <- subset(combined_df_sign, celltype == cell)
gene_vector <- cur_df$genes
overRep <- enricher(gene = gene_vector, TERM2GENE = msigdbr_t2g)
r1 <- dotplot(overRep, showCategory=10) + ggtitle(paste0("Human Celltype: ", cell))
ggsave(filename = paste0(pviz_dir,"GeneRatio_OverRep_", cell, ".pdf"), width = 12)
#gSea <- GSEA(gene = gene_vector, TERM2GENE = msigdbr_t2g)
#r2 <- dotplot(gSea, showCategory=10) + ggtitle(paste0("Human Celltype: ", cell))
#ggsave(filename = paste0(pviz_dir,"GeneRatio_GSEA_", cell, ".pdf"), width = 12)
}