2008年6月20日金曜日

go-perl (GO::Model::Grap)

今回は、GO::Model::Graphオブジェクトについて。

GO::Model::Graphのフィールドは、
  1. GO::Model::Term
  2. GO::Model::Path
  3. GO::Model::Association
  4. GO::Model::GeneProduct
  5. GO::Model::Relationship
の様子。
ということで、各オブジェクトのフィールドとメソッドを把握しておけば使えるはず。

とりあえず、GO::Model::Graphにあるサンプルコードを試してみる。

# FETCHING GRAPH FROM FILES
use GO::Parser;
my $parser = new GO::Parser({handler=>'obj'});
$parser->parse("gene_ontology.obo"); # ontology
$parser->parse("gene-associations.sgd"); # gene assocs
# get L object
my $graph = $parser->handler->graph;
my $terms = $graph->term_query("/transmembrane/"); # matching terms
foreach my $term (@$terms) {
# find gene products associated to this term
my $assocs = $graph->deep_association_list($term->acc);
printf "Term: %s %s\n", $term->acc, $term->name;
print " Associations (direct and via transitive closure_\n";
foreach my $assoc (@$assocs) {
next if $assoc->is_not;
printf " Assoc evidence: %s to: %s %s\n",
join(';', map {$_->code} @{$assoc->evidence_list}),
$assoc->gene_product->xref->as_str,
$assoc->gene_product->symbol;
}
}

ところが、gene-association.sgdファイルのパースでエラーが出る。
GO::ParserのFormatの項目によると、

go_assoc
Annotations of genes or gene products using GO
Files with prefix "gene-association."

となっているが、実際に、ここにおいてあるファイルは、
gene_association.sgd.gz
このような名前であり、しかもontologyのHandlerが自動的に選択されている様だ。
そこで、

$parser->parse("gene-associations.sgd"); # gene assocs

ここを、

$parser->parse("gene_association.sgd"); # gene assocs

この様に変更したところ動いた。

go-perlサンプルコードを読んでみた

まずは、昨日走らせたサンプルルコードを読んでみる。

tomo$ less go-perl.pl
#!/usr/bin/perl

use GO::Parser;

my $parser = new GO::Parser({handler=>'obj'}); # create parser object
$parser->parse("gene_ontology.obo"); # parse file -> objects
my $graph = $parser->handler->graph; # get L object
my $term = $graph->get_term("GO:0001303"); # fetch a term by ID
printf "Got term: %s %sn", $term->acc, $term->name;
my $ancestor_terms = $graph->get_recursive_parent_terms($term->acc);
foreach my $anc_term (@$ancestor_terms) {
printf " Ancestor term: %s %sn", $anc_term->acc, $anc_term->name;
}

GO::Parserというのがこのモジュールの名前らしい。

my $parser = new GO::Parser({handler=>'obj'}); # create parser object
$parser->parse("gene_ontology.obo"); # parse file -> objects

ここで、GO::parserオブジェクトをGO object modelをhandlerとして作成。そして、"gene_ontology.obo"ファイルをパースして、gene ontologyのデータをGO::Parserオブジェクトに取り込む。
handlerとして選択可能なモデルは、ここにあるGO::Handler::*すべてのようだ。
パース可能なファイルフォーマットは、こちらに記載されている。このサンプルでは、各Gene ontologyの階層関係を記述したgene_ontology.oboファイルを読み込んでいる。

my $graph = $parser->handler->graph; # get L object

ここでは、GO::Parserオブジェクトのhandlerメソッドを呼び出し、得られたGO::Handler::objのgraphメソッドを呼び出して、GO::Model::Graphオブジェクトを得ている。
このGO::Model::Graphオブジェクトに、ファイルから読み出した情報が格納されていることになる。
GO::Model::Graphオブジェクトのメソッドは、こちらに列記されている。

my $term = $graph->get_term("GO:0001303"); # fetch a term by ID

ここでは、GO::Model::Graphオブジェクトのget_termメソッドを使用して、GO IDからGO::Model::Termオブジェクトを獲得し、

printf "Got term: %s %sn", $term->acc, $term->name;

ここで、GO::Model::Termオブジェクトの要素をそれぞれ呼び出して表示する。

