Contents

1 Introduction

In Bioconductor 3.19, ontoProc can work with OWL RDF/XML serializations of ontologies, via the owlready2 python modules.

The owl2cache function retrieves OWL from a URL or file and places it in a cache to avoid repetitious retrievals. The default cache is the one defined by BiocFileCache::BiocFileCache(). Here we work with the cell ontology. setup_entities will use owlready2 python modules to parse the OWL and produce an instance of S3 class owlents.

library(ontoProc)
ontoProc:::install_owlready2()
## Using Python: /usr/bin/python3.10
## Creating virtual environment 'r-owlready2' ... 
## Done!
## Installing packages: pip, wheel, setuptools
## Virtual environment 'r-owlready2' successfully created.
## Using virtual environment 'r-owlready2' ...
clont_path = owl2cache(url="http://purl.obolibrary.org/obo/cl.owl")
cle = setup_entities(clont_path)
cle
## owlents instance with 16148 classes.

A plot method is available. Given a vector of tags as reported in OWL (no colons are used), the plot method produces an ontologyIndex instance and runs onto_plot2 on the result.

sel = c("CL_0000492", "CL_0001054", "CL_0000236", 
"CL_0000625", "CL_0000576", 
"CL_0000623", "CL_0000451", "CL_0000556")
plot(cle, sel)

2 Illustration with Human Phenotype ontology

We’ll obtain and ad hoc selection of 15 UBERON term names and visualize the hierarchy.

ontoProc:::install_owlready2()
## Using virtual environment 'r-owlready2' ...
## + /home/biocbuild/.virtualenvs/r-owlready2/bin/python -m pip install --upgrade --no-user owlready2
hpont_path = owl2cache(url="http://purl.obolibrary.org/obo/hp.owl")
## resource BFC96 already in cache from http://purl.obolibrary.org/obo/hp.owl
hpents = setup_entities(hpont_path)
kp = grep("UBER", hpents$clnames, value=TRUE)[21:35]
plot(hpents, kp)

The prefixes of class names in the ontology give a sense of its scope.

t(t(table(sapply(strsplit(hpents$clnames, "_"), "[", 1))))
##         
##          [,1] 
##   BFO       14
##   CHEBI   1842
##   CL      1142
##   GO      2593
##   HP     18961
##   HsapDv    12
##   MPATH     75
##   NBO      143
##   PATO     568
##   PR       205
##   RO         1
##   UBERON  5604

To characterize human phenotypes ontologically, CL, GO, CHEBI, and UBERON play significant roles.