Convert an igraph to data for a 3D plotly plot.

graph_to_plotly(
  g,
  ont = get_ontology("hpo"),
  layout_func = igraph::layout.fruchterman.reingold,
  dim = 3,
  id_col = "name",
  label_var = "hpo_name",
  seed = 2023
)

Arguments

g

ggnetwork object (or an igraph/tbl_graph to be converted to ggnetwork format).

ont

An ontology of class ontology_DAG.

layout_func

Layout function for the graph.

dim

Number of dimensions to create layout in.

id_col

Column containing unique ID per term.

label_var

Column containing the label for each node in a graph (e.g. "hpo_name").

seed

Set the seed for reproducible clustering.

Value

Named list of data.frames.

Examples

ont <- get_ontology("hp", terms=10)
#> Using cached ontology file (1/1):
#>  /github/home/.cache/R/KGExplorer/ontologies/github/hp_v2025-05-06.rds
#> Randomly sampling 10 term(s).
g <- ontology_to(ont, to="tbl_graph")
#> Translating ontology terms to ids.
#> Converted ontology to: tbl_graph 
p <- graph_to_plotly(g)
#> Converting igraph to plotly data.
#> Translating ontology terms to names.
#> Using cached ontology file (1/1):
#>  /github/home/.cache/R/KGExplorer/ontologies/github/hp_v2025-05-06.rds