Given a KGX-formatted tabular KG (see https://github.com/biolink/kgx/blob/master/specification/kgx-format.md) loads it as a graph.
load_kgx(filename, attach_engine = NULL, ...)A tbl_kgx graph.
phenos <- monarch_engine() |>
fetch_nodes(query_ids = "MONDO:0007525") |>
expand(
predicates = "biolink:has_phenotype",
categories = "biolink:PhenotypicFeature"
)
#> Trying to connect to https://neo4j.monarchinitiative.org
#> Connected to https://neo4j.monarchinitiative.org
#> Fetching; counting matching nodes...
#> total: 1.
#> Fetching; fetched1of1
#> Expanding; counting matching edges...
#> total: 26.
#> Expanding; fetched26of26edges.
save_kgx(phenos, "phenos.tar.gz")
# when loading the graph, we can optionally attach an engine
loaded_phenos <- load_kgx("phenos.tar.gz", attach_engine = monarch_engine())
#> Trying to connect to https://neo4j.monarchinitiative.org
#> Connected to https://neo4j.monarchinitiative.org
loaded_phenos
#> # A tbl_graph: 29 nodes and 26 edges
#> #
#> # A rooted forest with 3 trees
#> #
#> # Node Data: 29 × 16 (active)
#> id pcategory name description synonym category iri xref file_source
#> <chr> <chr> <chr> <chr> <chr> <list> <chr> <chr> <chr>
#> 1 MONDO:0… biolink:… Ehle… An inherit… "c(\"\… <chr> http… "c(\… phenio_nod…
#> 2 HP:0000… biolink:… Thin… Reduction … "Thin … <chr> http… "c(\… phenio_nod…
#> 3 HP:0000… biolink:… Hype… A conditio… "c(\"\… <chr> http… "UML… phenio_nod…
#> 4 HP:0001… biolink:… Abno… NA "Abnor… <chr> http… "UML… phenio_nod…
#> 5 HP:0001… biolink:… Hypo… Hypotonia … "c(\"\… <chr> http… "c(\… phenio_nod…
#> 6 HP:0001… biolink:… Join… Displaceme… "c(\"\… <chr> http… "c(\… phenio_nod…
#> 7 HP:0001… biolink:… Hip … The presen… "c(\"\… <chr> http… "c(\… phenio_nod…
#> 8 HP:0001… biolink:… Join… Joint stif… "c(\"\… <chr> http… "c(\… phenio_nod…
#> 9 HP:0002… biolink:… Muti… Complete l… "c(\"\… <chr> http… "c(\… phenio_nod…
#> 10 HP:0002… biolink:… Apha… An acquire… "c(\"\… <chr> http… "c(\… phenio_nod…
#> # ℹ 19 more rows
#> # ℹ 7 more variables: narrow_synonym <chr>, namespace <chr>, provided_by <chr>,
#> # exact_synonym <chr>, related_synonym <chr>, subsets <chr>,
#> # broad_synonym <chr>
#> #
#> # Edge Data: 26 × 19
#> from to subject predicate object primary_knowledge_so…¹ knowledge_level
#> <int> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 1 2 MONDO:000… biolink:… HP:00… infores:orphanet knowledge_asse…
#> 2 1 3 MONDO:000… biolink:… HP:00… infores:orphanet knowledge_asse…
#> 3 1 4 MONDO:000… biolink:… HP:00… infores:orphanet knowledge_asse…
#> # ℹ 23 more rows
#> # ℹ abbreviated name: ¹primary_knowledge_source
#> # ℹ 12 more variables: evidence_count <dbl>, negated <lgl>,
#> # frequency_qualifier <chr>, file_source <chr>, original_subject <chr>,
#> # grouping_key <chr>, agent_type <chr>, aggregator_knowledge_source <chr>,
#> # has_evidence <chr>, provided_by <chr>, id <chr>, category <chr>
# cleanup saved file
file.remove("phenos.tar.gz")
#> [1] TRUE