Lightning talk to Boston area R users group Jeff Marcus 7/13/2011 Rgraphviz Lightning talk to Boston area R users group Jeff Marcus 7/13/2011
Introduction Rgraphviz allows you to visualize graphs (nodes and arcs) Good detailed presentation at http://www.bioconductor.org/help/course-materials/2009/SeattleApr09/graph/biocGraphs.pdf Some applications Social networks Biological pathways, protein interactions My use: callflow analysis in speech recognition applications Rgraphviz part of Bioconductor project Built around Graphviz, AT&T opensource graph visualization software
Example using “graph” package library(“graph”) library(“Rgraphviz”) nodes <- c("A", "B", "C", "D") edge.list <- list( A=list(edges=c("A", "B", "C")), B=list(edges=("C")), C=list(edges=c(“C","D")), D=list(edges=“B")) g <- new("graphNEL", nodes=nodes, edgeL=edge.list, edgemode="directed") Rgraphviz::plot(g) Note: graphNEL is a class in the “graph” package that extends virtual “graph” class. Efficient for smallish graphs with not too many edges
Igraph package Package “igraph” has richer set of graph manipulation functions and is better suited to large graphs Must convert igraph to graphNEL for Rgraphviz library(“igraph”) # igraph has many ways to construct graphs ig <- igraph::graph.data.frame (data.frame( from=c("a","a","a","b", "c", "c", "d"), to=c("a","b","c","c", "c", "d", "b"))) g <- igraph.to.graphNEL (ig) # Same graph as before Rgraphviz::plot(g)
Rgraphviz layout control Very fine-grained control of layout Overall layout (“dot”, “neato”, etc., each useful for different purposes) Node shapes Node and edge colors Edge thicknesses Ability to plot subgraphs as well Rgraphviz essentially an API around graphviz so need to consult graphviz documentation for details Caution: I found that many but not all graphviz features supported
Example: callflow graph Rgraphviz can produce legible graphs much more complex than this one
Installation You will need to first install graphviz See https://wiki.duke.edu/display/DUKER/Install+RGraphviz+under+Windows for details for Windows installation.