Writes an undirected weighted graph to a .graphml file with
igraph::write_graph(), for use in external tools such as
Gephi.
Details
data is either a bare square symmetric numeric matrix or a tibble from
which key= selects exactly one row. Matrix input may come from any
producer.
Input must be square, symmetric within 1e-8, and finite. A tibble row must
be typed similarity; other declared types are outside the export contract.
In particular, distance values would invert the meaning of edge weight. A
bare matrix carries no declared type and is written as supplied. The diagonal
is excluded from the exported edges.
An existing file is an error. Nothing is overwritten.
References
Csardi G, Nepusz T (2006). The igraph software package for complex network research. InterJournal Complex Systems, 1695.
See also
precise_viz(), which renders the same graph as a panel.
Examples
data(data_cell_cycle, package = "PreciseViz")
cells <- c(1:4, 60:63, 118:121)
cell_cycle <- as.matrix(data_cell_cycle[cells, 2:41])
rownames(cell_cycle) <- paste0(data_cell_cycle$Cell_cycle[cells], "_", cells)
euclidean <- as.matrix(stats::dist(cell_cycle))
adjacency <- (euclidean <= stats::quantile(euclidean[lower.tri(euclidean)],
0.25)) * 1
diag(adjacency) <- 0
graphml_file <- tempfile(fileext = ".graphml")
precise_graphml(adjacency, graphml_file)
file.exists(graphml_file)
#> [1] TRUE