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/zh-tw/n/370951.html