使用 mygene.info 获取基因注释信息

特简介 在生物信息学研究中,获取准确和全面的基因注释信息是至关重要的。mygene.info是一个提供全面、准确和最新基因注释信息的在线服务。该服务由Scripps研究所提供,并以RESTful API的形式...

特简介

在生物信息学研究中,获取准确和全面的基因注释信息是至关重要的。mygene.info是一个提供全面、准确和最新基因注释信息的在线服务。该服务由Scripps研究所提供,并以RESTful API的形式开放给公众。在本文中,我们将探讨如何使用mygene.info的Python包来快速获取基因的相关信息。

特点

  • 多物种支持: 包括人、小鼠、大鼠、斑马鱼等多个模式生物。
  • 多数据源聚合: 聚合了来自NCBI、Ensembl、UniProt等多个主流数据库的数据。
  • 灵活的查询: 支持多种类型的基因标识符。
  • 批量操作: 支持批量获取和注释,提高工作效率。
  • 多语言支持: 除了Python,还有R和其他语言的支持。
  • 安装

    使用 pip 安装:

    pip install mygene

    示例

    单个基因查询

    首先,导入MyGeneInfo类,并实例化。

    import mygene
    mg = mygene.MyGeneInfo()
  • 使用 query 方法来查询单个基因,比如人类的 TP53 基因。

    gene_info = mg.query('TP53', species='human')
    print(gene_info)
    >>> print(gene_info)
    {'took': 102, 'total': 394, 'max_score': 88.34604, 'hits': [{'_id': '7157', '_score': 88.34604, 'entrezgene': '7157', 'name': 'tumor protein p53', 'symbol': 'TP53', 'taxid': 9606}, {'_id': '27296', '_score': 63.07153, 'entrezgene': '27296', 'name': 'TP53 target 5', 'symbol': 'TP53TG5', 'taxid': 9606}, {'_id': '11257', '_score': 63.07153, 'entrezgene': '11257', 'name': 'TP53 target 1', 'symbol': 'TP53TG1', 'taxid': 9606}, {'_id': '112858', '_score': 63.07153, 'entrezgene': '112858', 'name': 'TP53 regulating kinase', 'symbol': 'TP53RK', 'taxid': 9606}, {'_id': '24150', '_score': 63.07153, 'entrezgene': '24150', 'name': 'TP53 target 3', 'symbol': 'TP53TG3', 'taxid': 9606}, {'_id': '653550', '_score': 63.07153, 'entrezgene': '653550', 'name': 'TP53 target 3C', 'symbol': 'TP53TG3C', 'taxid': 9606}, {'_id': '729264', '_score': 63.07153, 'entrezgene': '729264', 'name': 'TP53 target 3D', 'symbol': 'TP53TG3D', 'taxid': 9606}, {'_id': '729355', '_score': 63.07153, 'entrezgene': '729355', 'name': 'TP53 target 3B', 'symbol': 'TP53TG3B', 'taxid': 9606}, {'_id': '102723655', '_score': 51.38891, 'entrezgene': '102723655', 'name': 'TP53-target gene 3 protein', 'symbol': 'LOC102723655', 'taxid': 9606}, {'_id': '57103', '_score': 51.38891, 'entrezgene': '57103', 'name': 'TP53 induced glycolysis regulatory phosphatase', 'symbol': 'TIGAR', 'taxid': 9606}]}
    

    批量注释

    如果你有一个基因ID列表,你可以使用 querymany 方法来进行批量查询。

    gene_list = ['1017', '1018', '1019']
    result = mg.querymany(gene_list, scopes='entrezgene', species='human', fields='symbol,name')
    print(result)
    >>> print(result)
    [{'query': '1017', '_id': '1017', '_score': 26.068851, 'name': 'cyclin dependent kinase 2', 'symbol': 'CDK2'}, {'query': '1018', '_id': '1018', '_score': 26.068903, 'name': 'cyclin dependent kinase 3', 'symbol': 'CDK3'}, {'query': '1019', '_id': '1019', '_score': 26.068905, 'name': 'cyclin dependent kinase 4', 'symbol': 'CDK4'}]
    

    根据条件过滤

    可以根据GO标签、染色体位置等条件进行过滤。

    result = mg.query('GO:0006915', species='human', fields='entrezgene')
    print(result)
    >>> print(result)
    {'took': 14, 'total': 555, 'max_score': 9.643033, 'hits': [{'_id': '56924', '_score': 9.643033, 'entrezgene': '56924'}, {'_id': '1946', '_score': 9.643033, 'entrezgene': '1946'}, {'_id': '196', '_score': 9.643033, 'entrezgene': '196'}, {'_id': '10201', '_score': 9.643033, 'entrezgene': '10201'}, {'_id': '23204', '_score': 9.643033, 'entrezgene': '23204'}, {'_id': '23213', '_score': 9.643033, 'entrezgene': '23213'}, {'_id': '23239', '_score': 9.643033, 'entrezgene': '23239'}, {'_id': '23241', '_score': 9.643033, 'entrezgene': '23241'}, {'_id': '23421', '_score': 9.643033, 'entrezgene': '23421'}, {'_id': '23429', '_score': 9.643033, 'entrezgene': '23429'}]}
    

    ID转换

    使用 querymany 还可以进行ID转换,比如从 Entrez ID 转到 Ensembl ID。

    result = mg.querymany(['1017', '1018', '1019'], scopes='entrezgene', fields='ensembl.gene', species='human')
    print(result)
    >>> print(result)
    [{'query': '1017', '_id': '1017', '_score': 26.06837, 'ensembl': {'gene': 'ENSG00000123374'}}, {'query': '1018', '_id': '1018', '_score': 26.068947, 'ensembl': {'gene': 'ENSG00000250506'}}, {'query': '1019', '_id': '1019', '_score': 26.068468, 'ensembl': {'gene': 'ENSG00000135446'}}]

    批量获取

    比如这里批量获取了所有人类激酶

    result = mg.query('name:kinase', species='human', fetch_all=True)
    >>> print(result)
    <generator object _fetch_all at 0x7fec027d2eb0>

    结论

    mygene.info 提供了一个方便、快捷获取基因注释信息的途径。其丰富的功能和灵活的查询方式使其成为生物信息学研究中的有力工具。无论你是进行哪种类型的基因研究,都值得一试。

    参考链接


  • 发表于 2023-09-12 15:56
  • 阅读 ( 515 )
  • 分类:基础知识

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
xun
xun

电路元件工程师

68 篇文章

作家榜 »

  1. omicsgene 658 文章
  2. 安生水 328 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. 红橙子 78 文章
  6. CORNERSTONE 72 文章
  7. xun 68 文章
  8. rzx 67 文章