一悟泵、讀取文件树酪,ID轉(zhuǎn)換
1.讀取文件
library(clusterProfiler)
library(org.Hs.eg.db)
#讀取文件赘风,原始文件中使用空格分割的
go_ythdf2 <- read.table("./goList/RIP YTHDF2 RNAseq.txt",sep=" ")
go_ythdf2 <- t(go_ythdf2)
2.ID轉(zhuǎn)換髓考,ENTREZID是進(jìn)行GO分析最好的ID類型(針對(duì)clusterProfiler)
ID轉(zhuǎn)換用到的是bitr()
函數(shù),bitr()的使用方法:
bitr(geneID, fromType, toType, OrgDb, drop = TRUE)
geneID:一個(gè)含有g(shù)ene_name的矢量
orgDb:人類的注釋包是 org.Hs.eg.db
fromType:輸入的gene_name的類型
toType:需要轉(zhuǎn)換成的gene_name的類型舞痰,可以是多種類型土榴,用大寫character類型向量表示
3.gene_name的類型查看
org.Hs.eg.db包含有多種gene_name的類型
#查看org.Hs.eg.db中可以被選擇/使用的類型
keytypes(org.Hs.eg.db)
[1] "ACCNUM" "ALIAS" "ENSEMBL" "ENSEMBLPROT" "ENSEMBLTRANS" "ENTREZID"
[7] "ENZYME" "EVIDENCE" "EVIDENCEALL" "GENENAME" "GO" "GOALL"
[13] "IPI" "MAP" "OMIM" "ONTOLOGY" "ONTOLOGYALL" "PATH"
[19] "PFAM" "PMID" "PROSITE" "REFSEQ" "SYMBOL" "UCSCKG"
[25] "UNIGENE" "UNIPROT"
#ID轉(zhuǎn)換,把gene_symbol轉(zhuǎn)換成ENTREZID响牛。
go_ythdf2_id_trance <- bitr(go_ythdf2,fromType = "SYMBOL",toType = "ENTREZID",OrgDb = "org.Hs.eg.db",drop = T)
4.org.Hs.eg.db的相關(guān)函數(shù)
keytypes():keytypes(x)玷禽,查看注釋包中可以使用的類型
columns():類似于keytypes(),針對(duì)org.Hs.eg.db兩個(gè)函數(shù)返回值一致
select():select(x, keys, columns, keytype, ...) eg.
#類似于bitr()的注釋方式
select(org.Hs.eg.db, keys=geneids, columns=c("SYMBOL", "GENENAME"呀打,"GO"), keytype="ENSEMBL")
二矢赁、GO注釋
函數(shù)enrichGO()進(jìn)行GO富集分析,enrichGO()的使用方法:
enrichGO(gene, OrgDb, keyType = "ENTREZID", ont = "MF", pvalueCutoff = 0.05,
pAdjustMethod = "BH", universe, qvalueCutoff = 0.2, minGSSize = 10,
maxGSSize = 500, readable = FALSE, pool = FALSE)
Arguments:
gene a vector of entrez gene id.
OrgDb OrgDb
keyType keytype of input gene
ont One of "MF", "BP", and "CC" subontologies or 'ALL'.
pvalueCutoff Cutoff value of pvalue.
pAdjustMethod one of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"
universe background genes
qvalueCutoff qvalue cutoff
minGSSize minimal size of genes annotated by Ontology term for testing.
maxGSSize maximal size of genes annotated for testing
readable whether mapping gene ID to gene Name
pool If ont=’ALL’, whether pool 3 GO sub-ontologies
舉例:
result_go_ythdf2 <- enrichGO(go_ythdf2_id_trance$ENTREZID,OrgDb = "org.Hs.eg.db",
keyType = "ENTREZID",ont = "ALL",readable = T)
結(jié)果處理
畫(huà)圖
dotplot(result_go_ythdf2,showCategory=50)
barplot(result_go_ythdf2,showCategory=20)
保存
df_go_ythdf2 <- as.data.frame(result_go_ythdf2)
write.table(df_go_ythdf2,"df_go_ythdf2.xls",quote = F,sep = "\t")
三贬丛、整體代碼
library("clusterProfiler")
library("org.Hs.eg.db")
#讀取數(shù)據(jù)
go_ythdf2 <- read.table("./goList/RIP YTHDF2 RNAseq.txt",sep=" ")
go_ythdf2 <- t(go_ythdf2)
#ID轉(zhuǎn)換
go_ythdf2_id_trance <- bitr(go_ythdf2,fromType = "SYMBOL",toType = "ENTREZID",
OrgDb = "org.Hs.eg.db",drop = T)
#GO分析
result_go_ythdf2 <- enrichGO(go_ythdf2_id_trance$ENTREZID,OrgDb = "org.Hs.eg.db",
keyType = "ENTREZID",ont = "ALL",readable = T)
#繪圖
dotplot(result_go_ythdf2,showCategory=50)
barplot(result_go_ythdf2,showCategory=20)
#保存
df_go_ythdf2 <- as.data.frame(result_go_ythdf2)
write.table(df_go_ythdf2,"df_go_ythdf2.xls",quote = F,sep = "\t")
我想建立并管理一個(gè)高質(zhì)量的生信&統(tǒng)計(jì)相關(guān)的微信討論群撩银,如果你想?yún)⑴c討論,可以添加微信:veryqun 豺憔。我會(huì)拉你進(jìn)群额获,當(dāng)然有問(wèn)題也可以微信咨詢我。