今天是生信星球陪你的第1008天
公众号里的文章大多数需要编程基础,如果因为代码看不懂,而跟不上正文的节奏,可以来找我学习,相当于给自己一个新手保护期。我的课程都是循环开课,点进去咨询微信↓
生信分析直播课程(每月初开一期,春节休一个月)
生信新手保护学习小组(每月两期)
单细胞陪伴学习小组(每月两期)
rm(list = ls())
library(clusterProfiler)
library(org.At.tair.db)
library(stringr)
library(ggplot2)
load("genes.Rdata")
head(genes)
## [1] "ATBCA3" "BCA3" "AtWSCP" "Kunitz-PI;1" "BCAT6"
## [6] "OSR1"
1.ID转换
x = bitr(genes,fromType = "SYMBOL",toType = "TAIR",
OrgDb = "org.At.tair.db")
head(x)
## SYMBOL TAIR
## 1 ATBCA3 AT1G23730
## 2 BCA3 AT1G23730
## 3 AtWSCP AT1G72290
## 4 Kunitz-PI;1 AT1G72290
## 5 BCAT6 AT1G50110
## 6 OSR1 AT2G41230
2.做KEGG富集
ekk <- enrichKEGG(gene = x$TAIR,organism = 'ath')
ekk <- setReadable(ekk,OrgDb = org.At.tair.db,keyType = "TAIR")
#如果ekk是空的,这句就会报错,因为没富集到任何通路。
# 条带图画一下
barplot(ekk)
ekk@result$Description = str_remove(ekk@result$Description," - Arabidopsis thaliana \\(thale cress\\)")
barplot(ekk)
3.GO富集分析
ego <- enrichGO(gene = genes,OrgDb= org.At.tair.db,
keyType = "SYMBOL",
ont = "ALL")
barplot(ego, split = "ONTOLOGY") +
facet_grid(ONTOLOGY ~ ., space = "free_y",scales = "free_y")