已知GO ids,获取其term和ontology

问题描述:
使用Blast2GO得到的.annot文件只有GO id号,即GO:2001317,没有其描述(term)和所属分类(ontology),根据网上的方法使用GO.db包发现有好多id找不到其对应信息,或许是因为我研究的物种是非模式生物?为了解决这一问题,我在http://geneontology.org/网站上挑了几个在GO.db包中找不到描述的id号进行搜索,发现都能找到,因此可以从这个网站入手解决问题。
问题解决:

  1. http://geneontology.org/docs/download-ontology/下载go.obo文件
    用Notepad++打开如下所示:
    go.obo.png

    2.使用python脚本go.obo.py解析go.obo文件并保存为csv文件(运行python go.obo.py即可,提前安装好tqdm和pandas)
from tqdm import tqdm
import pandas as pd

data = []
with open('go.obo', 'r') as file:
    for line in tqdm(file):
        if line.startswith('[Term]'):
            next_line_1 = next(file).strip()
            next_line_2 = next(file).strip()
            next_line_3 = next(file).strip()

            id_string = next_line_1.split('id: ')[1]
            name_string = next_line_2.split('name: ')[1]
            namespace_string = next_line_3.split('namespace: ')[1]

            data.append({'id': id_string, 'name': name_string, 'namespace': namespace_string})

df = pd.DataFrame(data)
df.columns = ['GO','TERM','ONTOLOGY']
df.to_csv("GO_database.csv", index=False)

注意:我只提取了go id,term和ontology信息,如果需要其他可自行添加,部分结果如下图所示:


GO_database.csv.png
  1. 根据自己的GO id list用R tidyverse包的left_join函数就可以提取想要的GO id及其term和ontology信息了,方便后续进行GO富集分析等。
Info=left_join(id,GO_database,by="GO")
GO id list.png

GO info.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。