Description Usage Arguments Value See Also Examples
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).
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, ...)
|
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
|
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_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.
|
leaf_order |
An optional vector describing in which order should
the leaves be drawn. Using automated heuristic
depending on |
fix |
If nothing else helps, the list |
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
|
title |
Optional title for the plot. |
... |
Additional plotting options. |
A plot.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.