Access ontologies#

When it comes to ontology defined vocabularies, such as cell type, tissue, disease, and phenotype, Pronto Ontology object can be accessed via {entity}.ontology

import bionty as bt

Basic fields: name, ontology_id, definition, synonyms, children#

These fields are parsed into the DataFrame(df()) and lookup object to be directly accessible

disease_bt = bt.Disease()

disease_bt
Disease
Organism: all
Source: mondo, 2023-04-04
#terms: 26234

📖 Disease.df(): ontology reference table
🔎 Disease.lookup(): autocompletion of terms
🎯 Disease.search(): free text search of terms
✅ Disease.validate(): strictly validate values
🧐 Disease.inspect(): full inspection of values
👽 Disease.standardize(): convert to standardized names
🪜 Disease.diff(): difference between two versions
🔗 Disease.ontology: Pronto.Ontology object
disease_bt.df().head()
name definition synonyms parents
ontology_id
MONDO:0000001 disease A Disease Is A Disposition To Undergo Patholog... disorders|medical condition|other disease|dise... []
MONDO:0000002 obsolete 46,XX sex reversal None None []
MONDO:0000003 obsolete 17-hydroxysteroid dehydrogenase defic... None None []
MONDO:0000004 adrenocortical insufficiency An Endocrine Or Hormonal Disorder That Occurs ... adrenal gland insufficiency|adrenal cortical i... [MONDO:0002816]
MONDO:0000005 alopecia, isolated None None [MONDO:0021034]
lookup = disease_bt.lookup()
lookup_record = lookup.alzheimer_disease

lookup_record
Disease(ontology_id='MONDO:0004975', name='Alzheimer disease', definition='A Progressive, Neurodegenerative Disease Characterized By Loss Of Function And Death Of Nerve Cells In Several Areas Of The Brain Leading To Loss Of Cognitive Function Such As Memory And Language.', synonyms="Alzheimer disease|Alzheimer's dementia|AD|Alzheimer's disease|presenile and senile dementia|Alzheimers disease|Alzheimer dementia|Alzheimers dementia", parents=array(['MONDO:0005574', 'MONDO:0001627'], dtype=object))
lookup_record.definition
'A Progressive, Neurodegenerative Disease Characterized By Loss Of Function And Death Of Nerve Cells In Several Areas Of The Brain Leading To Loss Of Cognitive Function Such As Memory And Language.'

Synonyms are concatenated into a string with bars |:

lookup_record.synonyms
"Alzheimer disease|Alzheimer's dementia|AD|Alzheimer's disease|presenile and senile dementia|Alzheimers disease|Alzheimer dementia|Alzheimers dementia"

Parents with distance=1 can be directly accessed:

lookup_record.parents
array(['MONDO:0005574', 'MONDO:0001627'], dtype=object)

.pronto: Pronto Ontology#

More hierarchical information can be accessed from the Pronto Ontology object:

pronto_object = disease_bt.ontology
💡 downloading Disease ontology source file...


pronto_object
Ontology('/home/runner/work/bionty/bionty/bionty/_dynamic/ontology_all__mondo__2023-04-04__Disease', timeout=100)
term = pronto_object.get_term("MONDO:0004975")

term
Term('MONDO:0004975', name='Alzheimer disease')
list(term.subclasses(distance=2, with_self=False))
[Term('MONDO:0010422', name='Alzheimer disease 16'),
 Term('MONDO:0014036', name='Alzheimer disease 17'),
 Term('MONDO:0014265', name='Alzheimer disease 18'),
 Term('MONDO:0014316', name='Alzheimer disease 19'),
 Term('MONDO:0100087', name='familial Alzheimer disease'),
 Term('MONDO:0007089', name='Alzheimer disease 2'),
 Term('MONDO:0015140', name='early-onset autosomal dominant Alzheimer disease')]

Extra fields#

