SPARQLthon/go comparison
提供:TogoWiki
| 180行: | 180行: | ||
* weighted-tree | * weighted-tree | ||
http://vizuly.io/product/weighted-tree/?demo=d3js | http://vizuly.io/product/weighted-tree/?demo=d3js | ||
| + | |||
| + | = 汎用性 = | ||
| + | == 可視化 == | ||
| + | ツリー構造にも転用できるので可視化の際に汎用性のある作りにして頂きたい。例: [http://biohackathon.org/d3sparql/ d3sparql] | ||
| + | == SPARQLのAPI化 == | ||
| + | SPARQListでクエリ部分をAPI化すれば作ればViewとModelが分けられる [/mw/SPARQList SPARQList] | ||
2017年11月27日 (月) 02:45時点における最新版
目次 |
目的
RefExで複数の遺伝子を列挙する画面において、遺伝子のGOを比較して表示したい。
例えば、選択された遺伝子の中で一つだけ機能がかけ離れたものがあるかどうか。可視化できれば尚可。
使用データセット
遺伝子とGOを紐付けるデータEnsemblで公開されていたため、これを使用。
Emsembl RDF
ダウンロードURL
ftp://ftp.ensembl.org/pub/current_rdf/homo_sapiens/
修正
但し、URLエスケープされて("GO:" => "GO%3A" => "GO%253A")URIとして他のデータと繋がらないものがあるため(EBIに修正依頼済み)置換する。
perl -pi -e "s#GO%253A#GO:#g" homo_sapiens_xrefs.ttl perl -pi -e "s#GO%3A#GO:#g" homo_sapiens_xrefs.ttl
さらにgo.owlとprefixを合わせるため、置換する。
perl -pi -e "s#http://identifiers.org/go/GO:#http://purl.obolibrary.org/obo/GO_#g" homo_sapiens_xrefs.ttl
GO
ダウンロードURL
http://purl.obolibrary.org/obo/go.owl
データロード
isqlでロード実行
//ensembl
log_enable(2,1);
SPARQL CLEAR GRAPH <http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens>;
ld_dir_all('/data/store/rdf/ebi/ensembl/release201707', '*.ttl', 'http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens');
rdf_loader_run();
checkpoint;
//go
log_enable(2, 1);
DB.DBA.RDF_LOAD_RDFXML_MT(file_to_string_output('/data/store/rdf/ebi/ensembl/release201707_fixed/go.owl'), '', 'http://togogenome.org/graph/go');
checkpoint;
SPARQL
A. 遺伝子(geneid:64344)から紐付くGOの一覧を取得する 結果
transcriptからGOへはrdfs:seeAlsoだけではなく、<http://rdf.ebi.ac.uk/terms/ensembl/DIRECT>, <http://rdf.ebi.ac.uk/terms/ensembl/MISC>といったpredicateでも紐づいているけどヨクワカラナイ
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX ncbigene: <http://identifiers.org/ncbigene/>
SELECT DISTINCT ?go
FROM <http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens>
{
?ens_gene rdfs:seeAlso ncbigene:64344 .
?ens_transcript obo:SO_transcribed_from ?ens_gene .
?ens_transcript rdfs:seeAlso ?go .
?go a <http://identifiers.org/go> .
}
B. 遺伝子(geneid:64344)から紐付くcellular_componentのGOの一覧を取得する 結果
検算用 Ensembl biological_process(GO_0008150), cellular_component(GO_0005575), molecular_function(GO_0003674)
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX ncbigene: <http://identifiers.org/ncbigene/>
SELECT DISTINCT ?go
FROM <http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens>
FROM <http://togogenome.org/graph/go>
{
?ens_gene rdfs:seeAlso ncbigene:64344 .
?ens_transcript obo:SO_transcribed_from ?ens_gene .
?ens_transcript rdfs:seeAlso ?go .
?go a <http://identifiers.org/go> ;
rdfs:subClassOf* obo:GO_0005575 .
}
C. 遺伝子(geneid:64344)から紐付くcellular_componentのGO(親GOを含める)一覧を取得する 結果
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX ncbigene: <http://identifiers.org/ncbigene/>
SELECT DISTINCT ?go ?parent_go (STR(?go_label) AS ?label)
FROM <http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens>
FROM <http://togogenome.org/graph/go>
{
?ens_gene rdfs:seeAlso ncbigene:64344 .
?ens_transcript obo:SO_transcribed_from ?ens_gene .
?ens_transcript rdfs:seeAlso ?go .
?go a <http://identifiers.org/go> ;
rdfs:subClassOf* ?parent_go .
?parent_go rdf:type owl:Class .
?go rdfs:subClassOf* obo:GO_0005575 .
GRAPH <http://togogenome.org/graph/go> {
?parent_go rdfs:label ?go_label .
}
} ORDER BY ?go ?parent_go
D. 複数の遺伝子群に紐付くGO(親のGO含む)の一覧と、各GOに紐付く遺伝子個数 結果
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX ncbigene: <http://identifiers.org/ncbigene/>
SELECT ?go (STR(?go_label) AS ?label) (COUNT(DISTINCT ?gene_id) AS ?gene_count) (GROUP_CONCAT(DISTINCT REPLACE(STR(?gene_id), "http://identifiers.org/ncbigene/",""); separator = ",") AS ?gene_ids) ?parent_go
FROM <http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens>
FROM <http://togogenome.org/graph/go>
{
VALUES ?gene_id { ncbigene:64344 ncbigene:7139 }
?ens_gene rdfs:seeAlso ?gene_id .
?ens_transcript obo:SO_transcribed_from ?ens_gene ;
rdfs:seeAlso ?exact_go .
?exact_go a <http://identifiers.org/go> ;
rdfs:subClassOf* ?go .
?go rdf:type owl:Class .
?exact_go rdfs:subClassOf* obo:GO_0005575 .
?go rdfs:subClassOf ?parent_go .
?parent_go rdf:type owl:Class .
GRAPH <http://togogenome.org/graph/go>
{
?go rdfs:label ?go_label .
}
} GROUP BY ?go ?go_label ?parent_go
E. 着目する遺伝子(geneid:64344)のGOのうち、その他の遺伝子(群)のGO(親GOを含める)にはないGOの一覧を取得する 結果
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX ncbigene: <http://identifiers.org/ncbigene/>
SELECT DISTINCT ?go (STR(?go_label) AS ?label)
FROM <http://rdf.ebi.ac.uk/dataset/ensembl/90/homo_sapiens>
FROM <http://togogenome.org/graph/go>
{
{
SELECT DISTINCT ?go
{
VALUES ?gene_id { ncbigene:64344 }
?ens_gene rdfs:seeAlso ?gene_id .
?ens_transcript obo:SO_transcribed_from ?ens_gene ;
rdfs:seeAlso ?go .
?go a <http://identifiers.org/go> ;
rdf:type owl:Class .
?go rdfs:subClassOf* obo:GO_0005575 .
}
}
MINUS
{
SELECT DISTINCT ?go
{
VALUES ?gene_id { ncbigene:7139 }
?ens_gene rdfs:seeAlso ?gene_id .
?ens_transcript obo:SO_transcribed_from ?ens_gene ;
rdfs:seeAlso ?exact_go .
?exact_go a <http://identifiers.org/go> ;
rdfs:subClassOf* ?go .
?go rdf:type owl:Class .
?exact_go rdfs:subClassOf* obo:GO_0005575 .
}
}
GRAPH <http://togogenome.org/graph/go>
{
?go rdfs:label ?go_label .
}
}
可視化の参考例
(メモ程度です)
選択されているGeneに紐付くGOを親GOと共に取得できるので、出現するGOだけの多重継承ツリーを描画できる(クエリ4.4)
どのGO経路をいくつの遺伝子が通っているかをツリーのバスの太さで表現(Sankey diagram)することもできる(クエリ4.4 gene_count)
選択ボックスで着目したい1個の遺伝子をユーザに選択させ、その遺伝子にしか紐づかないGOを強調表示するとか(クエリ4.5)
マルチ選択ボックスで複数の遺伝子をユーザに選択させ、それらの遺伝子のGOが通るパスを強調するとか(クエリ4.4)
- Ancestor Chart
https://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0005861
- Sankey diagram
http://maggielee.net/ga-lawmakers-write-4800-things-mostly-honors/
http://bl.ocks.org/d3noob/raw/5028304/
- weighted-tree
http://vizuly.io/product/weighted-tree/?demo=d3js
汎用性
可視化
ツリー構造にも転用できるので可視化の際に汎用性のある作りにして頂きたい。例: d3sparql
SPARQLのAPI化
SPARQListでクエリ部分をAPI化すれば作ればViewとModelが分けられる SPARQList