Viewing Results with Gephi
Brian Muchmore
2026-07-14
Source:vignettes/articles/Viewing-Results-with-Gephi.Rmd
Viewing-Results-with-Gephi.Rmd“An algorithm must be seen to be believed.”
Export a graph for Gephi
The precise_viz() router draws panels but performs no
file I/O. To take a graph into a dedicated tool like Gephi, use the small standalone helper
precise_graphml(), which writes a plain weighted undirected
graph to a .graphml file via igraph.
Like the rest of PreciseViz, precise_graphml() is a
bring-your-own-matrix tool: it accepts either a row of a typed tibble
(selected by key=) or a bare square symmetric matrix, so it
works on PreciseDist output and on a matrix from anywhere
else.
From data to a GraphML file
Build a distance, project it to a graph, and export one row by its key:
d <- precise_dist(cell_cycle, dists = "euclidean", verbose = FALSE)
g <- precise_graph(d, methods = "knn", params = list(knn = list(k = 3)),
verbose = FALSE)
out <- precise_graphml(g, file = tempfile(fileext = ".graphml"),
key = "euclidean__knn")
basename(out)
#> [1] "file15cf62454f062.graphml"precise_graphml() refuses to overwrite an existing file,
and — because it is part of the typed spine — refuses a distance-typed
row (Gephi wants a similarity/adjacency graph, not raw distances);
coerce or project first.
Any matrix will do
Because it takes a bare matrix plus type= is not even
needed for the pure export (it just needs a square symmetric matrix),
you can hand it a matrix produced by a completely different method — say
an affinity S from another package — and still get a
Gephi-ready file:
precise_graphml(S, file = "my_graph.graphml")Open the resulting .graphml in Gephi to lay out, colour,
and explore the graph interactively.