使用clusterProfiler给非模式物种做富集分析的一些参考资料

玉米虽然是非模式物种,但是研究的人也挺多的,注释信息也非常完整了

if(interactive()){
  
  ## Makes an organism package for Zebra Finch data.frames:
  finchFile <- system.file("extdata","finch_info.txt",package="AnnotationForge")
  finch <- read.table(finchFile,sep="\t")
  
  ## not that this is how it should always be, but that it *could* be this way.
  fSym <- finch[,c(2,3,9)]
  fSym <- fSym[fSym[,2]!="-",]
  fSym <- fSym[fSym[,3]!="-",]
  colnames(fSym) <- c("GID","SYMBOL","GENENAME")
  
  fChr <- finch[,c(2,7)]
  fChr <- fChr[fChr[,2]!="-",]
  colnames(fChr) <- c("GID","CHROMOSOME")
  
  finchGOFile <- system.file("extdata","GO_finch.txt",package="AnnotationForge")
  fGO <- read.table(finchGOFile,sep="\t")
  fGO <- fGO[fGO[,2]!="",]
  fGO <- fGO[fGO[,3]!="",]
  colnames(fGO) <- c("GID","GO","EVIDENCE")
  
  makeOrgPackage(gene_info=fSym, chromosome=fChr, go=fGO,
                 version="0.1",
                 maintainer="Some One <so@someplace.org>",
                 author="Some One <so@someplace.org>",
                 outputDir = ".",
                 tax_id="59729",
                 genus="Taeniopygia",
                 species="guttata",
                 goTable="go")
  
  ## then you can call install.packages based on the return value
  install.packages("./org.Tguttata.eg.db", repos=NULL)
  
}
## test data lets load up a couple tab files from /extdata...
## file finch_info.txt now has data I can use (for examples)
library(AnnotationForge)

finchFile <- system.file("extdata","finch_info.txt",package="AnnotationForge")
finch <- read.table(finchFile,sep="\t")

## not that this is how it should always be, but that it *could* be this way.
fSym <- finch[,c(2,3,9)]
fSym <- fSym[fSym[,2]!="-",]
fSym <- fSym[fSym[,3]!="-",]
colnames(fSym) <- c("GID","SYMBOL","GENENAME")

fChr <- finch[,c(2,7)]
fChr <- fChr[fChr[,2]!="-",]
colnames(fChr) <- c("GID","CHROMOSOME")


finchGOFile <- system.file("extdata","GO_finch.txt",package="AnnotationForge")
fGO <- read.table(finchGOFile,sep="\t")
fGO <- fGO[fGO[,2]!="",]
fGO <- fGO[fGO[,3]!="",]
colnames(fGO) <- c("GID","GO","EVIDENCE")

## Now make a list
## data <- list(gene_info=fSym, chromosome=fChr, go=fGO)
genus <- "Taeniopygia"
species <- "guttataTestingSubset"
dbName <- AnnotationForge:::.generateOrgDbName(genus,species)
## this becomes the file name for the DB
dbfile <- paste(dbName, ".sqlite", sep="")



## Test DB building:
## AnnotationForge:::makeOrgDbFromDataFrames(data, genus, species, dbfile)

# debug(AnnotationForge:::.makeAnnDbPkg)
# debug(AnnotationForge:::.createAnnotPackage)



## or test pkg building
AnnotationForge:::makeOrgPackage(gene_info=fSym, chromosome=fChr, go=fGO,
                                 version="0.1",
                                 maintainer="Some One <so@someplace.org>",
                                 author="Some One <so@someplace.org>",
                                 outputDir = ".",
                                 tax_id="59729",
                                 genus=genus,
                                 species=species)


AnnotationForge:::makeOrgPackage(gene_info=fSym, chromosome=fChr, go=fGO,
                                 version="0.1",
                                 maintainer="Some One <so@someplace.org>",
                                 author="Some One <so@someplace.org>",
                                 outputDir = ".",
                                 tax_id="59729",
                                 genus=genus,
                                 species=species,
                                 goTable="go")

## then you can install on the return value
install.packages("./org.Tguttata.eg.db", repos=NULL)




## NEXT UP: lets make an actual template in AnnotationDbi so that I
## can start making these things as packages.
library(org.Tguttata.eg.db)
#debug(AnnotationDbi:::.noSchemaCols)
columns(org.Tguttata.eg.db)
## so that change will also work for keytypes
keytypes(org.Tguttata.eg.db)

## Now for keys I need to read carefully.
## I want to do the same thing for .keys that I did for
library(org.Tguttata.eg.db)
# debug(AnnotationDbi:::.noSchemaKeys)
keys(org.Tguttata.eg.db, "CHROMOSOME")

head(keys(org.Tguttata.eg.db, "GID"))

head(keys(org.Tguttata.eg.db, "SYMBOL", pattern="BDNF"))

head(keys(org.Tguttata.eg.db, "GID", pattern="BDNF", column="SYMBOL"))

head(keys(org.Tguttata.eg.db, "SYMBOL", column="GID"))



## Now I just need select() to work...
library(org.Tguttata.eg.db)
## debug(AnnotationDbi:::.noSchemaSelect)

## TODO: add check to the keys argument to make sure its a character()
select(org.Tguttata.eg.db, keys="100008579", columns="SYMBOL", keytype="GID")
## 
select(org.Tguttata.eg.db, keys="100008579", columns=c("SYMBOL","CHROMOSOME"), keytype="GID")
## This one should warn about the number or rows - it does
select(org.Tguttata.eg.db, keys="100008579", columns="GO", keytype="GID")
## now fixed
select(org.Tguttata.eg.db, keys="100008579", columns=c("GO","EVIDENCE"), keytype="GID")
## What if there is only one table to visit?
select(org.Tguttata.eg.db, keys="BDNF", columns="GENENAME", keytype="SYMBOL")




## TODO:
## 1) Add checks for all arguments (especially data) - DONE
## 2) Add code to look for and extract ALL extra GIDs - DONE

## 3) Add code to filter GO IDs :
## A - add arg to function to say which table should get GO treatment. - DONE
## B - add special checks for GO frame (special checker)- DONE
## - only three cols required (GID, GO, EVIDENCE)- DONE
## - those cols must have names: GID, GO, EVIDENCE- DONE
## C - add function to drop old go table, and make 2 new ones:  -DONE
## D - use .filterGOFrame to remove stuff that's too new from go->populate - DONE
## E - make newer .expandGOFRAME to make a go_all table -DONE
## - (GID, GOALL, EVIDENCEALL, ONTOLOGYALL) - yep
## - require(GO.db); select(GO.db, go$GO, "ONTOLOGY") -yep
## 4) Add indexing to relevant fields (_id, go_id and all others) - DONE
## 5.5) change the argument on the external function from a list to a ... Then internally convert that to a list use: extraArgs <- list(...) - DONE
## 6) Add manual page - DONE




## 5) Add unit tests for new helpers  - Need some help

## 6.5) Add more checks:
##1) GO terms should look like: "GO:DDDDDDD";
## 2) no row names on the data.frames. - DONE

## 7) Add vignette for makeOrgPackage() and for makeOrgPackageFromNCBI()

欢迎大家关注我的公众号
小明的数据分析笔记本

公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记!

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,372评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,368评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,415评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,157评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,171评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,125评论 1 297
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,028评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,887评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,310评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,533评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,690评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,411评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,004评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,659评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,812评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,693评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,577评论 2 353

推荐阅读更多精彩内容