gsea_presto

gsea_presto

Downstream analysis of scRNAseq data

Gene Set enrichment (GSEA) analysis

library(Seurat)
library(devtools)
options(buildtools.check = function(action) TRUE )
install_github('immunogenomics/presto')

BiocManager::install('githubinstall')
library(githubinstall)
githubinstall('immunogenomics/presto')

devtools::install_local("idmap2.zip")

library(tidyverse)
library(presto)

setwd("D:/Data")
load("seu.rda")

pbmc<- seu

nc<-length(unique(pbmc@meta.dataseurat_clusters)) clusters<-as.vector(unique(pbmc@meta.dataseurat_clusters))

pbmc.genes <- wilcoxauc(pbmc, 'seurat_clusters')
head(pbmc.genes)

we have all the genes for each cluster

dplyr::count(pbmc.genes, group)

BiocManager::install(c("msigdbr", "fgsea"))

library(msigdbr)
library(fgsea)
library(dplyr)
library(ggplot2)

msigdbr_show_species()
m_df<- msigdbr(species = "Homo sapiens", category = "H")
head(m_df)
fgsea_sets<- m_df %>% split(x = .gene_symbol, f = .gs_name)

p<-list()
nes<-matrix(0,50,nc)
p.me<-matrix(0,50,nc)

colnames(nes)<-clusters
colnames(p.me)<-clusters

for (i in 1:nc){

ci<-clusters[i]
print (ci)

select only the feature and auc columns for fgsea, which statistics to use is an open question

cluster0.genes<- pbmc.genes %>%
dplyr::filter(group == ci) %>%
arrange(desc(auc)) %>%
dplyr::select(feature, auc)
ranks<- deframe(cluster0.genes)
head(ranks)
fgseaRes<- fgsea(fgsea_sets, stats = ranks, nperm = 1000)

nes[,i]<-fgseaResNES rownames(nes)<-fgseaRespathway
p.me[,i]<-fgseaRespadj rownames(p.me)<-fgseaRespathway

fgseaResTidy <- fgseaRes %>%
as_tibble() %>%
arrange(desc(NES))
fgseaResTidy %>%
dplyr::select(-leadingEdge, -ES, -nMoreExtreme) %>%
arrange(padj) %>%
head()

```

plot a barplot for with the normalized Enrichment score

}

p.me<--log10(p.me)

pdf("presto_hallmarker_all.pdf")
breaks<-seq(-10,10,1)
legend_breaks<-seq(-10,10,2)

pheatmap(nes, scale="none",#fontsize_row=8,
cluster_rows=TRUE, cluster_cols=TRUE,

     color = c(colorRampPalette(colors=c("navy","white"))(10),colorRampPalette(colors=c("white","firebrick3"))(10)),
     legend_breaks=legend_breaks,
     breaks=breaks,
     fontsize_row=7,
     fontsize_legend=1.0)

pheatmap(nes, scale="row",#fontsize_row=8,
cluster_rows=TRUE, cluster_cols=TRUE,

     color = c(colorRampPalette(colors=c("navy","white"))(5),colorRampPalette(colors=c("white","firebrick3"))(5)),
     
     fontsize_row=7,
     fontsize_legend=1.0)

breaks<-c(0,1.3,2,3)
legend_breaks<-breaks

pheatmap(p.me, scale="none",#fontsize_row=8,
cluster_rows=TRUE, cluster_cols=TRUE,

     clustering_distance_rows = "euclidean",
     clustering_distance_cols = "euclidean",
     color = c(colorRampPalette(colors=c("white","firebrick3"))(3)),
     legend_breaks=legend_breaks,
     breaks=breaks,
     fontsize_row=7,
     fontsize_legend=1.0)

dev.off()

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ==================安装seurant================ install.packa...
    jjjscuedu阅读 9,732评论 0 6
  • 本文参考Satija Lab的seurat 包,网址https://satijalab.org/seurat 设置...
    麒麟991阅读 34,610评论 1 29
  • 首先,我们需要知道,热图的原理就是根据你的matrix或者data.frame中行列数字大小,映射到一个个独立的小...
    我最有才阅读 6,639评论 0 4
  • 久违的晴天,家长会。 家长大会开好到教室时,离放学已经没多少时间了。班主任说已经安排了三个家长分享经验。 放学铃声...
    飘雪儿5阅读 12,193评论 16 22
  • 创业是很多人的梦想,多少人为了理想和不甘选择了创业来实现自我价值,我就是其中一个。 创业后,我由女人变成了超人,什...
    亦宝宝阅读 5,848评论 4 1