In [2]:
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')
In [3]:
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)
In [9]:
[p1] = ont.search("abnormal hippocampus morphology")
[p2] = ont.search("abnormal glucose homeostasis")
In [10]:
genes = aset.query([p1, p2])
In [11]:
len(genes)
Out[11]:
In [12]:
genes
Out[12]:
In [14]:
["{} '{}'".format(g, aset.label(g)) for g in genes]
Out[14]:
In [28]:
z, xlabels, ylabels = aset.similarity_matrix(genes, genes)
In [29]:
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
In [35]:
trace = go.Heatmap(z=-np.array(z),
x=xlabels,
y=ylabels)
In [36]:
py.iplot([trace], filename='labelled-heatmap')
Out[36]:
In [ ]: