Network manipulation
The package contains many utilities to extract information about phylogenetic networks, and to modify networks. Functions that are not exported are more likely to experience breaking changes in future versions, but can be used by prefixing their name with PhyloNetworks.
.
Below is a list of the most useful functions. They typically assume a bicombining network, that is, a network in which each hybrid node has exactly 2 parents (never more).
Getting information on a network
overall network information
tiplabels
for taxon labelsgetroot
gives the root nodepairwisetaxondistancematrix
for average distancesvcv
for the variance-covariance matrix between taxa under a Brownian Motion model along the network, andsharedpathmatrix
for the variance-covariance between all nodes (not just leaves)istimeconsistent
:true
orfalse
, to know if for all nodes, the various paths from the root to that node have the same length (as expected if length was proportional to time)getnodeages
assuming the network is time-consistent and ultrametricdisplayedtrees
ormajortree
to get the displayed trees or major tree, respectivelyhardwiredclusters
to get all clusters of taxa on a networkbiconnectedcomponents
andPhyloNetworks.blobinfo
give information about the blobs found within a network; alsoPhyloNetworks.biconnectedcomponent_entrynodes
,PhyloNetworks.biconnectedcomponent_exitnodes
, andblobdecomposition
treeedgecomponents
are the components after removing hybrid edgescheckroot!
to check that the graph is a valid semidirected network with a root node in a admissible rooting position
The following functions all compute distances from the root to each node. Their differ in how they handle time inconsistency: when the distance from the root to a node varies across multiple paths from the root to that node.
node information
To learn about nodes and how some might be related or connected, one can use:
PhyloNetworks.isdescendant
andPhyloNetworks.isconnected
can be used to learn about the relationship between two nodeshassinglechild
getparent
orgetparents
if the node is a hybridgetparentminor
getchild
orgetchildren
if the node has more than one childisrootof
To learn about the edges connected to a given node, one can use:
edge information
To learn about the nodes related connected to a given edge, one can use the following functions:
PhyloNetworks.descendants
for the clade ("hardwired cluster") below an edgegetparent
getchild
getpartneredge
gives the hybrid partner of an edge, if it is the parent edge of a hybrid node.isparentof
,ischildof
can inform whether an edge and node are connectedhardwiredcluster
to get the cluster of taxa below a particular edge
Modifying a network
To modify some of the core components of a network:
rootonedge!
,rootatnode!
: very useful to root with an outgroup, androtate!
to improve plotsnni!
to perform a semidirected nearest neighbor interchangePhyloNetworks.fliphybrid!
to flip the direction of a hybrid edgePhyloNetworks.unzip_canonical!
to "unzip" (or zip down) all reticulations, orPhyloNetworks.rezip_canonical!
to undo.setlength!
andsetlengths!
to change the length of one or more edges, andsetgamma!
to change a hybrid edge inheritance γ
To remove components from a network:
deleteleaf!
deleteaboveLSA!
: the "least stable ancestor" may be different from the rootdeletehybridthreshold!
to simplify a network by deleting edges with small γ'sPhyloNetworks.shrinkedge!
to contract an edgeremovedegree2nodes!
to suppress degree-2 nodesshrink3cycles!
andshrink2cycles!
to contract "cycles" of 2 or 3 edges, which deletes 1 reticulationPhyloNetworks.deletehybridedge!
to remove one hybrid edge.
To add components to a network:
To modify some internal attributes, that don't affect the network topology or edge parameters:
To calibrate a network (modify its edge lengths):
calibratefrompairwisedistances!
. This documentation has little about calibration so far, but see this tutorial
Comparing two networks
hardwiredclusterdistance
: extends the Robinson-Foulds distance. It's a dissimilarity measure on networks: a dissimilarity of 0 does not guarantee that the 2 networks have the same topology in general. But it does if the networks are in some classes (e.g. trees, level-1, tree-child, and others).