Gene Ontology(GO)是一个广泛使用的术语库,用于描述和统计基因与蛋白质功能的相互关系。GO把生物学领域中的复杂概念分解成更简单、更易理解的术语。这些术语被组织成有向无环图,称为GO图,它描述了基因、基因产物及其功能间的分层次结构关系。
一、基本概念
1、术语库
GO术语库分为三个主要的分支:分子功能、细胞组分和生物过程。分子功能描述分子水平上一个基因产物的活性,细胞组分描述的是这个基因产物在哪里发挥作用,生物过程描述的是哪些事件会导致这个基因产物的表达变化。
2、GO图
GO图是一个由有向无环图组成的术语描述的分层结构。三个主要的分支是分子功能,细胞组分和生物过程。每个分支是一个独立的层级架构,相互独立,互相连接。它们紧密地关联在一起,构成了一个基因和蛋白质功能的完整描述。
3、GO ID
GO ID是唯一的GO名称标识符。每个GO对应一个GO ID。GO ID 由一个“GO”字母后面跟着一个长度为7位的数字组成。
二、基于GO的生物信息分析
1、GO数据库下载
基于GO分析需要从官方网站下载最新的数据库文件。官网可以根据需要下载各种格式的数据。例如,可以下载完整的数据库(GO Annotation:gene_association.goa_ref_human.gz 和go-basic.obo),或者只下载一部分数据(例如 GO ID 和前缀)。
2、基于GO的生物信息学分析流程
3、GO富集分析
GO分析可用于解释已知基因集中基因的生物学组成。富集分析将一个基因表达数据集与基因的GO注释信息结合起来,以确定哪些GO术语在该基因表达数据集中显著富集。
三、使用python解析GO库数据
1、下载GO文件和注释文件
go-basic.obo:http://geneontology.org/ontology/go-basic.obo gene_association.goa_ref_human:http://geneontology.org/gene-associatio 引入包和下载数据 import wget go_obo_url = 'http://geneontology.org/ontology/go-basic.obo' go_obo_file_name = wget.download(go_obo_url) go_annotations_url = 'http://geneontology.org/gene-associations/gene_association.goa_ref_human.gz' go_annotations_file_name = wget.download(go_annotations_url)
2、解析GO文件
从go-basic.obo文件中解析GO属性 from collections import defaultdict go_id_to_name = {} go_id_to_namespace = defaultdict(set) with open(go_obo_file_name) as f: current_block = None for line in f: if line.startswith('[Term]'): current_block = 'Term' elif line.startswith('[Typ'): current_block = 'Type' if current_block == 'Term' and line.startswith('id:'): go_id = line.split()[-1] elif current_block == 'Term' and line.startswith('name:'): name = line.split()[-1] go_id_to_name[go_id] = name elif current_block == 'Term' and line.startswith('namespace:'): namespace = line.split()[-1] go_id_to_namespace[namespace].add(go_id)
3、解析注释文件
从gene_association.goa_ref_human.gz文件中解析GO注释信息 import gzip import pandas as pd gene_id_to_symbol = {} symbol_to_gene_ids = defaultdict(set) gene_id_to_go = defaultdict(set) with gzip.open(go_annotations_file_name) as f: for line in f: line = line.strip().decode() if line.startswith('!'): continue fields = line.split('\t') gene_id = fields[1] symbol = fields[2] go_id = fields[4] aspect = fields[8] gene_id_to_symbol[gene_id] = symbol symbol_to_gene_ids[symbol].add(gene_id) gene_id_to_go[gene_id].add(go_id)
4、结果展示
使用Python Pandas数据分析库来展示GO分析结果 # 统计GO ID和基因数目 go_id_to_gene_count = {go_id: len(set(gene_ids)) for go_id, gene_ids in gene_id_to_go.items()} # 构造一个dataframe来展示GO ID、GO Term、命名空间、基因计数等信息 go_info_df = pd.DataFrame({'go_term': list(go_id_to_name.values()), 'namespace': [list(go_id_to_namespace['molecular_function'])[0] for i in range(len(go_id_to_name))], 'go_id': list(go_id_to_name.keys()), 'gene_count': list(go_id_to_gene_count.values())}) # 按基因计数排序,并展示前10个结果 sorted_go_info_df = go_info_df.sort_values(by='gene_count', ascending=False) top_10_go_term_df = sorted_go_info_df[:10][['go_id', 'go_term']] print(top_10_go_term_df.to_string(index=False))
原创文章,作者:PJFBT,如若转载,请注明出处:https://www.506064.com/n/370951.html