“An algorithm must be seen to be believed.”

-Donald Knuth

Gephi is a fabulous graphing tool, so we have made sure the results of precise_viz() can be written out into a format that Gephi understands. First, we will quickly calculate a distance matrix, transform it with precise_transform(), turn it into a graph with precise_graph(), and then write out a GraphML file with precise_viz(), which we can subsequently load into Gephi. Rather than using the output of precise_dist() with precise_fuse(), however, we will use the results of SIMLR() directly. We do this to drive home the point that precise_transform(), precise_graph() and precise_viz() are universal functions that can take any distance matrix as input. The following functions were detailed in the Cell Cycle vignette, so they are being lumped together here:

Now we can play with the distance matrix output of SIMLR():

cell_cycle_simlr_simil <- cell_cycle_simlr$S  %>%
  precise_transform(enforce_sim = TRUE) %>%
  precise_transform(binary_matrix = "0.20") %>%
  precise_transform(transform = "binorm") %>%
  precise_transform(transform = "random_walk") %>%
  precise_transform(enforce_dist = TRUE)

Lastly, create the graph and input it into precise_viz(). Note that we have set a file path for the graphml parameter here:

The GraphML output file can now be opened in Gephi v0.9.2. To view the layout precise_viz() calculated, install the MdsLayout plugin and use gravity_x and gravity_y as the inputs into Dimension 1 and Dimension 2, respectively. Note that the colors seen upon initial loading into Gephi are written into the GraphML file after being passed from the precise_viz() color_vec and colors arguments:

Of course, you can now also leverage Gephi’s layouts like ForceAtlas2:

Or, their fruchterman-reingold layout, which gives aesthetic results very different from precise_viz():

P.S. The embedding of downloadable Gephi-exported static images into pkgdown was done using plotly_embed() from this package (i.e. PreciseDist).