{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## Perform enrichment test using phenotype ontology\n", "\n", "Given a file of genes:\n", "\n", "```\n", "$ head data/rp-genes.tsv\n", "NCBIGene:6295 SAG\n", "NCBIGene:1258 CNGB1\n", "NCBIGene:3614 IMPDH1\n", "NCBIGene:26121 PRPF31\n", "```\n", "\n", "The example file here is derived from a Monarch query for all retinitis pigmentosa genes.\n", "\n", "We want to test each class in HPO to see if it is enriched for genes in this set.\n", "\n", "First we need to parse the gene Ids in the file" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['NCBIGene:6295',\n", " 'NCBIGene:1258',\n", " 'NCBIGene:3614',\n", " 'NCBIGene:26121',\n", " 'NCBIGene:7275',\n", " 'NCBIGene:55857',\n", " 'NCBIGene:79797',\n", " 'NCBIGene:10594',\n", " 'NCBIGene:64218',\n", " 'NCBIGene:7401']" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "## Parse ids from file\n", "file = open(\"data/rp-genes.tsv\", \"r\")\n", "gene_ids = [row.split(\"\\t\")[0] for row in file]\n", "\n", "## show first 10 IDs:\n", "gene_ids[:10]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Create an ontology factory in order to fetch HPO\n", "from ontobio.ontol_factory import OntologyFactory\n", "\n", "ofactory = OntologyFactory()\n", "ont = ofactory.create(\"hp\") ## Load HP. Note the first time this runs Jupyter will show '*' - be patient" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Create an association factory to get gene-phenotype associations\n", "from ontobio.assoc_factory import AssociationSetFactory\n", "afactory = AssociationSetFactory()\n", "## Load Associations from Monarch. Note the first time this runs Jupyter will show '*' - be patient\n", "aset = afactory.create(ontology=ont, subject_category='gene', object_category='phenotype', taxon='NCBITaxon:9606')\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Run enrichment tests using all classes in ontology\n", "enr = aset.enrichment_test(subjects=gene_ids, threshold=0.00005, labels=True)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1.24e-123 HP:0030466 Abnormal full-field electroretinogram \n", "4.25e-111 HP:0000512 Abnormal electroretinogram \n", "6.94e-104 HP:0000546 Retinal degeneration \n", "1.28e-103 HP:0030453 Abnormal visual electrophysiology \n", "3.03e-102 HP:0008323 Abnormal light- and dark-adapted electroretinogram\n", "7.84e-97 HP:0000608 Macular degeneration \n", "1.08e-95 HP:0001103 Abnormality of the macula \n", "1.66e-93 HP:0000556 Retinal dystrophy \n", "3.85e-90 HP:0001147 Retinal exudate \n", "5.53e-90 HP:0000662 Nyctalopia \n", "4.51e-89 HP:0007675 Progressive night blindness \n", "1.37e-88 HP:0008020 Progressive cone degeneration \n", "1.55e-85 HP:0007703 Abnormality of retinal pigmentation \n", "2.43e-84 HP:0030506 Yellow/white lesions of the retina \n", " 9.5e-84 HP:0200065 Chorioretinal degeneration \n", "4.22e-83 HP:0001730 Progressive hearing impairment \n", "2.91e-81 HP:0030469 Abnormal dark-adapted electroretinogram \n", "2.91e-81 HP:0030470 Abnormal dark-adapted bright flash electroretinogram\n", "2.91e-81 HP:0030478 Abnormal amplitude of dark-adapted bright flash electroretinogram\n", "2.91e-81 HP:0007984 Electronegative electroretinogram \n" ] } ], "source": [ "## Show first 20 results\n", "for r in enr[:20]:\n", " print(\"{:8.3g} {} {:40s}\".format(r['p'],r['c'],str(r['n'])))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Given that the initial gene set is for retinitis pigmentosa genes, it's not surprising that enriched phenotype\n", "terms are related to retinal degeneration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Viewing Results\n", "\n", "We can use different visualization options to see the enriched terms. First we will show a simple tree view\n" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Get all enriched class Ids\n", "terms = [r['c'] for r in enr]" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": true }, "outputs": [], "source": [ "## Create a minimal slim of HPO consisting of enriched terms,\n", "## with non-informative intermediate nodes removed\n", "from ontobio.slimmer import get_minimal_subgraph\n", "g = get_minimal_subgraph(ont.get_graph(), terms)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ". HP:0000118 ! Phenotypic abnormality\n", " % HP:0000478 ! Abnormality of the eye * \n", " % HP:0012372 ! Abnormal eye morphology * \n", " % HP:0012374 ! Abnormality of the globe * \n", " % HP:0100887 ! Abnormality of globe size * \n", " % HP:0000568 ! Microphthalmia * \n", " % HP:0008056 ! Aplasia/Hypoplasia affecting the eye * \n", " % HP:0000568 ! Microphthalmia * \n", " % HP:0008057 ! Aplasia/Hypoplasia affecting the fundus * \n", " % HP:0008061 ! Aplasia/Hypoplasia of the retina * \n", " % HP:0007770 ! Hypoplasia of the retina * \n", " % HP:0008047 ! Abnormality of the vasculature of the eye * \n", " % HP:0008046 ! Abnormality of the retinal vasculature * \n", " % HP:0007843 ! Attenuation of retinal blood vessels * \n", " % HP:0004329 ! Abnormality of the posterior segment of the globe * \n", " % HP:0001098 ! Abnormality of the fundus * \n", " % HP:0000479 ! Abnormality of the retina * \n", " % HP:0000532 ! Chorioretinal abnormality * \n", " % HP:0200065 ! Chorioretinal degeneration * \n", " % HP:0000533 ! Chorioretinal atrophy * \n", " % HP:0011958 ! Retinal perforation * \n", " % HP:0011530 ! Retinal hole * \n", " % HP:0000546 ! Retinal degeneration * \n", " % HP:0000547 ! Tapetoretinal degeneration * \n", " % HP:0007893 ! Progressive retinal degeneration * \n", " % HP:0007769 ! Peripheral retinal degeneration * \n", " % HP:0000655 ! Vitreoretinal degeneration * \n", " % HP:0001105 ! Retinal atrophy * \n", " % HP:0008020 ! Progressive cone degeneration * \n", " % HP:0008061 ! Aplasia/Hypoplasia of the retina * \n", " % HP:0007770 ! Hypoplasia of the retina * \n", " % HP:0007703 ! Abnormality of retinal pigmentation * \n", " % HP:0007894 ! Hypopigmentation of the fundus * \n", " % HP:0000580 ! Pigmentary retinopathy * \n", " % HP:0000510 ! Rod-cone dystrophy * \n", " % HP:0001146 ! Pigmentary retinal degeneration * \n", " % HP:0007737 ! Bone spicule pigmentation of the retina * \n", " % HP:0000488 ! Retinopathy * \n", " % HP:0001103 ! Abnormality of the macula * \n", " % HP:0007754 ! Macular dystrophy * \n", " % HP:0000608 ! Macular degeneration * \n", " % HP:0007868 ! Age-related macular degeneration * \n", " % HP:0030498 ! Macular thickening * \n", " % HP:0040049 ! Macular edema * \n", " % HP:0011505 ! Cystoid macular edema * \n", " % HP:0030506 ! Yellow/white lesions of the retina * \n", " % HP:0001147 ! Retinal exudate * \n", " % HP:0007898 ! Exudative retinopathy * \n", " % HP:0011532 ! Subretinal exudate * \n", " % HP:0012777 ! Retinal neoplasm * \n", " % HP:0009919 ! Retinoblastoma * \n", " % HP:0000556 ! Retinal dystrophy * \n", " % HP:0000548 ! Cone/cone-rod dystrophy * \n", " % HP:0000510 ! Rod-cone dystrophy * \n", " % HP:0007754 ! Macular dystrophy * \n", " % HP:0008046 ! Abnormality of the retinal vasculature * \n", " % HP:0007843 ! Attenuation of retinal blood vessels * \n", " % HP:0000587 ! Abnormality of the optic nerve * \n", " % HP:0012795 ! Abnormality of the optic disc * \n", " % HP:0000648 ! Optic atrophy * \n", " % HP:0000543 ! Optic disc pallor * \n", " % HP:0008057 ! Aplasia/Hypoplasia affecting the fundus * \n", " % HP:0008061 ! Aplasia/Hypoplasia of the retina * \n", " % HP:0007770 ! Hypoplasia of the retina * \n", " % HP:0000610 ! Abnormality of the choroid * \n", " % HP:0000532 ! Chorioretinal abnormality * \n", " % HP:0200065 ! Chorioretinal degeneration * \n", " % HP:0000533 ! Chorioretinal atrophy * \n", " % HP:0000553 ! Abnormality of the uvea * \n", " % HP:0000610 ! Abnormality of the choroid * \n", " % HP:0000532 ! Chorioretinal abnormality * \n", " % HP:0200065 ! Chorioretinal degeneration * \n", " % HP:0000533 ! Chorioretinal atrophy * \n", " % HP:0004328 ! Abnormality of the anterior segment of the globe * \n", " % HP:0000517 ! Abnormality of the lens * \n", " % HP:0000518 ! Cataract * \n", " % HP:0000481 ! Abnormality of the cornea * \n", " % HP:0011486 ! Abnormality of corneal thickness * \n", " % HP:0100689 ! Decreased corneal thickness * \n", " % HP:0000563 ! Keratoconus * \n", " % HP:0100691 ! Abnormality of the curvature of the cornea * \n", " % HP:0100692 ! Increased corneal curvature * \n", " % HP:0000563 ! Keratoconus * \n", " % HP:0100012 ! Neoplasm of the eye * \n", " % HP:0012777 ! Retinal neoplasm * \n", " % HP:0009919 ! Retinoblastoma * \n", " % HP:0012373 ! Abnormal eye physiology * \n", " % HP:0030637 ! Cone dysfunction syndrome * \n", " % HP:0000551 ! Abnormality of color vision * \n", " % HP:0000496 ! Abnormality of eye movement * \n", " % HP:0012547 ! Abnormal involuntary eye movements * \n", " % HP:0000639 ! Nystagmus * \n", " % HP:0000597 ! Ophthalmoparesis * \n", " % HP:0000602 ! Ophthalmoplegia * \n", " % HP:0000504 ! Abnormality of vision * \n", " % HP:0000505 ! Visual impairment * \n", " % HP:0000618 ! Blindness * \n", " % HP:0007875 ! Congenital blindness * \n", " % HP:0000662 ! Nyctalopia * \n", " % HP:0007675 ! Progressive night blindness * \n", " % HP:0000613 ! Photophobia * \n", " % HP:0001123 ! Visual field defect * \n", " % HP:0001133 ! Constriction of peripheral visual field * \n", " % HP:0000551 ! Abnormality of color vision * \n", " % HP:0007663 ! Reduced visual acuity * \n", " % HP:0000572 ! Visual loss * \n", " % HP:0000529 ! Progressive visual loss * \n", " % HP:0000501 ! Glaucoma * \n", " % HP:0030453 ! Abnormal visual electrophysiology * \n", " % HP:0000512 ! Abnormal electroretinogram * \n", " % HP:0030466 ! Abnormal full-field electroretinogram * \n", " % HP:0008323 ! Abnormal light- and dark-adapted electroretinogram * \n", " % HP:0000654 ! Decreased light- and dark-adapted electroretinogram amplitude * \n", " % HP:0030469 ! Abnormal dark-adapted electroretinogram * \n", " % HP:0030470 ! Abnormal dark-adapted bright flash electroretinogram * \n", " % HP:0030478 ! Abnormal amplitude of dark-adapted bright flash electroretinogram * \n", " % HP:0007984 ! Electronegative electroretinogram * \n", " % HP:0000550 ! Undetectable electroretinogram * \n", " % HP:0040064 ! Abnormality of limbs * \n", " % HP:0040068 ! Abnormality of limb bone * \n", " % HP:0002813 ! Abnormality of limb bone morphology * \n", " % HP:0045060 ! Aplasia/hypoplasia involving bones of the extremities * \n", " % HP:0006496 ! Aplasia/hypoplasia involving bones of the upper limbs * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0011297 ! Abnormality of digit * \n", " % HP:0010442 ! Polydactyly * \n", " % HP:0009815 ! Aplasia/hypoplasia of the extremities * \n", " % HP:0009826 ! Limb undergrowth * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0045060 ! Aplasia/hypoplasia involving bones of the extremities * \n", " % HP:0006496 ! Aplasia/hypoplasia involving bones of the upper limbs * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0002817 ! Abnormality of the upper limb * \n", " % HP:0006496 ! Aplasia/hypoplasia involving bones of the upper limbs * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0000598 ! Abnormality of the ear * \n", " % HP:0000370 ! Abnormality of the middle ear * \n", " % HP:0011452 ! Functional abnormality of the middle ear * \n", " % HP:0000405 ! Conductive hearing impairment * \n", " % HP:0000364 ! Hearing abnormality * \n", " % HP:0000365 ! Hearing impairment * \n", " % HP:0012714 ! Severe hearing impairment * \n", " % HP:0008625 ! Severe sensorineural hearing impairment * \n", " % HP:0000405 ! Conductive hearing impairment * \n", " % HP:0000407 ! Sensorineural hearing impairment * \n", " % HP:0008625 ! Severe sensorineural hearing impairment * \n", " % HP:0000408 ! Progressive sensorineural hearing impairment * \n", " % HP:0008527 ! Congenital sensorineural hearing impairment * \n", " % HP:0001730 ! Progressive hearing impairment * \n", " % HP:0000408 ! Progressive sensorineural hearing impairment * \n", " % HP:0000359 ! Abnormality of the inner ear * \n", " % HP:0011389 ! Functional abnormality of the inner ear * \n", " % HP:0000407 ! Sensorineural hearing impairment * \n", " % HP:0008625 ! Severe sensorineural hearing impairment * \n", " % HP:0000408 ! Progressive sensorineural hearing impairment * \n", " % HP:0008527 ! Congenital sensorineural hearing impairment * \n", " % HP:0002664 ! Neoplasm * \n", " % HP:0011793 ! Neoplasm by anatomical site * \n", " % HP:0100012 ! Neoplasm of the eye * \n", " % HP:0012777 ! Retinal neoplasm * \n", " % HP:0009919 ! Retinoblastoma * \n", " % HP:0011792 ! Neoplasm by histology * \n", " % HP:0030060 ! Nervous tissue neoplasm * \n", " % HP:0030061 ! Neuroectodermal neoplasm * \n", " % HP:0030063 ! Neuroepithelial neoplasm * \n", " % HP:0009919 ! Retinoblastoma * \n", " % HP:0002898 ! Embryonal neoplasm * \n", " % HP:0009919 ! Retinoblastoma * \n", " % HP:0000119 ! Abnormality of the genitourinary system * \n", " % HP:0010935 ! Abnormality of the upper urinary tract * \n", " % HP:0000077 ! Abnormality of the kidney * \n", " % HP:0012210 ! Abnormal renal morphology * \n", " % HP:0100957 ! Abnormality of the renal medulla * \n", " % HP:0000090 ! Nephronophthisis * \n", " % HP:0000078 ! Abnormality of the genital system * \n", " % HP:0000080 ! Abnormality of reproductive system physiology * \n", " % HP:0000135 ! Hypogonadism * \n", " % HP:0012243 ! Abnormal genital system morphology * \n", " % HP:0000812 ! Abnormal internal genitalia * \n", " % HP:0000008 ! Abnormality of female internal genitalia * \n", " % HP:0000140 ! Abnormality of the menstrual cycle * \n", " % HP:0100608 ! Metrorrhagia * \n", " % HP:0010461 ! Abnormality of the male genitalia * \n", " % HP:0000032 ! Abnormality of male external genitalia * \n", " % HP:0000036 ! Abnormality of the penis * \n", " % HP:0008736 ! Hypoplasia of penis * \n", " % HP:0000035 ! Abnormality of the testis * \n", " % HP:0010460 ! Abnormality of the female genitalia * \n", " % HP:0000008 ! Abnormality of female internal genitalia * \n", " % HP:0000140 ! Abnormality of the menstrual cycle * \n", " % HP:0100608 ! Metrorrhagia * \n", " % HP:0000811 ! Abnormal external genitalia * \n", " % HP:0000032 ! Abnormality of male external genitalia * \n", " % HP:0000036 ! Abnormality of the penis * \n", " % HP:0008736 ! Hypoplasia of penis * \n", " % HP:0000035 ! Abnormality of the testis * \n", " % HP:0003241 ! External genital hypoplasia * \n", " % HP:0000050 ! Hypoplastic male external genitalia * \n", " % HP:0008736 ! Hypoplasia of penis * \n", " % HP:0001507 ! Growth abnormality * \n", " % HP:0000002 ! Abnormality of body height * \n", " % HP:0004322 ! Short stature * \n", " % HP:0001510 ! Growth delay * \n", " % HP:0004322 ! Short stature * \n", " % HP:0004323 ! Abnormality of body weight * \n", " % HP:0004324 ! Increased body weight * \n", " % HP:0001513 ! Obesity * \n", " % HP:0000818 ! Abnormality of the endocrine system * \n", " % HP:0000819 ! Diabetes mellitus * \n", " % HP:0005978 ! Type II diabetes mellitus * \n", " % HP:0008373 ! Puberty and gonadal disorders * \n", " % HP:0000135 ! Hypogonadism * \n", " % HP:0000858 ! Menstrual irregularities * \n", " % HP:0000140 ! Abnormality of the menstrual cycle * \n", " % HP:0100608 ! Metrorrhagia * \n", " % HP:0003117 ! Abnormality of circulating hormone level * \n", " % HP:0040214 ! Abnormal insulin level * \n", " % HP:0040215 ! Abnormal circulating insulin level * \n", " % HP:0000842 ! Hyperinsulinemia * \n", " % HP:0002597 ! Abnormality of the vasculature * \n", " % HP:0008047 ! Abnormality of the vasculature of the eye * \n", " % HP:0008046 ! Abnormality of the retinal vasculature * \n", " % HP:0007843 ! Attenuation of retinal blood vessels * \n", " % HP:0001574 ! Abnormality of the integument * \n", " % HP:0000951 ! Abnormality of the skin * \n", " % HP:0011121 ! Abnormality of skin morphology * \n", " % HP:0001000 ! Abnormality of skin pigmentation * \n", " % HP:0001070 ! Mottled pigmentation * \n", " % HP:0011354 ! Generalized abnormality of skin * \n", " % HP:0000987 ! Atypical scarring of skin * \n", " % HP:0001939 ! Abnormality of metabolism/homeostasis * \n", " % HP:0011032 ! Abnormality of fluid regulation * \n", " % HP:0000969 ! Edema * \n", " % HP:0040049 ! Macular edema * \n", " % HP:0011505 ! Cystoid macular edema * \n", " % HP:0003119 ! Abnormality of lipid metabolism * \n", " % HP:0003107 ! Abnormality of cholesterol metabolism * \n", " % HP:0010979 ! Abnormality of the level of lipoprotein cholesterol * \n", " % HP:0010981 ! Hypolipoproteinemia * \n", " % HP:0003563 ! Hypobetalipoproteinemia * \n", " % HP:0008181 ! Abetalipoproteinemia * \n", " % HP:0011013 ! Abnormality of carbohydrate metabolism/homeostasis * \n", " % HP:0011014 ! Abnormal glucose homeostasis * \n", " % HP:0000819 ! Diabetes mellitus * \n", " % HP:0005978 ! Type II diabetes mellitus * \n", " % HP:0000842 ! Hyperinsulinemia * \n", " % HP:0000707 ! Abnormality of the nervous system * \n", " % HP:0012639 ! Abnormality of nervous system morphology * \n", " % HP:0000759 ! Abnormal peripheral nervous system morphology * \n", " % HP:0009830 ! Peripheral neuropathy * \n", " % HP:0012757 ! Abnormal neuron morphology * \n", " % HP:0002450 ! Abnormal motor neuron morphology * \n", " % HP:0007373 ! Motor neuron atrophy * \n", " % HP:0007354 ! Amyotrophic lateral sclerosis * \n", " % HP:0002011 ! Morphological abnormality of the central nervous system * \n", " % HP:0011282 ! Abnormality of hindbrain morphology * \n", " % HP:0011283 ! Abnormality of the metencephalon * \n", " % HP:0001317 ! Abnormality of the cerebellum * \n", " % HP:0001251 ! Ataxia * \n", " % HP:0007367 ! Atrophy/Degeneration affecting the central nervous system * \n", " % HP:0007373 ! Motor neuron atrophy * \n", " % HP:0007354 ! Amyotrophic lateral sclerosis * \n", " % HP:0002180 ! Neurodegeneration * \n", " % HP:0100705 ! Abnormality of the glial cells * \n", " % HP:0002171 ! Gliosis * \n", " % HP:0012638 ! Abnormality of nervous system physiology * \n", " % HP:0001250 ! Seizures * \n", " % HP:0012759 ! Neurodevelopmental abnormality * \n", " % HP:0001249 ! Intellectual disability * \n", " % HP:0012758 ! Neurodevelopmental delay * \n", " % HP:0001263 ! Global developmental delay * \n", " % HP:0011442 ! Abnormality of central motor function * \n", " % HP:0011443 ! Abnormality of coordination * \n", " % HP:0001251 ! Ataxia * \n", " % HP:0002493 ! Upper motor neuron dysfunction * \n", " % HP:0001347 ! Hyperreflexia * \n", " % HP:0000708 ! Behavioral abnormality * \n", " % HP:0000613 ! Photophobia * \n", " % HP:0000924 ! Abnormality of the skeletal system * \n", " % HP:0011842 ! Abnormality of skeletal morphology * \n", " % HP:0011844 ! Abnormal appendicular skeleton morphology * \n", " % HP:0002813 ! Abnormality of limb bone morphology * \n", " % HP:0045060 ! Aplasia/hypoplasia involving bones of the extremities * \n", " % HP:0006496 ! Aplasia/hypoplasia involving bones of the upper limbs * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0011297 ! Abnormality of digit * \n", " % HP:0010442 ! Polydactyly * \n", " % HP:0009115 ! Aplasia/hypoplasia involving the skeleton * \n", " % HP:0009815 ! Aplasia/hypoplasia of the extremities * \n", " % HP:0009826 ! Limb undergrowth * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0045060 ! Aplasia/hypoplasia involving bones of the extremities * \n", " % HP:0006496 ! Aplasia/hypoplasia involving bones of the upper limbs * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0040068 ! Abnormality of limb bone * \n", " % HP:0002813 ! Abnormality of limb bone morphology * \n", " % HP:0045060 ! Aplasia/hypoplasia involving bones of the extremities * \n", " % HP:0006496 ! Aplasia/hypoplasia involving bones of the upper limbs * \n", " % HP:0009824 ! Upper limb undergrowth * \n", " % HP:0011297 ! Abnormality of digit * \n", " % HP:0010442 ! Polydactyly * \n", " % HP:0003549 ! Abnormality of connective tissue * \n", " % HP:0100699 ! Scarring * \n", " % HP:0000987 ! Atypical scarring of skin * \n", " % HP:0001324 ! Muscle weakness * \n", " % HP:0001871 ! Abnormality of blood and blood-forming tissues * \n", " % HP:0005561 ! Abnormality of bone marrow cell morphology * \n", " % HP:0012130 ! Abnormality of cells of the erythroid lineage * \n", " % HP:0001877 ! Abnormality of erythrocytes * \n", " % HP:0004447 ! Poikilocytosis * \n", " % HP:0001927 ! Acanthocytosis * \n", " % HP:0000152 ! Abnormality of head or neck * \n", " % HP:0000234 ! Abnormality of the head * \n", " % HP:0000271 ! Abnormality of the face * \n", " % HP:0000366 ! Abnormality of the nose * \n", " % HP:0000422 ! Abnormality of the nasal bridge * \n", " % HP:0000431 ! Wide nasal bridge * \n", " % HP:0005288 ! Abnormality of the nares * \n", " % HP:0000463 ! Anteverted nares * \n", " % HP:0010938 ! Abnormality of the external nose * \n", " % HP:0000429 ! Abnormality of the nasal alae * \n", " % HP:0000463 ! Anteverted nares * \n", " % HP:0005105 ! Abnormal nasal morphology * \n", " % HP:0000463 ! Anteverted nares * \n", " % HP:0000315 ! Abnormality of the orbital region * \n", " % HP:0100887 ! Abnormality of globe size * \n", " % HP:0000568 ! Microphthalmia * \n", "\n", "\n" ] } ], "source": [ "## Render as ascii-tree\n", "from ontobio.graph_io import GraphRenderer\n", "w = GraphRenderer.create('tree')\n", "w.write(g, query_ids=terms)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## visualization\n", "\n", "Now we will show enriched terms in a graph using graphviz" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": true }, "outputs": [], "source": [ "terms = [r['c'] for r in enr[:30]]\n", "g = get_minimal_subgraph(ont.get_graph(), terms)\n", "w = GraphRenderer.create('png')\n", "w.outfile = \"output/enr.png\"\n", "w.write(g, query_ids=terms)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Image\n", "\n", "![title](output/enr.png)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" } }, "nbformat": 4, "nbformat_minor": 2 }