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)
#>  All local files already up-to-date!
#> Importing cached file: /github/home/.cache/R/KGExplorer/hp-international.owl
#> Adding term metadata.
#> IC_method: IC_offspring
#> Adding ancestor metadata.
#> Getting absolute ontology level for 25,301 IDs.
#> 900 ancestors found at level 2
#> Translating all terms to names.
#> + Returning a vector of terms (same order as input).
#> Converted ontology to: adjacency 
#> Getting absolute ontology level for 25,301 IDs.
#> Randomly sampling 10 term(s).
g <- ontology_to(ont, to="tbl_graph")
#> Converted ontology to: tbl_graph 
p <- graph_to_plotly(g)
#> Converting igraph to plotly data.
#> Translating all terms to names.
#> Ontology not found via 'rols.' Trying method='github'.'
#> Preparing ontology_index object from: https://github.com/obophenotype/human-phenotype-ontology/releases/download/v2024-01-16/hp-base.obo
#> Parsing [Typedef] sections in the obo file [7/7]
#> Parsing [Term] sections in the obo file [1000/18264]
#> Parsing [Term] sections in the obo file [2000/18264]
#> Parsing [Term] sections in the obo file [3000/18264]
#> Parsing [Term] sections in the obo file [4000/18264]
#> Parsing [Term] sections in the obo file [5000/18264]
#> Parsing [Term] sections in the obo file [6000/18264]
#> Parsing [Term] sections in the obo file [7000/18264]
#> Parsing [Term] sections in the obo file [8000/18264]
#> Parsing [Term] sections in the obo file [9000/18264]
#> Parsing [Term] sections in the obo file [10000/18264]
#> Parsing [Term] sections in the obo file [11000/18264]
#> Parsing [Term] sections in the obo file [12000/18264]
#> Parsing [Term] sections in the obo file [13000/18264]
#> Parsing [Term] sections in the obo file [14000/18264]
#> Parsing [Term] sections in the obo file [15000/18264]
#> Parsing [Term] sections in the obo file [16000/18264]
#> Parsing [Term] sections in the obo file [17000/18264]
#> Parsing [Term] sections in the obo file [18000/18264]
#> Parsing [Term] sections in the obo file [18264/18264]
#> remove 388 obsolete terms
#> Adding term metadata.
#> IC_method: IC_offspring
#> Adding ancestor metadata.
#> Getting absolute ontology level for 17,874 IDs.
#> 70 ancestors found at level 2
#> Translating all terms to names.
#> + Returning a vector of terms (same order as input).
#> Converted ontology to: adjacency 
#> Getting absolute ontology level for 17,874 IDs.
#> + Returning a vector of terms (same order as input).