这篇Cell里面的GSEA展示很不错!
生活随笔
收集整理的這篇文章主要介紹了
这篇Cell里面的GSEA展示很不错!
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這篇文章中有一張圖很有趣,如下:
作者使用Hallmarks通路進行GSEA富集分析,共發現26條通路顯著與兩種表型相關,與stemness表型相關的有16條通路,與cancer表型相關的有10條通路。
本次演練中,我們選擇MSIDB數據庫中的50條Hallmarks通路進行示例,通路信息下載鏈接:http://www.gsea-msigdb.org/gsea/downloads.jsp
下面我們用我們自己的數據來做一下這張圖:
表達矩陣為 raw read count data
head(clin)第一列為expr每一列對應的ID,第二列為分組信息。
table(clin$Group)0和1分別有223個和135個
##構建分組信息 group?<-?factor(rep(c('1','0'),times=c(135,223))) colData <- data.frame(row.names=rownames(clin),group) ##保留在50%以上的樣本中count>=1的基因 keep?<-?rowSums(expr>=1)?>=?ncol(expr)*0.5 table(keep) cc?<-?expr[keep,] ##差異分析 dds <- DESeqDataSetFromMatrix(round(cc), colData, design= ~group) dds <- DESeq(dds) res<-?results(dds,contrast=c("group","1","0"),independentFiltering=FALSE) ##差異分析結果 alldiff <- as.data.frame(res)%>%na.omit() alldiff$type <- ifelse(alldiff$padj>0.05,'No-Sig',ifelse(alldiff$log2FoldChange>1,'Up',ifelse(alldiff$log2FoldChange< -1,'Down','No-Sig')))table(alldiff$type) ##?順手畫個火山圖 ggplot(alldiff,aes(log2FoldChange,-log10(padj),fill=type))+geom_point(shape=21,aes(size=-log10(padj),color=color))+scale_fill_manual(values=c('seagreen','gray','orange'))+scale_color_manual(values=c('gray60','black'))+geom_vline(xintercept=c(-1,1),lty=2,col="gray30",lwd=0.6) +geom_hline(yintercept = -log10(0.05),lty=2,col="gray30",lwd=0.6)+theme_bw(base_rect_size = 1)+theme(axis.title = element_text(size = 15),axis.text = element_text(size = 12),legend.title = element_blank(),legend.text = element_text(size = 12),panel.grid = element_blank(),plot.title = element_text(family = 'regular',hjust = 0.5),legend.position = c(0.5, 1),legend.justification = c(0.5, 1),legend.key.height = unit(0.5,'cm'),legend.background = element_rect(fill = NULL, colour = "black",size = 0.5))+xlim(-4,4)+guides(size=F,color=F)+ylab('-log10 (FDR)')+xlab('log2 (Fold Change)')接下來開始重頭戲,開始畫GSEA table
## 根據logfc降序排列基因 alldiff?<-?alldiff[order(alldiff$log2FoldChange,decreasing?=?T),] ##?fgsea中輸入的關鍵基因信息 id <- alldiff$log2FoldChange names(id)?<-?rownames(alldiff) ##?fgsea中輸入的關鍵通路信息 gmtfile <- "./h.all.v7.4.symbols.gmt" hallmark <- read.gmt(gmtfile) hallmark$term <- gsub('HALLMARK_','',hallmark$term) hallmark.list <- hallmark %>% split(.$term) %>% lapply( "[[", 2) ##?Perform?the?fgsea analysis fgseaRes <- fgsea(pathways = hallmark.list, stats = id,minSize=1,maxSize=10000,nperm=10000) sig <- fgseaRes[fgseaRes$padj<0.05,] sig <- sig[order(sig$NES,decreasing = T),] ##?最后一步 開始繪圖 plotGseaTable(hallmark.list[sig$pathway],id, fgseaRes,gseaParam = 0.5)這樣子基本上畫完了,但是貌似不是很好看,可以保存為PPT格式再處理一下
library(export) graph2ppt(file = 'GSEA-table.pptx',height = 7,width = 8.5)其中每個元素都可以調整哦
調整完之后如下所示:
加編者微信入群 "生信交流群-醫學僧"
加微信時請備注 "學校-專業-姓名"
往期精品(點擊圖片直達文字對應教程)
機器學習
后臺回復“生信寶典福利第一波”或點擊閱讀原文獲取教程合集
總結
以上是生活随笔為你收集整理的这篇Cell里面的GSEA展示很不错!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 生信学习学的是什么?常识!
- 下一篇: 基因表达热图聚类并增加行列注释