public documentation

Documentation for PhyloPlots's public (exported) functions.

index

functions

PhyloPlots.plotMethod
plot(net::HybridNetwork)

Plot a network with edges going from left to right and taxa (leaves) placed on the right, using R graphics. Optional arguments are listed below.

lines forming the network:

  • useedgelength = false: if true, the tree edges and major hybrid edges are drawn proportionally to their length. Minor hybrid edges are not, however. Note that edge lengths in coalescent units may scale very poorly with time.
  • style = :fulltree: symbol indicating the style of the diagram
    • :majortree will simply draw minor edges onto the major tree.
    • :fulltree will draw minor edges as their own branches in the tree, in the same style used by icytree. This is useful for overlapping or confusing networks.
  • arrowlen: the length of the arrow tips in the full tree style. The default is 0.1 if style = :fulltree, and 0 if style = :majortree (making the arrows appear as segments).
  • edgewidth=1: width of horizontal (not diagonal) edges. To vary them, use a dictionary to map the number of each edge to its desired width.
  • xlim, ylim: array of 2 values, to determine the axes limits.

tip annotations:

  • showtiplabel = true: if true, taxon labels (names) are shown.
  • tipoffset = 0: to offset tip labels.
  • tipcex = 1: character expansion for tip and internal node names.

nodes & edges annotations:

  • shownodelabel = false: if true, internal nodes are labelled with their names. Useful for hybrid nodes, which do have tags like 'H1'.
  • shownodenumber = false: if true, nodes are labelled with the number used internally.
  • showedgenumber = false: if true, edges are labelled with the number used internally.
  • showedgelength = false: if true, edges are labelled with their length (above).
  • showgamma = false: if true, hybrid edges are labelled with their heritability (below).
  • edgelabel = DataFrame(): dataframe with two columns: the first with edge numbers, the second with labels (like bootstrap values) to annotate edges. empty by default.
  • nodelabel = DataFrame(): dataframe with two columns: the first with node numbers, the second with labels (like bootstrap values for hybrid relationships) to annotate nodes. empty by default.
  • nodecex = 1: character expansion for labels in the nodelabel data frame.
  • edgecex = 1: character expansion for labels in the edgelabel data frame.

colors:

  • edgecolor = "black": color for tree edges.
  • majorhybridedgecolor = "deepskyblue4": color for major hybrid edges.
  • minorhybridedgecolor = "deepskyblue": color for minor hybrid edges.
  • edgenumbercolor = "grey": color for edge numbers.
  • edgelabelcolor = "black": color for labels in the edgelabel data frame.
  • nodelabelcolor = "black": color for labels in the nodelabel data frame.

Output the following named tuple, that can be used for downstream plot annotations with RCall:

(xmin, xmax, ymin, ymax,
 node_x,    node_y,    node_y_lo, node_y_hi,
 edge_x_lo, edge_x_hi, edge_y_lo, edge_y_hi,
 node_data, edge_data)
  1. :xmin: minimum x value of the plot
  2. :xmax: maximum x value of the plot
  3. :ymin: minimum y value of the plot
  4. :ymax: maximum y value of the plot
  5. :node_x: x values of the nodes in net.node in their respective order
  6. :node_y: y values of the nodes
  7. :node_y_lo: y value of the beginning of the vertical bar representing the clade at each node
  8. :node_y_hi: y value of the end of the vertical bar
  9. :edge_x_lo: x value of the beginning of the edges in net.edge in their respective order
  10. :edge_x_hi: x value of the end of the edges
  11. :edge_y_lo: y value of the beginning of the edges
  12. :edge_y_hi: y value of the end of the edges
  13. :node_data: node data frame: see section Adding labels for more
  14. :edge_data: edge data frame

Note that plot actually modifies some (minor) attributes of the network, as it calls PhyloNetworks.directedges! and PhyloNetworks.preorder!.

If hybrid edges cross tree and major edges, you may choose to rotate some tree edges to eliminate crossing edges, using PhyloNetworks.rotate!.

Alternative: a tree or network can be exported with sexp and then displayed with R's "plot" and all its options.

source
RCall.sexpMethod
function sexp(net::HybridNetwork)

Export a HybridNework object to the R language as either phylo or evonet object (depending on degree of hybridization) recognized by the R package ape. Used by the $object syntax and by @rput to use a Julia object in R: see the examples below. Makes it easy to plot a Julia tree or network using plotting facilities in R.

Examples

julia> using RCall
julia> using PhyloNetworks
julia> net = readnewick("(((A:.2,(B:.1)#H1:.1::0.9):.1,(C:.11,#H1:.01::0.1):.19):.1,D:.4);");
R> library(ape); # type $ to switch from julia to R
R> $net

    Evolutionary network with 1 reticulation

               --- Base tree ---
Phylogenetic tree with 4 tips and 5 internal nodes.

Tip labels:
  A, B, C, D

Rooted; includes branch lengths.

julia> @rput net; # press the delete key to switch from R back to julia

R> net

    Evolutionary network with 1 reticulation

               --- Base tree ---
Phylogenetic tree with 4 tips and 5 internal nodes.

Tip labels:
  A, B, C, D

Rooted; includes branch lengths.

R> str(net)
List of 7
 $ edge               : int [1:8, 1:2] 5 5 6 6 7 8 8 9 6 4 ...
 $ reticulation.length: num 0.01
 $ Nnode              : int 5
 $ edge.length        : num [1:8] 0.1 0.4 0.1 0.19 0.11 0.2 0.1 0.1
 $ reticulation       : int [1, 1:2] 7 9
 $ reticulation.gamma : num 0.1
 $ tip.label          : chr [1:4] "A" "B" "C" "D"
 - attr(*, "class")= chr [1:2] "evonet" "phylo"

R> plot(net)
source