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 the unique identifier for each node in a graph (e.g. "name").

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)
#> Loading cached ontology: /github/home/.cache/R/KGExplorer/hp.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.
#> ⠙ Iterating 9 done (4.2/s) | 2.2s
#> ⠙ Iterating 14 done (4.6/s) | 3s
#> Importing cached file: /github/home/.cache/R/KGExplorer/hp.obo
#> Adding term metadata.
#> IC_method: IC_offspring
#> Adding ancestor metadata.
#> Getting absolute ontology level for 19,025 IDs.
#> 79 ancestors found at level 2
#> Translating ontology terms to names.
#> Translating ontology terms to ids.
#> Converted ontology to: adjacency 
#> Getting absolute ontology level for 19,025 IDs.
#> Saving ontology --> /github/home/.cache/R/KGExplorer/hpo.rds