This function takes as input the results of precise_graph, and then offers a large variety of visualization algorithms that can be seen within RStudio, written out as a standalone HTML file or written out as a GraphML file that can be used as input into a graphing software like Gephi.

precise_viz(data, plot_type = "kk_2d_graph", k = 5, jitter = NULL,
  color_vec = NULL, colors = NULL, size = 0.5, graphml = NULL,
  html = NULL, verbose = TRUE)

Arguments

data

A square, numeric dataframe, matrix or tibble.

plot_type

A string value. See "Plot types" below for all possible options.

k

An integer of the number of nearest neighboors to use for sparsifying the graph.

color_vec

NULL or a string vector of names to use the same length as the input data.

colors

NULL or a string vector of hex colors to use.

size

A numeric value for the output node size.

graphml

TRUE or FALSE. Should precise_viduals write out a GraphML file? The file path is controlled by the file argument.

verbose

TRUE or FALSE. Should the function tell you what is happening internally?

file

NULL or the absolute path of where any output files should be written.

Value

A square, numeric matrix with new diagonal.

Details

This function has a number of intricacies the user should be aware of:

  • 2D plots are written out using plot_ly, 3D plots are written out using scatterplot3js, 2D graphs are written out using visNetwork or forceNetwork, and 3D graphs are written out using graphjs.

  • On some systems, graphjs and scatterplot3js 3D results may crash RStudio. Under these circumstances, write the object to file rather than trying to open it within RStudio.

  • If the color_vec argument is left NULL, the output graph will be colored according to it's precise_graph clustering.

  • If the color argument is left NULL, the colors of each group will be applied randomly.

  • The appropriate size argument will vary depending on the plot_type input.

Plot types

The following are the plot types available for input into the plot_type argument and their corresponding parent function.

References

Muchmore, B., Muchmore P. and Alarcón-Riquelme ME. (2018). Optimal Distance Matrix Construction with PreciseDist and PreciseGraph.

B. W. Lewis (2017). threejs: Interactive 3D Scatter Plots, Networks and Globes. R package version 0.3.1. https://CRAN.R-project.org/package=threejs

Almende B.V., Benoit Thieurmel and Titouan Robert (2018). visNetwork: Network Visualization using 'vis.js' Library. R package version 2.0.3. https://CRAN.R-project.org/package=visNetwork

J.J. Allaire, Christopher Gandrud, Kenton Russell and CJ Yetman (2017). networkD3: D3 JavaScript Network Graphs from R. R package version 0.4. https://CRAN.R-project.org/package=networkD3

See also

Examples

library(PreciseDist) test_matrix <- replicate(10, rnorm(50)) test_distances <- test_matrix %>% precise_dist(dists = c("euclidean", "manhattan"))
#> [1] "Starting dists calculations at 2018-11-29 15:20:32" #> [1] "Finished dists calculations at 2018-11-29 15:20:33" #> [1] "Calculations took: 0.5 seconds" #> [1] "Starting dist_funcs calculations at 2018-11-29 15:20:33" #> [1] "Finished dist_funcs calculations at 2018-11-29 15:20:33" #> [1] "Calculations took: 0 seconds"
test_fusion <- test_distances %>% precise_fusion(fusion = "distatis", verbose = TRUE)
#> [1] "Starting distance matrix fusion using distatis at 2018-11-29 15:20:33" #> [1] "Finished distance matrix fusion at 2018-11-29 15:20:34" #> [1] "Fusion took: 0.08 seconds"
test_graph <- test_fusion %>% precise_graph(distillation = 1, perplexity = 5, theta = 0.5, max_iter = 1000, cores = 1, verbose = TRUE)
#> Error in precise_graph(., distillation = 1, perplexity = 5, theta = 0.5, max_iter = 1000, cores = 1, verbose = TRUE): unused arguments (distillation = 1, perplexity = 5, theta = 0.5, max_iter = 1000, cores = 1)
test_viz <- precise_viz(data = test_graph, plot_type = "kk_2d_graph", graphml = FALSE, k = 5, color_vec = NULL, colors = NULL, size = 0.5, file = NULL, verbose = TRUE)
#> Error in precise_viz(data = test_graph, plot_type = "kk_2d_graph", graphml = FALSE, k = 5, color_vec = NULL, colors = NULL, size = 0.5, file = NULL, verbose = TRUE): unused argument (file = NULL)