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: 2024-04-07 15:00
#>   Status: 200
#>   Content-Type: text/obo
#>   Size: 115 kB
#> <ON DISK>  /tmp/RtmpgsvP1J/file165a605f935b8f
obo <- obo_parser(path)
unlink(path)
rel_swapped <- swap_relations(obo$relations)