Title: | Reading Ontologies into R |
---|---|
Description: | Functions for reading ontologies into R as lists and manipulating sets of ontological terms - 'ontologyX: A suite of R packages for working with ontological data', Greene et al 2017 <doi:10.1093/bioinformatics/btw763>. |
Authors: | Daniel Greene <[email protected]> |
Maintainer: | Daniel Greene <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.12 |
Built: | 2024-12-19 06:43:40 UTC |
Source: | CRAN |
Functions for reading ontologies into R and manipulating sets of ontological terms.
Daniel Greene <[email protected]>
Maintainer: Daniel Greene <[email protected]>
Greene D, Richardson S, Turro E (2017). 'ontologyX: a suite of R packages for working with ontological data. _Bioinformatics_, 33(7), 1104–1106.
Westbury SK, Turro E, Greene D, Lentaigne C, Kelly AM, Bariana TK, Simeoni I, Pillois X, Attwood A, Austin S, Jansen SB, Bakchoul T, Crisp-Hihn A, Erber WN, Favier R, Foad N, Gattens M, Jolley JD, Liesner R, Meacham S, Millar CM, Nurden AT, Peerlinck K, Perry DJ, Poudel P, Schulman S, Schulze H, Stephens JC, Furie B, Robinson PN, Geet Cv, Rendon A, Gomez K, Laffan MA, Lambert MP, Nurden P, Ouwehand WH, Richardson S, Mumford AD and Freson K (2015). ‘Human phenotype ontology annotation and cluster analysis to unravel genetic defects in 707 cases with unexplained bleeding and platelet disorders.’ _Genome Med_, *7*(1), pp. 36.
Kohler S, Doelken SC, Mungall CJ, Bauer S, Firth HV, Bailleul-Forestier I, Black GC, Brown DL, Brudno M, Campbell J, FitzPatrick DR, Eppig JT, Jackson AP, Freson K, Girdea M, Helbig I, Hurst JA, Jahn J, Jackson LG, Kelly AM, Ledbetter DH, Mansour S, Martin CL, Moss C, Mumford A, Ouwehand WH, Park SM, Riggs ER, Scott RH, Sisodiya S, Van Vooren S, Wapner RJ, Wilkie AO, Wright CF, Vulto-van Silfhout A, de Leeuw N, de Vries B, Washingthon NL, Smith CL, Westerfield M, Schofield P, Ruef BJ, Gkoutos GV, Haendel M, Smedley D, Lewis SE and Robinson PN (2014). ‘The Human Phenotype Ontology project: linking molecular biology and disease through phenotype data.’ _Nucleic Acids Res._, *42*(Database issue), pp. D966-974.
Ashburner et al. Gene ontology: tool for the unification of biology (2000) Nat Genet 25(1):25-9
Smith, Cynthia L., Carroll-Ann W. Goldsmith, and Janan T. Eppig. ‘The Mammalian Phenotype Ontology as a tool for annotating, analyzing and comparing phenotypic information.’ Genome biology 6.1 (2004): 1.
ontology_index
object to data.frame
Case ontology_index
object to data.frame
## S3 method for class 'ontology_index' as.data.frame(x, ...)
## S3 method for class 'ontology_index' as.data.frame(x, ...)
x |
|
... |
Arguments pass to |
data.frame
containing information about an ontology, rows corresponding to terms and columns to properties.
Perform simple consistency checks on ontology_index
object
check(ontology, stop_if_invalid = FALSE)
check(ontology, stop_if_invalid = FALSE)
ontology |
|
stop_if_invalid |
Logical value determining whether the function should call |
Exclude from set terms
, any terms that are either in, or descend from one of, the set roots
.
exclude_descendants(ontology, roots, terms)
exclude_descendants(ontology, roots, terms)
ontology |
|
roots |
Character vector of IDs for terms with respect to which descendants are to be defined. |
terms |
Character vector of ontological terms. |
Character vector of terms
intersection_with_descendants
, prune_descendants
Get set of terms containing all ancestors of terms in a given set
get_ancestors(ontology, terms)
get_ancestors(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms. |
Character vector of all terms which are an ancestor of at least one term in terms
, including the terms themselves
link{get_descendants}
data(hpo) get_ancestors(hpo, c("HP:0001873", "HP:0011877"))
data(hpo) get_ancestors(hpo, c("HP:0001873", "HP:0011877"))
Get set of terms containing all descendants of terms in a given set
get_descendants(ontology, roots, exclude_roots = FALSE)
get_descendants(ontology, roots, exclude_roots = FALSE)
ontology |
|
roots |
Character vector of IDs for terms with respect to which descendants are to be defined. |
exclude_roots |
Boolean determining whether to remove the given |
Character vector of terms
link{get_ancestors}
data(hpo) get_descendants(hpo, roots="HP:0001873")
data(hpo) get_descendants(hpo, roots="HP:0001873")
Read ontology from OBO file into R
get_ontology( file, propagate_relationships = "is_a", extract_tags = "minimal", merge_equivalent_terms = TRUE ) get_OBO( file, propagate_relationships = "is_a", extract_tags = "minimal", merge_equivalent_terms = TRUE )
get_ontology( file, propagate_relationships = "is_a", extract_tags = "minimal", merge_equivalent_terms = TRUE ) get_OBO( file, propagate_relationships = "is_a", extract_tags = "minimal", merge_equivalent_terms = TRUE )
file |
File path of OBO formatted file. |
propagate_relationships |
Character vector of relations |
extract_tags |
Character value: either "minimal" or "everything", determining whether to extract only the properties of terms which are required to run functions in the package - i.e. |
merge_equivalent_terms |
Logical value determining whether terms that are marked |
ontology_index
object.
Get names of relations used in OBO file
get_relation_names(file)
get_relation_names(file)
file |
File path of OBO formatted file. |
Get logical descendancy matrix for set of terms
get_term_descendancy_matrix(ontology, terms = NULL, rows = terms, cols = terms)
get_term_descendancy_matrix(ontology, terms = NULL, rows = terms, cols = terms)
ontology |
|
terms |
Character vector of ontological terms. |
rows |
Rows for resultant matrix (defaults to |
cols |
Cols for resultant matrix (defaults to |
A logical square matrix of with length(terms)
columns and rows. result[row_term,col_term] == TRUE
if row_term
is an ancestor (and not the same as) of col_term
.
A logical matrix.
data(hpo) get_term_descendancy_matrix(hpo, c("HP:0001873", "HP:0011877"))
data(hpo) get_term_descendancy_matrix(hpo, c("HP:0001873", "HP:0011877"))
Get frequency of each term in a set of phenotypes
get_term_frequencies(ontology, term_sets, patch_missing = FALSE)
get_term_frequencies(ontology, term_sets, patch_missing = FALSE)
ontology |
|
term_sets |
List of character vectors of ontological term IDs. |
patch_missing |
Logical indicating whether to include whole ontology even if they're not present in the |
Numeric vector of information contents, named by corresponding terms. Takes into account ancestors, in the sense that all ancestor terms implied by the phenotypes are considered 'on'
data(hpo) get_term_frequencies(hpo, list("HP:0001873"))
data(hpo) get_term_frequencies(hpo, list("HP:0001873"))
Get information content of each term in a set of phenotypes
get_term_info_content(ontology, term_sets, patch_missing = FALSE)
get_term_info_content(ontology, term_sets, patch_missing = FALSE)
ontology |
|
term_sets |
List of character vectors of ontological term IDs. |
patch_missing |
Logical indicating whether to include all ontology terms even if they're not present in the |
Numeric vector of information contents, named by corresponding terms. Takes into account ancestors, in the sense that all ancestor terms implied by the phenotypes are considered 'on'
data(hpo) get_term_info_content(hpo, list("HP:0001873"))
data(hpo) get_term_info_content(hpo, list("HP:0001873"))
Get property of individual ontological term
get_term_property(ontology, property_name, term, as_names = FALSE)
get_term_property(ontology, property_name, term, as_names = FALSE)
ontology |
|
property_name |
Name of property. |
term |
Character value of term ID. |
as_names |
Logical value determining whether to return character vector of names (defaults to |
ontology_index
object encapsulating structure of the Gene Ontology (HPO) comprising a list
of lists/vectors of properties of GO terms indexed by term ID (downloaded from https://current.geneontology.org/ontology/go-basic.obo).
List of lists and vectors
ontology_index
object encapsulating structure of the Human Phenotype Ontology (HPO) comprising a list
of lists/vectors of properties of HPO terms indexed by term ID (downloaded from https://hpo.jax.org/app/data/ontology).
List of lists and vectors
Intersect a set of terms with the descendants of a given set of roots
intersection_with_descendants(ontology, roots, terms)
intersection_with_descendants(ontology, roots, terms)
ontology |
|
roots |
Character vector of IDs for terms with respect to which descendants are to be defined. |
terms |
Character vector of ontological terms. |
Character vector of terms
exclude_descendants
, prune_descendants
data(hpo) intersection_with_descendants(hpo, c("HP:0001872", "HP:0000707"), c("HP:0001873", "HP:0011877"))
data(hpo) intersection_with_descendants(hpo, c("HP:0001872", "HP:0000707"), c("HP:0001873", "HP:0011877"))
Remove redundant/implied terms from a set of terms
minimal_set(ontology, terms)
minimal_set(ontology, terms)
ontology |
|
terms |
Character vector of ontological terms. |
Character vector of terms
data(hpo) minimal_set(hpo, c("HP:0001873", "HP:0001872"))
data(hpo) minimal_set(hpo, c("HP:0001873", "HP:0001872"))
ontology_index
object encapsulating structure of the Mammalian Phenotype Ontology (MPO) comprising a list
of lists/vectors of properties of MPO terms indexed by term ID (downloaded from https://www.informatics.jax.org/downloads/reports/MPheno_OBO.ontology).
List of lists and vectors
ontology_index
object from vectors and lists of term propertiesCreate ontology_index
object from vectors and lists of term properties
ontology_index( parents, id = names(parents), name = id, obsolete = setNames(nm = id, rep(FALSE, length(id))), version = NULL, ... )
ontology_index( parents, id = names(parents), name = id, obsolete = setNames(nm = id, rep(FALSE, length(id))), version = NULL, ... )
parents |
List of character vectors of parents per term. |
id |
Character vector of term IDs. Defaults to the |
name |
Character vector of term labels. |
obsolete |
Logical vector indicating whether given terms are obsolete. |
version |
Version information about the ontology. |
... |
Additional arguments, each of which should be either a vector or list of term properties, each with the same length as |
animal_superclasses <- list(animal=character(0), mammal="animal", cat="mammal", fish="animal") animal_ontology <- ontology_index(parents=animal_superclasses) unclass(animal_ontology)
animal_superclasses <- list(animal=character(0), mammal="animal", cat="mammal", fish="animal") animal_ontology <- ontology_index(parents=animal_superclasses) unclass(animal_ontology)
ontology_index
objectPrint ontology_index
object
## S3 method for class 'ontology_index' print(x, ...)
## S3 method for class 'ontology_index' print(x, ...)
x |
|
... |
Unused parameters. |
Prints a summary
An 'ontology_index' can contain multiple relations (for example in the case of the Gene Ontology, "is_a"
and "part_of"
could be stored as separate properties in an ‘ontology_index'). Transitive relations (i.e. relations such that x related to y and y related to z implies x related to z, for example the relation ’is an ancestor of') stored by an ‘ontology_index' can be propagated using this function. The ’inverse relations' (i.e. x inversely related to y if y related to x) can also be propagated by setting the use_inverse_relations
parameter to TRUE
.
propagate_relations( ontology, roots, relations, use_inverse_relations = FALSE, exclude_roots = FALSE )
propagate_relations( ontology, roots, relations, use_inverse_relations = FALSE, exclude_roots = FALSE )
ontology |
|
roots |
Character vector of term IDs from which relations will be propagated. |
relations |
Character vector given names of transitive relations to be propagated. |
use_inverse_relations |
Boolean vector indicating whether to propagate inverse relations. If |
exclude_roots |
Boolean determining whether to remove the given |
Character vector of terms
get_ancestors
, get_descendants
Given two sets of terms, roots
and terms
, construct a set of terms containing those in terms
which do not descend from any term in roots
, and also any terms in roots
which are ancestors of any term in terms
.
prune_descendants(ontology, roots, terms)
prune_descendants(ontology, roots, terms)
ontology |
|
roots |
Character vector of IDs for terms with respect to which descendants are to be defined. |
terms |
Character vector of ontological terms. |
Character vector of terms
exclude_descendants
, intersection_with_descendants