Computes the transitive closure of a graph, treating the specified
predicate as transitive. Resulting edge predicates will the be the
same, but have primary_knowledge_source set to transitive_
transitive_closure(g, predicate = "biolink:subclass_of")
Graph with transitive edges added.
engine <- file_engine(system.file("extdata", "eds_marfan_kg.tar.gz", package = "monarchr"))
engine |> fetch_nodes(name == "Tall stature") |>
expand_n(predicates = "biolink:subclass_of", direction = "out", n = 3) |> # get 2 levels of ancestors
activate(edges) |>
filter(primary_knowledge_source == "infores:upheno") |>
transitive_closure(predicate = "biolink:subclass_of") |>
plot(edge_color = primary_knowledge_source)
#> Initial graph size: 1 nodes || 0 edges
#> Expanding graph: iteration 1/3
#> Graph size: 3 nodes || 2 edges
#> Expanding graph: iteration 2/3
#> Graph size: 7 nodes || 7 edges
#> Expanding graph: iteration 3/3
#> Graph size: 13 nodes || 15 edges
#> Using "sugiyama" as default layout