ExperimentalFactor parses Experimental Factor Ontology to the following additional categories for describing biological experiments:

  • molecule

  • instrument

  • measurement

readout_bt = bt.ExperimentalFactor()
readout_bt.df().head()
name definition synonyms parents molecule instrument measurement
ontology_id
EFO:0011021 BRCA1 mutation carier status Determination Of The Presence Or Absence Of Kn... BRCA1 mutation status|BRCA1 carrier status [EFO:0007658] None None carrier status
EFO:0011022 BRCA2 mutation carier statu Determination Of The Presence Or Absence Of Kn... BRCA2 carrier status|BRCA2 mutation status [EFO:0007658] None None carrier status
EFO:0700000 spatial proteomics An Assay That Allows For Visualization And Qua... None [EFO:0001458] protein assay None None
EFO:0700001 PhenoCycler-Fusion A Spatial Discovery System Where Whole-Slide S... None [EFO:0700000] protein assay None None
EFO:0700002 PhenoCycler An Automated Fluidics System That Uses Oligonu... None [EFO:0700000] protein assay None None
lookup = readout_bt.lookup()

Look up a molecular readout:

lookup_record = lookup.single_cell_rna_sequencing
lookup_record
ExperimentalFactor(ontology_id='EFO:0008913', name='single-cell RNA sequencing', definition='A Protocol That Provides The Expression Profiles Of Single Cells Via The Isolation And Barcoding Of Single Cells And Their Rna, Reverse Transcription, Amplification, Library Generation And Sequencing.', synonyms='single-cell RNA-seq|scRNA-seq|single cell RNA sequencing|single-cell transcriptome sequencing', parents=array(['EFO:0001457', 'EFO:0007832'], dtype=object), molecule='RNA assay', instrument='single cell sequencing', measurement=None)
lookup_record.molecule
'RNA assay'
lookup_record.instrument
'single cell sequencing'

Lookup a phenotypic readout:

lookup.tumor_size
ExperimentalFactor(ontology_id='EFO:0004134', name='tumor size', definition='The Physical Size Of A Tumor.', synonyms='size of tumor', parents=array(['EFO:0001444'], dtype=object), molecule=None, instrument=None, measurement='tumor size')

Comparing ontology versions#

Bionty provides bionty.Bionty.diff() to determine a diff between two ontology versions.

disease_bt_old = bt.Disease(source="mondo", version="2023-04-04")
disease_bt_new = bt.Disease(source="mondo", version="2023-02-06")

new_entries, modified_entries = disease_bt_old.diff(disease_bt_new)
new_entries.head()
name definition synonyms parents
ontology_id
MONDO:0000001 disease A Disease Is A Disposition To Undergo Patholog... disorders|medical condition|other disease|dise... NaN
MONDO:0000437 cerebellar ataxia A Neurological Syndrome Characterised By Clums... spinocerebellar Degeneration|ataxia syndrome NaN
MONDO:0000476 generalized dystonia None dystonia deformans progressiva|generalized iso... NaN
MONDO:0000866 hereditary myoglobinuria None None NaN
MONDO:0001142 salivary gland disorder A Disease Involving The Saliva-Secreting Gland. salivary gland disorder|disease of saliva-secr... NaN
modified_entries.head()
name definition synonyms
self other self other self other
ontology_id
MONDO:0000001 disease disease or disorder NaN NaN NaN NaN
MONDO:0000437 NaN NaN NaN NaN spinocerebellar Degeneration|ataxia syndrome spinocerebellar Degeneration|ataxia|ataxia syn...
MONDO:0000476 NaN NaN NaN NaN dystonia deformans progressiva|generalized iso... dystonia deformans progressiva
MONDO:0000866 hereditary myoglobinuria myoglobinuria NaN NaN NaN NaN
MONDO:0001142 NaN NaN NaN NaN salivary gland disorder|disease of saliva-secr... salivary gland disorder|disease of saliva-secr...