from ontobio.ontol_factory import OntologyFactory
# Create ontology object, for mammalian phenotype ontology
# Transparently uses remote SPARQL service.
# (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do
# not re-execute cell)
ofactory = OntologyFactory()
ont = ofactory.create('mp')
from ontobio.assoc_factory import AssociationSetFactory
MOUSE = 'NCBITaxon:10090'
# Create association set
# Transparently uses remote Monarch service.
# (May take a few seconds to run first time, Jupyter will show '*'. BE PATIENT, do
# not re-execute cell)
afactory = AssociationSetFactory()
aset = afactory.create(ontology=ont,
subject_category='gene',
object_category='phenotype',
taxon=MOUSE)
[p1] = ont.search("abnormal hippocampus morphology")
[p2] = ont.search("abnormal glucose homeostasis")
genes = aset.query([p1, p2])
len(genes)
12
genes
['MGI:88227', 'MGI:107164', 'MGI:102548', 'MGI:1926884', 'MGI:88145', 'MGI:97362', 'MGI:98331', 'MGI:102709', 'MGI:109583', 'MGI:103555', 'MGI:2145264', 'MGI:1929213']
["{} '{}'".format(g, aset.label(g)) for g in genes]
["MGI:88227 'C3'", "MGI:107164 'Ppp3ca'", "MGI:102548 'Tsc2'", "MGI:1926884 'Huwe1'", "MGI:88145 'Bdnf'", "MGI:97362 'Nos3'", "MGI:98331 'Snap25'", "MGI:102709 'Cav1'", "MGI:109583 'Pten'", "MGI:103555 'Clcn3'", "MGI:2145264 'Nhlrc1'", "MGI:1929213 'Zbtb20'"]
z, xlabels, ylabels = aset.similarity_matrix(genes, genes)
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
trace = go.Heatmap(z=-np.array(z),
x=xlabels,
y=ylabels)
py.iplot([trace], filename='labelled-heatmap')