Skip to contents

Reverse the direction of ontology relations

Usage

swap_relations(relations)

Arguments

relations

The `relations` component of the data returned by obo_parser or any `...ontology_download` function such as go_ontology_download. Depending on the tables argument of those functions the `relations` can be a data frame or a nested list.

Value

Same type as the input, but the relations swapped: if in the input these pointed from each child to the parents, in the output they point from each parent to their children, and vice versa.

Examples

goslim_url <-
    "http://current.geneontology.org/ontology/subsets/goslim_generic.obo"
path <- tempfile()
httr::GET(goslim_url, httr::write_disk(path, overwrite = TRUE))
#> Response [http://current.geneontology.org/ontology/subsets/goslim_generic.obo]
#>   Date: 2023-07-31 12:47
#>   Status: 200
#>   Content-Type: text/obo
#>   Size: 114 kB
#> <ON DISK>  /tmp/RtmpztLmFt/file895a15799936f
obo <- obo_parser(path)
unlink(path)
rel_swapped <- swap_relations(obo$relations)