public documentation

Documentation for PhyloPlots's public (exported) functions.

index

functions

PhyloPlots.plotMethod
plot(net::HybridNetwork)

Plot a network 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. if style = :fulltree, then arrowlen = 0.2. otherwise, arrowlen = 0, which makes 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 witdth.
  • xlim, ylim : array of 2 values, to determine the axes limits

tip annotations:

  • showtiplabel = true : if true, taxon labels (names) are shown.
  • tipoffset = 0.0 : to offset tip labels
  • tipcex=1.0: 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.0: character expansion for labels in the nodelabel data frame
  • edgecex=1.0: 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 tuple, that can be used for downstream plot annotations with RCall:

(xmin, xmax, ymin, ymax,
 node_x, node_y, node_yB, node_yE,
 edge_xB, edge_xE, edge_yB, edge_yE,
 ndf, edf)
  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_yB : y value of the beginning of the verticle bar
  8. node_yE : y value of the end of the verticle bar
  9. edge_xB : x value of the beginning of the edges in net.edge in their respective order
  10. edge_xE : x value of the end of the edges
  11. edge_yB : y value of the beginning of the edges
  12. edge_yE : y value of the end of the edges
  13. ndf : node data frame: see section Adding labels for more
  14. edf : edge data frame

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

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

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

source
PhyloPlots.plotMethod
plot(model::TwoBinaryTraitSubstitutionModel)

Display substitution rates for a trait evolution model for two possibly dependent binary traits; using R via RCall. Adapted from fitPagel functions found in the R package phytools.

Examples

julia> using PhyloNetworks

julia> m = TwoBinaryTraitSubstitutionModel([2.0,1.2,1.1,2.2,1.0,3.1,2.0,1.1],
                ["carnivory", "noncarnivory", "wet", "dry"])
Substitution model for 2 binary traits, with rate matrix:
                     carnivory-wet    carnivory-dry noncarnivory-wet noncarnivory-dry
    carnivory-wet                *           1.0000           2.0000           0.0000
    carnivory-dry           3.1000                *           0.0000           1.1000
 noncarnivory-wet           1.2000           0.0000                *           2.0000
 noncarnivory-dry           0.0000           2.2000           1.1000                *

julia> plot(m);
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.

code inspired from Phylo.jl

Examples

julia> using RCall
julia> using PhyloNetworks
julia> net = readTopology("(((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