plot.agraph: Plot an admixture graph.

Description Usage Arguments Value See Also Examples

Description

This is a basic drawing routine for visualising the graph. Uses Nelder-Mead algorithm and complicated heuristic approach to find aestethic node coordinates, but due to bad luck or an oversight in the heuristics, especially with larger graphs, might sometimes produce a weird looking result. Usually plotting again helps and if not, use the optional parameters to help the algorithm or try the faster and deterministic function fast_plot (which unfortunately is not very good at handling multiple admixture events).

Usage

1
2
3
4
5
6
7
## S3 method for class 'agraph'
plot(x, show_leaf_labels = TRUE, draw_leaves = TRUE,
  color = "yellowgreen", show_inner_node_labels = FALSE,
  draw_inner_nodes = FALSE, inner_node_color = color,
  show_admixture_labels = FALSE, parent_order = list(),
  child_order = list(), leaf_order = NULL, fix = list(), platform = 1,
  title = NULL, ...)

Arguments

x

The admixture graph.

show_leaf_labels

A flag determining if leaf names are shown.

draw_leaves

A flag determining if leaf nodes are drawn as little circles.

color

Color of all drawn nodes unless overriden by inner_node_color.

show_inner_node_labels

A flag determining if the plot should include the names of inner nodes.

draw_inner_nodes

A flag determining if inner nodes are drawn as little circles.

inner_node_color

Color of inner node circles, if drawn.

show_admixture_labels

A flag determining if the plot should include the names of admixture proportions.

parent_order

An optional list of instuctions on which order from left to right to draw the parents of nodes. The list should contain character vectors of parents with the name of the child, e.g. child = c("left_parent", "right_parent"). Using automated heuristics for nodes not specified.

child_order

An optional list of instuctions on which order from left to right to draw the children of nodes. The list should contain character vectors of children with the name of the parent, e.g. parent = c("left_child", "right_child"). Using automated heuristics for nodes not specified.

leaf_order

An optional vector describing in which order should the leaves be drawn. Using automated heuristic depending on parent_order and child_order if not specified. Accepts both a character vector of the leaves or a numeric vector interpreted as a permutation of the default order.

fix

If nothing else helps, the list fix can be used to correct the inner node coordinates given by the heuristics. Should contain numeric vectors of length 2 with the name of an inner node, e.g. inner_node = c(0, 10), moving inner_node to the right 10 units where 100 is the plot width. Non-specified inner nodes are left in peace.

platform

By default admixture nodes are drawn with a horizontal platform for proportion labels, the width of which is half the distance between any two leaves. The number platform tells how many default platform widths should the platforms be wide, i. e. zero means no platform.

title

Optional title for the plot.

...

Additional plotting options.

Value

A plot.

See Also

agraph

fast_plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
leaves <- c("salmon", "sea horse", "mermaid", "horse", "human", "lobster")
inner_nodes <- c("R", "s", "t", "u", "v", "w", "x", "y", "z")
edges <- parent_edges(c(edge("salmon", "t"),
                        edge("sea horse", "y"),
                        edge("mermaid", "z"),
                        edge("horse", "w"),
                        edge("human", "x"),
                        edge("lobster", "R"),
                        edge("s", "R"),
                        edge("t", "s"),
                        edge("u", "t"),
                        edge("v", "s"),
                        edge("w", "v"),
                        edge("x", "v"),
                        admixture_edge("y", "u", "w"),
                        admixture_edge("z", "u", "x")))
admixtures <- admixture_proportions(c(admix_props("y", "u", "w", "a"),
                                      admix_props("z", "u", "x", "b")))
graph <- agraph(leaves, inner_nodes, edges, admixtures)
plot(graph, show_inner_node_labels = TRUE)

# Suppose now that we prefer to have the outgroup "lobster" on the right side.
# This is achieved by telling the algorithm that the children of "R" should be in
# the order ("s", "lobster"), from left to right:

plot(graph, child_order = list(R = c("s", "lobster")))

# Suppose further that we prefer to have "mermaid" and "human" next to each other,
# as well as "sea horse" and "horse". This is easily achieved by rearranging the leaf
# order proposed by the algorithm. We can also fine-tune by moving "y" a little bit
# to the right, make the admixture platforms a bit shorter, color the nodes, show the
# admixture proportions and give the plot a title:

plot(graph, child_order = list(R = c("s", "lobster")), leaf_order = c(1, 2, 4, 3, 5, 6),
     fix = list(y = c(5, 0)), platform = 0.8, color = "deepskyblue",
     inner_node_color = "skyblue", show_admixture_labels = TRUE,
     title = "Evolution of fish/mammal hybrids")

admixturegraph documentation built on May 2, 2019, 6:02 a.m.