Generate a 2D or 2D layout of a graph using the UMAP algorithm. See here for details: igraph_layout_umap

layout_umap(graph, use_3d = FALSE, prefix = "UMAP", ...)

Arguments

graph

A graph object

use_3d

Logical, whether to use a 3D layout (TRUE) or 2D layout (FALSE). Default is FALSE (2D).

prefix

A character string prefix to add to the layout column names.

...

Additional arguments passed to the layout function.

Value

A matrix of x and y coordinates for each node in the graph.

Examples

set.seed(2024)
filename <- system.file("extdata", "eds_marfan_kg.tar.gz", package = "monarchr")
g <- file_engine(filename) |>
          fetch_nodes(pcategory=="biolink:Disease", limit=40) |>
          expand(predicates = "biolink:has_phenotype",
                 categories = "biolink:PhenotypicFeature")|>
          tidygraph::sample_n(200) |>
          expand(categories = "biolink:Gene")
#> `sample_n()` argument `.env` is deprecated and no longer has any effect.
X <- layout_umap(g)
g <- graph_centrality(g)
#> Computing node centrality.
plot(g, layout=X, node_size=centrality)
#> Warning: ggrepel: 177 unlabeled data points (too many overlaps). Consider increasing max.overlaps