PhenIO tutorial
author: Chris Mungall
created: 2022-08-16
This tutorial walks through phenio, the goals are:
to help understand the structure of phenio
to show how to do advanced OAK queries (CLI and programmatic) on PhenIO
to explore semsim techniques
Create an alias
For convenience we will set a bash alias.
This assumes you have built the sqlite version of phenio in the ../../db
folder
NOTE an alternative is:
%alias phenio runoak -i sqlite:obo:phenio
[2]:
%alias phenio runoak -i ../../db/phenio.db
Basic lookup queries
Let’s check it’s working:
[3]:
phenio info HP:0008609
HP:0008609 ! Morphological abnormality of the middle ear (HPO)
[4]:
phenio info "l~abnormality of the middle ear"
HP:0000370 ! Abnormality of the middle ear (HPO)
HP:0004452 ! Abnormality of the middle ear ossicles (HPO)
HP:0008609 ! Morphological abnormality of the middle ear (HPO)
HP:0011452 ! Functional abnormality of the middle ear (HPO)
Exploring the structure of PhenIO
[5]:
phenio relationships HP:0008609
subject predicate object subject_label predicate_label object_label
HP:0008609 rdfs:subClassOf HP:0000370 Morphological abnormality of the middle ear (HPO) None Abnormality of the middle ear (HPO)
HP:0008609 rdfs:subClassOf UPHENO:0021692 Morphological abnormality of the middle ear (HPO) None abnormal middle ear morphology
NOTE I am surprised there is no linkages to Uberon here. Something has gone wrong.
Let’s try a different example
[6]:
phenio relationships HP:0008609 HP:0011453
Here we can see linkages to external ontologies using two relations
We can find out more about these:
[7]:
phenio info UPHENO:0000001 UPHENO:0000003
UPHENO:0000001 ! has phenotype affecting
UPHENO:0000003 ! phenotype has associated entity
Here we can see linkages to external ontologies using two relations
Querying ancestors
We will try finding all ancestors of HP:0008609 (Morphological abnormality of the middle ear)
IMPORTANT in OAK, all graph commands are parameterized by predicate lists. Consult the OAK docs if you don’t understand what this means!
To find all is-a ancestors (i.e. ancestors following SubClassOf between named classes) we use -p i
:
[9]:
phenio ancestors -p i HP:0008609
BFO:0000001 ! entity
BFO:0000002 ! continuant
BFO:0000020 ! specifically dependent continuant
HP:0000001 ! All (HPO)
HP:0000118 ! Phenotypic abnormality (HPO)
HP:0000152 ! Abnormality of head or neck (HPO)
HP:0000234 ! Abnormality of the head (HPO)
HP:0000370 ! Abnormality of the middle ear (HPO)
HP:0000598 ! Abnormality of the ear (HPO)
HP:0008609 ! Morphological abnormality of the middle ear (HPO)
HP:0031703 ! Abnormal ear morphology (HPO)
PATO:0000001 ! quality
UPHENO:0001001 ! Phenotype
UPHENO:0001001 ! phenotype
UPHENO:0001002 ! Phenotypic abnormality
UPHENO:0001003 ! phenotype by ontology source
UPHENO:0001005 ! abnormal phenotype by ontology source
UPHENO:0002536 ! abnormal anatomical entity
UPHENO:0002764 ! abnormal craniocervical region
UPHENO:0002844 ! abnormal head
UPHENO:0002903 ! abnormal ear
UPHENO:0003017 ! abnormal middle ear
UPHENO:0015280 ! abnormal anatomical entity morphology in the independent continuant
UPHENO:0020584 ! abnormal anatomical entity morphology
UPHENO:0021692 ! abnormal middle ear morphology
UPHENO:0075696 ! abnormal anatomical entity
UPHENO:0076692 ! abnormal anatomical entity morphology
UPHENO:0076730 ! abnormal ear morphology
UPHENO:0081581 ! abnormal multicellular organism morphology
Next we will generate a visualization from this using the viz
command:
[10]:
phenio viz -p i HP:0008609 -o output/HP_0008609.png
Note we are using the default OAK stylesheet which colors Upheno in black, HPO in blue-green, etc. For more info on visualization and stylesheets see OboGraphViz
siblings
Next we will explore siblings. Again, we parameterize the predicate list to avoid flooding results:
[10]:
phenio siblings -p i HP:0008609
HP:0000388 ! Otitis media (HPO)
HP:0008609 ! Morphological abnormality of the middle ear (HPO)
HP:0011452 ! Functional abnormality of the middle ear (HPO)
HP:0040090 ! Abnormality of the tympanic membrane (HPO)
HP:0040099 ! Abnormality of the round window (HPO)
HP:0040100 ! Abnormality of the vestibular window (HPO)
HP:0040115 ! Abnormality of the Eustachian tube (HPO)
HP:0040262 ! Glue ear (HPO)
HP:0040268 ! Recurrent infections of the middle ear (HPO)
HP:0100799 ! Neoplasm of the middle ear (HPO)
MP:0000049 ! abnormal middle ear morphology (MPO)
XPO:0102637 ! abnormal middle ear morphology (XPO)
let’s take a closer look at some of these siblings.
the viz
command, like most commands in OAK, takes as argument an open ended list of queries:
[11]:
phenio viz -p i HP:0008609 MP:0000049 -o output/HP_0008609_MP_0000049.png
[12]:
phenio descendants -p i "abnormal middle ear morphology (MPO)"
MP:0000029 ! abnormal malleus morphology (MPO)
MP:0000030 ! abnormal tympanic ring morphology (MPO)
MP:0000040 ! absent middle ear ossicles (MPO)
MP:0000049 ! abnormal middle ear morphology (MPO)
MP:0003110 ! absent malleus processus brevis (MPO)
MP:0003138 ! absent tympanic ring (MPO)
MP:0003330 ! abnormal auditory tube morphology (MPO)
MP:0003739 ! dense middle ear ossicles (MPO)
MP:0003740 ! fusion of middle ear ossicles (MPO)
MP:0004204 ! absent stapes (MPO)
MP:0004290 ! abnormal stapes footplate morphology (MPO)
MP:0004318 ! absent incus (MPO)
MP:0004319 ! absent malleus (MPO)
MP:0004479 ! abnormal oval window morphology (MPO)
MP:0004480 ! abnormal round window morphology (MPO)
MP:0004541 ! absent auditory tube (MPO)
MP:0004665 ! abnormal stapedial artery morphology (MPO)
MP:0004666 ! absent stapedial artery (MPO)
MP:0005105 ! abnormal middle ear ossicle morphology (MPO)
MP:0005106 ! abnormal incus morphology (MPO)
MP:0005107 ! abnormal stapes morphology (MPO)
MP:0006018 ! abnormal tympanic membrane morphology (MPO)
MP:0006019 ! absent tympanic membrane (MPO)
MP:0006020 ! decreased tympanic ring size (MPO)
MP:0008372 ! small malleus (MPO)
MP:0008373 ! short malleus (MPO)
MP:0008374 ! abnormal malleus manubrium morphology (MPO)
MP:0008375 ! short malleus manubrium (MPO)
MP:0008376 ! small malleus manubrium (MPO)
MP:0008377 ! absent malleus manubrium (MPO)
MP:0008378 ! small malleus processus brevis (MPO)
MP:0008379 ! absent malleus head (MPO)
MP:0008380 ! abnormal gonial bone morphology (MPO)
MP:0008381 ! absent gonial bone (MPO)
MP:0008382 ! gonial bone hypoplasia (MPO)
MP:0008383 ! enlarged gonial bone (MPO)
MP:0010324 ! abnormal malleus processus brevis morphology (MPO)
MP:0010325 ! abnormal malleus head morphology (MPO)
MP:0010326 ! malleus hypoplasia (MPO)
MP:0010327 ! abnormal malleus neck morphology (MPO)
MP:0010328 ! thin malleus neck (MPO)
MP:0013871 ! abnormal stapedial artery topology (MPO)
MP:0020900 ! abnormal middle ear epithelium morphology (MPO)
MP:0020901 ! abnormal middle ear goblet cell morphology (MPO)
MP:0020902 ! abnormal middle ear goblet cell number (MPO)
MP:0020903 ! increased middle ear goblet cell number (MPO)
MP:0020904 ! decreased middle ear goblet cell number (MPO)
MP:0030084 ! tympanic ring hypoplasia (MPO)
MP:0030106 ! small incus (MPO)
MP:0030107 ! incus hypoplasia (MPO)
MP:0030110 ! incudomalleolar fusion (MPO)
MP:0030123 ! small middle ear ossicles (MPO)
MP:0030124 ! middle ear ossicle hypoplasia (MPO)
MP:0030125 ! small gonial bone (MPO)
MP:0030127 ! small stapes (MPO)
MP:0030128 ! stapes hypoplasia (MPO)
MP:0030154 ! abnormal tympanic cavity morphology (MPO)
MP:0030155 ! absent tympanic cavity (MPO)
MP:0030156 ! abnormal tympanic cavity muscle morphology (MPO)
MP:0030157 ! abnormal stapedius muscle morphology (MPO)
MP:0030158 ! absent stapedius muscle (MPO)
MP:0030159 ! abnormal tensor tympani muscle morphology (MPO)
MP:0030187 ! abnormal epitympanic recess morphology (MPO)
MP:0030213 ! gonial bone hyperplasia (MPO)
MP:0030226 ! middle ear polyps (MPO)
MP:0030227 ! abnormal tubotympanic recess morphology (MPO)
MP:0030228 ! absent tubotympanic recess (MPO)
MP:0030321 ! abnormal tegmen tympani morphology (MPO)
MP:0030394 ! abnormal incus short process morphology (MPO)
MP:0030395 ! absent incus short process (MPO)
MP:0030396 ! abnormal incus long process morphology (MPO)
MP:0030397 ! abnormal incus lenticular process morphology (MPO)
MP:0030398 ! absent incus lenticular process (MPO)
MP:0030399 ! abnormal incus body morphology (MPO)
MP:0030400 ! abnormal stapes annular ligament morphology (MPO)
MP:0030401 ! absent stapes annular ligament (MPO)
MP:0030402 ! abnormal stapes head morphology (MPO)
MP:0030403 ! absent stapes head (MPO)
MP:0030404 ! abnormal stapes obturator foramen morphology (MPO)
MP:0030405 ! small stapes obturator foramen (MPO)
MP:0030406 ! absent stapes obturator foramen (MPO)
MP:0030407 ! abnormal stapes crus morpholgy (MPO)
MP:0030408 ! abnormal stapes posterior crus morphology (MPO)
MP:0030409 ! abnormal stapes anterior crus morphology (MPO)
MP:0030410 ! middle ear effusion (MPO)
MP:0030411 ! small round window (MPO)
MP:0030412 ! absent round window (MPO)
MP:0030413 ! tympanic membrane retraction (MPO)
MP:0030414 ! tympanic membrane perforation (MPO)
MP:0030465 ! absent oval window (MPO)
Pairwise term similarity
Next we will explore the nascent semantic similarity functions in OAK
Note that the data model and signatures may change slightly here in the future.
Once again, it is important to understand how OAK handles graphs - all similarity methods are parameterized by predicate lists. Let’s start with the simple case of is-a hierarchies:
[13]:
phenio similarity -p i HP:0000388 MP:0030395
subject_id: HP:0000388
object_id: MP:0030395
ancestor_id: UPHENO:0003017
ancestor_information_content: 12.860723034493532
jaccard_similarity: 0.22077922077922077
phenodigm_score: 1.6850461151591245
TODOs:
allow calculation of IC from background annotations
add an
--autolabel
option (other OAK commands have this)
to see what the MRCA is:
[15]:
phenio info UPHENO:0003017
UPHENO:0003017 ! abnormal middle ear
[16]:
# this is how we would do all-by-all
#phenio all-similarity -p i,p --set1 i^HP: --set2 i^MP: --ic-minimum 3.0 --jaccard-minimum 0.65
[17]:
phenio tree -p i HP:0000388 MP:0030395 --max-hops 2
* [] UPHENO:0003017 ! abnormal middle ear
* [i] HP:0000370 ! Abnormality of the middle ear (HPO)
* [i] **HP:0000388 ! Otitis media (HPO)**
* [] HP:0031703 ! Abnormal ear morphology (HPO)
* [i] HP:0000370 ! Abnormality of the middle ear (HPO)
* [i] **HP:0000388 ! Otitis media (HPO)**
* [] HP:0012647 ! Abnormal inflammatory response (HPO)
* [i] HP:0012649 ! Increased inflammatory response (HPO)
* [i] **HP:0000388 ! Otitis media (HPO)**
* [] UPHENO:0074782 ! increased biological_process in middle ear
* [i] UPHENO:0074629 ! increased inflammatory response in middle ear
* [i] **HP:0000388 ! Otitis media (HPO)**
* [] UPHENO:0074685 ! increased inflammatory response in independent continuant
* [i] UPHENO:0074629 ! increased inflammatory response in middle ear
* [i] **HP:0000388 ! Otitis media (HPO)**
* [] MP:0005106 ! abnormal incus morphology (MPO)
* [i] MP:0030394 ! abnormal incus short process morphology (MPO)
* [i] **MP:0030395 ! absent incus short process (MPO)**
Using other ontologies
We can parameterize the similarity calculation to make use of is-a (i), part-of (p) (which typically traverse within an ontology), and UPHENO:0000003 (phenotype has associated entity) (which traverses “sideways” from a phenotype ontology to an “entity” ontology).
Here we will ask for the similarity between the concept of the stapes bone and the concept of Abnormality of the incus:
[18]:
phenio similarity -p i,p,UPHENO:0000003 UBERON:0001687 HP:0011453
subject_id: UBERON:0001687
object_id: HP:0011453
ancestor_id: UBERON:0001686
ancestor_information_content: 12.16586147141704
jaccard_similarity: 0.4329896907216495
phenodigm_score: 2.2951454411150713
[20]:
phenio info UBERON:0001686
UBERON:0001686 ! auditory ossicle bone
[19]:
phenio viz HP:0011453 -p i,UPHENO:0000003 -o output/with-uberon.png
[ ]: