getNodeElements: Functions for working with Rgraphviz plots in SVG

Description Usage Arguments Value Author(s) References See Also Examples

Description

These functions provide some support for working with graphs in SVG generated via Rgraphviz.

addGraphIds takes the graph layout (Ragraph-class) object and determines the SVG elements corresponding to the nodes and edges and places id and class attributes on each. This allows us to easily identify the elements in subsequent computations, both in R and JavaScript.

A single node in the graph typically has two SVG elements associated with it: the circle and the text/label. We treat the circle as the node. The ids for the node circles are taken as the names from the graph layout object. The ids for the node labels are the same names but with "-label" appended.

The id for an edge is slightly more complex. The general format is "edge:tail-head", where tail and head are the names of the relevant nodes. For undirected edges, the order is important. The head is the earlier node in the list of node names. (We haven't dealt with directed edges yet.)

The edges have class "edge" and the nodes "node" and the text of the node "nodeLabel"

getNodeElements and getEdgeElements can be used to get the SVG elements in the document that correspond to the nodes and edges using the class attribute added by addGraphIds. These functions will not work correctly before addGraphIds has been called.

getEdgeInfo is used by addGraphIds and by users annotating SVG documents in R to get the edge identifiers (i.e. the id attributes) in the correct form. Unlike the other functions, this does not work with the SVG document, but with the graph object directly. There are methods for a graphNEL object and a laid-out Ragraph

These functions are not necessarily complete (!) and will not necessarily work for different types of graph layouts. The basic ideas however should extend readily to these other types but have not been implemented yet. Currently, the functions will typically only work correctly when each edge corresponds to just one SVG element. This is the case for the twopi layout.

Usage

1
2
3
4
5
6
7
addGraphIds(doc, graph,
            main = getNodeSet(doc,
                              "//s:svg/s:g/s:g",
                              c("s"= "http://www.w3.org/2000/svg"))[[1]])
getNodeElements(doc)
getEdgeElements(doc)
getEdgeInfo(graph, ...)

Arguments

doc

the parsed XML/SVG document

graph

the graph object. For addGraphIds, this should be an object of class Ragraph returned by a call to agopen. This is the already laid-out graph. For getEdgeInfo, this can also be a graph description, e.g graphNEL object.

main

the XML element in the SVG document which contains (as children) the elements for the nodes and edges in our graph

...

extra parameters for methods to specialize

Value

getNodeElements returns a list of XMLInternalNode objects corresponding to the nodes of the graph in the SVG display. Similarly, getEdgeElements returns a list of XMLInternalNode objects corresponding to the edges in the graph.

addGraphIds returns a list with three elements

getEdgeInfo returns a list with as manay elements as there are edges. Each element is a character vector giving the "edge:src-dest" label identifying the connections..

Author(s)

Duncan Temple Lang

References

graph and Rgraphviz packages. BioConductor book "Bioinformatics and Computational Biology Solutions Using R and BioConductor". Gentleman, Carey, Huber, Irizarry and Dudoit (Editors). 2005.

See Also

svgPlot

Examples

1
  # See the example in the tests/ directory of the package.

duncantl/SVGAnnotation documentation built on May 15, 2019, 5:57 p.m.