
xGGraph
is supposed to visualise an igraph object using ggraph,
with nodes/tips labelled (aligned to left-right or top-bottom edges).
xGGraph(
ig,
layout = "partition",
circular = T,
leave = T,
node.label.size = 2,
node.label.direction = c("none", "leftright", "topbottom"),
node.label.color = "steelblue",
node.label.alpha = 0.7,
node.label.wrap = NULL,
node.label.offset = 0.5,
node.size = 2,
limit.expansion = NULL,
edge = c("diagonal", "link", "arc", "fan", "elbow"),
edge.color = "grey",
edge.alpha = 0.5,
edge.width = 0.5,
...
)
an object of class "igraph" with node attribute 'name'. It could be a 'phylo' object converted to. Note: the node/leave labels would be the node attribute 'name' unless the node attribute 'label' is explicitely provided
the layout supported in ggraph::create_layout. This can be ggraph layouts 'partition' (by default), 'dendrogram', 'circlepack', 'treemap' (-1,1). This can be also igraph-supported layout ('nicely','fr','kk','sugiyama','randomly','star','circle','gem','dh','graphopt','grid','mds','drl','lgl','sphere')
the logic specifying whether or not circular representations. This will be disabled implicitly if the layout does not support circularity
the logic specifying whether or not only leaves (nodes/labellings) shown. This can be disenabled if the layout does not support tips
the text size of the leave labelings. By default, it is 2. If 0, all labellings will be disabled
the leave label direction. It can be "none", "leftright" (aligned to the left- and right-most edge) and "topbottom" (aligned to the top- and bottom-most edge)
the color of the leave labelings
the alpha of the leave labelings
the wrap width of the leave labelings
the offset of the leave labelings aligned to the edge. It is defined as relative to the range of limits (x-limit for left-right, and y-limit for top-bottom)
the size of the leave nodes. By default, it is 0
the x- and y-limit expansion. By default, it is NULL, decided by "node.label.offset"
the edge type. It can be "diagonal" (default) , "link" (straight lines), "arc", "fan" (curves of different curvature), "elbow"
the color of edges
the alpha of edges
the width of edges
additional graphic parameters (such as size, color) used in ggrepel::geom_text_repel to control labels
a ggplot2 object appended with 'ig' and 'data' which should contain columns 'x','y','name' (the same as V(ig)$name), 'label' (if not given in ig, a 'name' varient). Also contain 'leaf' (T/F), 'depth' (the number of step to the root) for tree-like graph with certain layouts.
# NOT RUN {
library(XGR)
RData.location <- "http://galahad.well.ox.ac.uk/bigdata"
AA.template <- xRDataLoader("AA.template",
RData.location=RData.location)
# consensus tree
ig <- AA.template$consensus$ig
# Default: partition-like circular layout
# none
gp <- xGGraph(ig, node.label.direction="none", node.label.wrap=50)
# leftright
gp <- xGGraph(ig, node.label.direction="leftright", node.label.wrap=50,
node.label.offset=0.5)
# topbottom
gp <- xGGraph(ig, node.label.direction="topbottom", node.label.wrap=50,
node.label.offset=0.5)
# advanced usage
## ggraph layouts
gp <- xGGraph(ig, layout='dendrogram',
node.label.direction="leftright")
gp <- xGGraph(ig, layout='treemap')
gp <- xGGraph(ig, layout='circlepack')
## igraph layouts
set.seed(825)
gp <- xGGraph(ig, layout='nicely', node.label.direction="leftright")
gp <- xGGraph(ig, layout='kk')
gp <- xGGraph(ig, layout='fr', node.label.direction="leftright")
gp <- xGGraph(ig, layout='gem')
# }
Run the code above in your browser using DataLab