PhyloPlots.jl
PhyloPlots is a Julia package to plot phylogenetic trees and networks.
PhyloNetworks objects can be displayed through R via RCall.
diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 4cf3c41..9333c8a 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.2","generation_timestamp":"2024-12-10T15:09:14","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.2","generation_timestamp":"2024-12-10T22:29:36","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 25e2d23..81b4b36 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -
PhyloPlots is a Julia package to plot phylogenetic trees and networks.
PhyloNetworks objects can be displayed through R via RCall.
Settings
This document was generated with Documenter.jl version 1.8.0 on Tuesday 10 December 2024. Using Julia version 1.11.2.
PhyloPlots is a Julia package to plot phylogenetic trees and networks.
PhyloNetworks objects can be displayed through R via RCall.
Settings
This document was generated with Documenter.jl version 1.8.0 on Tuesday 10 December 2024. Using Julia version 1.11.2.
Documentation for PhyloPlots
's internal functions. Those functions are not exported, but can still be used (like: PhyloPlots.foo()
for a function named foo()
).
PhyloPlots.check_nodedataframe
PhyloPlots.edgenode_coordinates
PhyloPlots.prepare_edgedataframe
PhyloPlots.prepare_nodedataframe
PhyloPlots.rexport
PhyloPlots.check_nodedataframe
— Methodcheck_nodedataframe(net, nodelabel)
Check data frame for node annotations:
PhyloPlots.edgenode_coordinates
— Methodedgenode_coordinates(net, useedgelength::Bool, useSimpleHybridLines::Bool)
Calculate coordinates for plotting later with Gadfly or RCall.
Actually modifies some (minor) attributes of the network, as it calls directedges!
and preorder!
.
output: tuple with the following elements, in which the order of nodes corresponds to the order in net.node
, and the order of edges corresponds to that in net.edge
(filtered to minor edges as needed).
edge_xB
: x coordinate for the Beginning and ...edge_xE
: ... End of each edge, in the same order as in net.edge
edge_yB
: y coordinate for edges, Begin ...edge_yE
: ... and End. Each major edge is drawn as a single horizontal line. Minor hybrid edges are drawn as: a single diagonal segment if useSimpleHybridLines
is true, or as 2 connected segments otherwise: one horizontal (whose length on the x axis can be used to represent the edge length), and the other diagonal to connect the horizontal segment to the child node. edge_*
contains the coordinates for the horizontal segment only, which is reduced to a single point (Begin = End) when using "SimpleHybridLines". minoredge_*
(see below) contains information for the diagonal segment. Agreed, edge_yB
= edge_yE
always (relic from before v0.3: no minoredge output back then, and simple diagonal lines only)node_x
: x and ...node_y
: ... y coordinate at the middle of the vertical bar that represents a node. The (or each) parent edge of the node connects to this middle point, but the node itself is drawn as a vertical bar connected to all it children edges. order: same as in net.node
node_yB
: y coordinates of the Beginning and the ...node_yE
: ... End of the vertical bar representing each node. The x coordinate (Begin & End) of the end points of the vertical bar is the same as that of the mid-point, given by node_x
.minoredge_xB
: x coordinate for the Beginning and ...minoredge_xE
: ... End of the diagonal segment of each minor hybrid edge, in the same order as in filter(e -> !e.ismajor, net.edge)
.minoredge_yB
: y coordinate for the beginning and ...minoredge_yE
: ... end of the diagonal segment of each minor hybrid edge.13-16. xmin
, xmax
, ymin
, ymax
: ranges for the x and y axes.
PhyloPlots.prepare_edgedataframe
— Methodprepare_edgedataframe(net, edgelabel::DataFrame, style::Symbol,
+internals · PhyloPlots.jl internal documentation
Documentation for PhyloPlots
's internal functions. Those functions are not exported, but can still be used (like: PhyloPlots.foo()
for a function named foo()
).
index
PhyloPlots.check_nodedataframe
PhyloPlots.edgenode_coordinates
PhyloPlots.prepare_edgedataframe
PhyloPlots.prepare_nodedataframe
PhyloPlots.rexport
functions
PhyloPlots.check_nodedataframe
— Methodcheck_nodedataframe(net, nodelabel)
Check data frame for node annotations:
- check that the data has at least 2 columns (if it has any)
- check that the first column has integers (to serve as node numbers)
- remove rows with no node numbers
- warning if some node numbers in the data are not in the network.
sourcePhyloPlots.edgenode_coordinates
— Methodedgenode_coordinates(net, useedgelength::Bool, useSimpleHybridLines::Bool)
Calculate coordinates for plotting later with Gadfly or RCall.
Actually modifies some (minor) attributes of the network, as it calls directedges!
and preorder!
.
output: tuple with the following elements, in which the order of nodes corresponds to the order in net.node
, and the order of edges corresponds to that in net.edge
(filtered to minor edges as needed).
edge_xB
: x coordinate for the Beginning and ...edge_xE
: ... End of each edge, in the same order as in net.edge
edge_yB
: y coordinate for edges, Begin ...edge_yE
: ... and End. Each major edge is drawn as a single horizontal line. Minor hybrid edges are drawn as: a single diagonal segment if useSimpleHybridLines
is true, or as 2 connected segments otherwise: one horizontal (whose length on the x axis can be used to represent the edge length), and the other diagonal to connect the horizontal segment to the child node. edge_*
contains the coordinates for the horizontal segment only, which is reduced to a single point (Begin = End) when using "SimpleHybridLines". minoredge_*
(see below) contains information for the diagonal segment. Agreed, edge_yB
= edge_yE
always (relic from before v0.3: no minoredge output back then, and simple diagonal lines only)node_x
: x and ...node_y
: ... y coordinate at the middle of the vertical bar that represents a node. The (or each) parent edge of the node connects to this middle point, but the node itself is drawn as a vertical bar connected to all it children edges. order: same as in net.node
node_yB
: y coordinates of the Beginning and the ...node_yE
: ... End of the vertical bar representing each node. The x coordinate (Begin & End) of the end points of the vertical bar is the same as that of the mid-point, given by node_x
.minoredge_xB
: x coordinate for the Beginning and ...minoredge_xE
: ... End of the diagonal segment of each minor hybrid edge, in the same order as in filter(e -> !e.ismajor, net.edge)
.minoredge_yB
: y coordinate for the beginning and ...minoredge_yE
: ... end of the diagonal segment of each minor hybrid edge.
13-16. xmin
, xmax
, ymin
, ymax
: ranges for the x and y axes.
sourcePhyloPlots.prepare_edgedataframe
— Methodprepare_edgedataframe(net, edgelabel::DataFrame, style::Symbol,
edge_xB, edge_xE, edge_yB, edge_yE,
- minoredge_xB, minoredge_xE, minoredge_yB, minoredge_yE)
Check data frame for edge annotation. edge_*
: Float64 vectors giving the coordinates for the beginning and end of edges. Return data frame with columns
- x, y: coordinates on the plots
- len: node name
- gam: gamma (inheritance value)
- num: node number
- lab: node label
- hyb: is hybrid?
- min: is minor?
sourcePhyloPlots.prepare_nodedataframe
— Methodprepare_nodedataframe(net, nodelabel::DataFrame,
+ minoredge_xB, minoredge_xE, minoredge_yB, minoredge_yE)
Check data frame for edge annotation. edge_*
: Float64 vectors giving the coordinates for the beginning and end of edges. Return data frame with columns
- x, y: coordinates on the plots
- len: node name
- gam: gamma (inheritance value)
- num: node number
- lab: node label
- hyb: is hybrid?
- min: is minor?
sourcePhyloPlots.prepare_nodedataframe
— Methodprepare_nodedataframe(net, nodelabel::DataFrame,
shownodenumber::Bool, shownodename::Bool, labelnodes::Bool,
- node_x, node_y)
Make data frame for node annotation. node_*
should be Float64 vectors. nodelabel
should have columns as required by check_nodedataframe
. shownodename
is to show the name of internal nodes. Leaf names are always included.
Columns of output data frame:
- x, y: coordinates on the plots (from
node_*
) - name: node name
- num: node number
- lab: node label
- lea: is leaf?
sourcePhyloPlots.rexport
— Methodrexport(net::HybridNetwork; maintree=false, useedgelength=true)
Create an RObject of class phylo
(and evonet
depending on the number of hybridizations) recognized by the ape
library in R (S3 object). This RObject can be evaluated using the tools available in the ape
library in R. For example, we can visualize the network using ape
's plot
function.
not exported: sexp
is the best way to go.
Arguments
- useedgelength: if true, export edge lengths from
net
. - maintree: if true, minor hybrid edges are omitted.
Examples
julia> net = readnewick("(((A,(B)#H1:::0.9),(C,#H1:::0.1)),D);");
+ node_x, node_y)
Make data frame for node annotation. node_*
should be Float64 vectors. nodelabel
should have columns as required by check_nodedataframe
. shownodename
is to show the name of internal nodes. Leaf names are always included.
Columns of output data frame:
- x, y: coordinates on the plots (from
node_*
) - name: node name
- num: node number
- lab: node label
- lea: is leaf?
sourcePhyloPlots.rexport
— Methodrexport(net::HybridNetwork; maintree=false, useedgelength=true)
Create an RObject of class phylo
(and evonet
depending on the number of hybridizations) recognized by the ape
library in R (S3 object). This RObject can be evaluated using the tools available in the ape
library in R. For example, we can visualize the network using ape
's plot
function.
not exported: sexp
is the best way to go.
Arguments
- useedgelength: if true, export edge lengths from
net
. - maintree: if true, minor hybrid edges are omitted.
Examples
julia> net = readnewick("(((A,(B)#H1:::0.9),(C,#H1:::0.1)),D);");
julia> phy = PhyloPlots.rexport(net)
RObject{VecSxp}
@@ -54,4 +54,4 @@
$ tip.label : chr [1:4] "A" "B" "C" "D"
$ reticulation : int [1, 1:2] 7 9
$ reticulation.gamma: num 0.1
- - attr(*, "class")= chr [1:2] "evonet" "phylo"
sourceSettings
This document was generated with Documenter.jl version 1.8.0 on Tuesday 10 December 2024. Using Julia version 1.11.2.
+ - attr(*, "class")= chr [1:2] "evonet" "phylo"
Settings
This document was generated with Documenter.jl version 1.8.0 on Tuesday 10 December 2024. Using Julia version 1.11.2.
Documentation for PhyloPlots
's public (exported) 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 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)
: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 in net.edge
in their respective order: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:node_data
: node data frame: see section Adding labels for more:edge_data
: edge data frameNote 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.
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
+ 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 in net.edge
in their respective order: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:node_data
: node data frame: see section Adding labels for more:edge_data
: edge data frameNote 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.
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
@@ -43,4 +43,4 @@
$ tip.label : chr [1:4] "A" "B" "C" "D"
- attr(*, "class")= chr [1:2] "evonet" "phylo"
-R> plot(net)
Settings
This document was generated with Documenter.jl version 1.8.0 on Tuesday 10 December 2024. Using Julia version 1.11.2.
Settings
This document was generated with Documenter.jl version 1.8.0 on Tuesday 10 December 2024. Using Julia version 1.11.2.