美文网首页
差异表达counts绘制火山图

差异表达counts绘制火山图

作者: 多啦A梦的时光机_648d | 来源:发表于2022-09-24 01:22 被阅读0次
##差异表达分析结果
de_result <- read_delim("twobam.counts.matrix.Mus_vs_Mus2.edgeR.DE_results", 
                                                     "\t", escape_double = FALSE, trim_ws = TRUE,)
image.png

-----注意id列

##多表关联与数据整理
tmp = select(de_result,id,logFC, PValue, FDR) %>%
  mutate(direction = if_else(abs(logFC)<1 |FDR >0.05, 'stand', if_else(logFC>=1,'up', 'down'))) %>%
  left_join(gene_exp,by=c('id'='X1'))  ## ##添加direction关联列(up stand down);关联gene_exp
image.png
##获取基因注释信息
1.若为20种模式物种(比如小鼠(ENSEMBL的id)或者人的(REFSEQ的id=genbank的id))
gene_anno = select(org.Mm.eg.db,keys = de_result$id, keytype = 'ENSEMBL', columns = c('SYMBOL','GENENAME'))
##gene_anno = select(org.Hs.eg.db,keys = de_result$id, keytype = 'REFSEQ', columns = c('SYMBOL','GENENAME'))
image.png
##关联基因功能
tmp2 =select(org.Mm.eg.db,keys = de_result$id, keytype = 'ENSEMBL', columns = c('SYMBOL','GENENAME')) %>% 
 left_join(tmp,by = c('ENSEMBL'='id'))
image.png

查看上下调


image.png

如果发现上下调基因差异较大,修改logFC)<1值

2.若为非模式物种,则需要去eggnog去做注释

5.火山图

devtools::install_github('stefano-meschiari/latex2exp')
library(latex2exp)
devtools::install_github('https://github.com/slowkow/ggrepel')
library(ggrepel)

tmp2 %>% 
  filter(-log10(PValue)>8) -> new.text.label

p1<-ggplot(data=tmp2,aes(x=logFC,y=-log10(PValue)))+
  geom_point(aes(color=direction))+
  scale_color_manual(values = c("down"="#0B1746",
                                "stand"="#4169E1",
                                "up"="#FFB6C1"),
                     labels=c("down"=TeX(r"(\textit{Mus}$-\textit{Heavy} depleted)"),
                              "stand"="Not Significant",
                              "up" = TeX(r"(\textit{Mus2}$-\textit{Heavy} enriched)")))+
  theme(legend.position = c(0.9,0.2),
      legend.text.align = 0,
      legend.title = element_blank())+
  geom_text_repel(data=new.text.label,
                  aes(x=logFC,y=-log10(PValue),
                      label=SYMBOL))+
  labs(x=TeX(r"(\textit{Mus}$-$\textit{Mus2}{(log$FC)}$))"),
       y=TeX(r"(-log${_1}{_0}$ {(}\textit{P}{ value}{)})"))
p1
p2<-ggplot(data=tmp2,aes(x=logFC,y=-log10(PValue)))+
  geom_point(aes(color=direction))+
  scale_color_manual(values = c("down"="darkgreen",
                                "stand"="#aaaaaa",
                                "up"="red"),
                     labels=c("down"=TeX(r"(\textit{Mus2}$$-\textit{Heavy} depleted)"),
                              "stand"="Not Significant",
                              "up" = TeX(r"(\textit{Mus}$$-\textit{Heavy} enriched)")))+
  theme_classic()+
  theme(legend.position = c(0.9,0.2),
        legend.text.align = 0,
        legend.title = element_blank())+
  geom_text_repel(data=new.text.label,
                  aes(x=logFC,y=-log10(PValue),
                      label=SYMBOL))+
  labs(x=TeX(r"(\textit{Mus}$-$\textit{Mus2}{(log$FC)}$)"),
       y=TeX(r"(-log${_1}{_0}$ {(}\textit{P}{ value}{)})"))
p2
library(patchwork)
pdf(file = "sonyong_Volcano.pdf",width = 14.1,height = 6)
p1+p2
dev.off()
image.png

6.最后查看一下上下调基因的功能及通路,选择自己感兴趣的往下做

en = c('Actg2','Krt7','Slc39a4','Tcf23')
select(org.Mm.eg.db,keys = en, keytype = 'SYMBOL',columns = c('GENENAME','PATH'))
image.png
image.png

相关文章

网友评论

      本文标题:差异表达counts绘制火山图

      本文链接:https://www.haomeiwen.com/subject/lftoortx.html