Viewing Results with Gephi
Brian Muchmore
2026-08-13
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] "file15e472e36246.graphml"precise_graphml() refuses to overwrite an existing file,
and it refuses a distance-typed row of a tibble. Edge weight means
connection strength in every graph tool, so exporting a distance as an
edge weight would make the least related pairs look like the strongest
links. Convert or project the row first.
Any matrix will do
A bare matrix carries no type, so the pure export needs only a square
symmetric matrix and no type= at all. That means 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.