要するに、GO::Model::GraphオブジェクトとGO::Model::Termオブジェクトの内容を調べれば、一通り扱えそうだ。

go-perlのインストール

環境:
MacBook(Mac OS X 10.4.11)

go-perlの入手先
http://search.cpan.org/~cmungall/go-perl-0.09/

インストールはCPAN shellから行いました。

sudo perl -MCPAN -e shell
install GO::Parser

途中でData::Stagをインストールするかどうかを聞いてくるので、yesと答えます。
特にエラー無くインストールは終了。

動作確認には、go-perlのdocumentに記載されているサンプルコードを実行してみました。

tomo$ less go-perl.pl
#!/usr/bin/perl

use GO::Parser;

my $parser = new GO::Parser({handler=>'obj'}); # create parser object
$parser->parse("gene_ontology.obo"); # parse file -> objects
my $graph = $parser->handler->graph; # get L object
my $term = $graph->get_term("GO:0001303"); # fetch a term by ID
printf "Got term: %s %sn", $term->acc, $term->name;
my $ancestor_terms = $graph->get_recursive_parent_terms($term->acc);
foreach my $anc_term (@$ancestor_terms) {
printf " Ancestor term: %s %sn", $anc_term->acc, $anc_term->name;
}

こちらから、"gene_ontology.obo"ファイルをダウンロードして来て、上記go-perl.plと同じディレクトリに置いておきます。
http://www.geneontology.org/ontology/gene_ontology.obo

実行結果は以下の通り、

tomo$ perl go-perl.pl
Got term: GO:0001303 nucleolar fragmentation during replicative aging
Ancestor term: GO:0001302 replicative cell aging
Ancestor term: GO:0007569 cell aging
Ancestor term: GO:0007568 aging
Ancestor term: GO:0032502 developmental process
Ancestor term: GO:0008150 biological_process
Ancestor term: GO:0007576 nucleolar fragmentation
Ancestor term: GO:0007000 nucleolus organization and biogenesis
Ancestor term: GO:0006997 nuclear organization and biogenesis
Ancestor term: GO:0006996 organelle organization and biogenesis
Ancestor term: GO:0016043 cellular component organization and biogenesis
Ancestor term: GO:0009987 cellular process
Ancestor term: GO:0008150 biological_process
Ancestor term: GO:0007569 cell aging
Ancestor term: GO:0007568 aging
Ancestor term: GO:0032502 developmental process
Ancestor term: GO:0008150 biological_process

2008年6月1日日曜日

GOに属する遺伝子群の抽出(6)

結局、evidence codeがIEAのGOはすべて除外して登録してみた。
トランスクリプトとの対応で、10297レコード。だいぶ近づいて来た。多分トランスクリプトとタンパク質との重なりが少しあるのであろう。タンパク質コードとの対応表を作ってみる事にする。

GOに属する遺伝子群の抽出(5)

やはり、GOはGene Productに対してつけられているので、具体的にはタンパク質に対してつけられているはず。よって、トランスクリプトとの対応の方が正しいようだ。
いまは、トランスクリプトから引いたGOに対して、親を検索し、親まで含めたすべてのGOをトランスクリプトに関連づけるようにしているが、その際に元となったGOのエビデンスコードをそこから引いた親すべてに付与するようにしてテーブルに格納してみる。

GOに属する遺伝子群の抽出(4)

トランスクリプトでは無く遺伝子とGOを対応させてみたが、やはりレコード数が多い。
考えられることといえば、Humanのみのデータを抽出するか、evidence_codeのIEAを除外してみるかだな。もともとのトランスクリプトはHumanのものだから、それらからひいたGOの親も、Humanのものだと思われるし、そもそもGOのヒエラルキーの上部は、種間で共通にしてあるはず。
とりあえず、今度はevidence codeをテーブルに突っ込んでみて、SQLで検索し様子を見てみることとする。

2008年5月31日土曜日

GOに属する遺伝子群の抽出(3)

という事で、ENSEMBL GENE IDをキーとして、GOをテーブルに格納する事にした。そして、別にENSEMBL Transcript IDとENSEMBL Gene IDの対応をつけるテーブルを作成し、テーブルを結合してENSEMBL Transcript IDからGO番号を取り出すようにしてみる。