public documentation
Documentation for PhyloPlots
's public (exported) functions.
index
functions
PhyloPlots.plot
— Methodplot(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 ifstyle = :fulltree
, and 0 ifstyle = :majortree
(making the arrows appear as segments).minorlinetype
: type of lines used for minor edges, represented by arrows. Default is "solid" under the major-tree style, and "longdash" under the full tree style.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 have labels such as "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
andedgecex = 1
: character expansion for labels in thenodelabel
andedgelabel
data frames.nodelabeladj = 1
andedgelabeladj = [.5,0]
: position adjustment to place the labels fromedgelabel
andnodelabel
data frames.
colors:
edgecolor = "black"
: color for tree edges if a single color is given. To vary edge colors, use a dictionary to map the number of each edge to its desired color. In that case, unmapped edges are given thedefaultedgecolor
.majorhybridedgecolor = "deepskyblue4"
: color for major hybrid edges.minorhybridedgecolor = "deepskyblue"
: color for minor hybrid edges. Both are ignored ifedgecolor
is a dictionary.defaultedgecolor
: default is "black" ifedgecolor
is a dictionary, oredgecolor
otherwise. Used to draw the segments representing each node.edgenumbercolor = "grey"
: color for edge numbers.edgelabelcolor = "black"
: color for labels in theedgelabel
data frame.nodelabelcolor = "black"
: color for labels in thenodelabel
data frame.
Output the following named tuple, that can be used for downstream 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,
arrow_x_lo, arrow_x_hi, arrow_y_lo, arrow_y_hi,
node_data, edge_data)
:xmin
: minimum x value of the plot:xmax
: maximum x value of the plot:ymin
: minimum y value of the plot:ymax
: maximum y value of the plot:node_x
: x values of the nodes in net.node in their respective order:node_y
: y values of the nodes:node_y_lo
: y value of the beginning of the vertical bar representing the clade at each node:node_y_hi
: y value of the end of the vertical bar:edge_x_lo
: x value of the beginning of the edges innet.edge
in their respective order. An edge (or branch) in the network is represented by 2 segments if it is a minor edge under the:fulltree
style.:edge_*
give the coordinates of the first (horizontal) segment for these minor edges, and the coordinates of the unique (horizontal) segment for major edges (tree of major hybrid edges).:edge_x_hi
: x value of the end of the edges:edge_y_lo
: y value of the beginning of the edges:edge_y_hi
: y value of the end of the edges:arrow_x_lo
: x value for the beginning of the arrows, for minor hybrid edges, listed in the same order as infilter(e -> !e.ismajor, net.edge)
.:arrow_x_hi
: same, but for the end of arrows:arrow_y_lo
: y values for the beginning of arrows:arrow_y_hi
: same, but for the end of arrows:node_data
: node data frame: see section Adding labels for more:edge_data
: edge data frame
Note that plot
actually modifies some (minor) attributes of the network, as it calls PhyloNetworks.directedges!
and PhyloNetworks.preorder!
(unless with option preorder = false
, which is not recommended).
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.
RCall.sexp
— Methodfunction 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)