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
tiplabelsfor taxon labelsgetrootgives the root nodeleaststableancestorgive the least stable ancestor (LSA) of all taxa (their MRCA on a tree), which may be below the rootpairwisetaxondistancematrixfor average distancesvcvfor the variance-covariance matrix between taxa under a Brownian Motion model along the network, andsharedpathmatrixfor the variance-covariance between all nodes (not just leaves)istimeconsistent:trueorfalse, 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)getnodeagesassuming the network is time-consistent and ultrametricdisplayedtreesormajortreeto get the displayed trees or major tree, respectivelyhardwiredclustersto get all clusters of taxa on a networkcheckroot!to check that the graph is a valid semidirected network with a root node in a admissible rooting position
on the network complexity:
istreechildhashybridladder– a hybrid ladder is also called a "stack": one hybrid parent of anotherisgalledin the sense of a galled networkgetlevelbiconnectedcomponentsandPhyloNetworks.process_biconnectedcomponents!to calculate (and store) the blobs in a network; alsoPhyloNetworks.biconnectedcomponent_entrynodes,PhyloNetworks.biconnectedcomponent_exitnodes, andblobdecompositiontreeedgecomponentsare the components after removing hybrid edges
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.isdescendantandPhyloNetworks.isconnectedcan be used to learn about the relationship between two nodeshassinglechildgetparentorgetparentsif the node is a hybridgetparentminorgetchildorgetchildrenif the node has more than one childisrootofleaststableancestor_matrixfor the LSA of all pairs of taxa (or MRCA on a tree: most recent common ancestor)
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.descendantsfor the clade ("hardwired cluster") below an edgegetparentgetchildgetpartneredgegives the hybrid partner of an edge, if it is the parent edge of a hybrid node.isparentof,ischildofcan inform whether an edge and node are connectedhardwiredclusterto 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 edgetreeofblobsto shrink blobs and get the strict tree-like part of the network
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 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).- μ-distances
mudistance_rootedandmudistance_semidirected: they also extend the Robinson-Foulds distance on trees. They are dissimilarities on general networks, but distances on some classes (including tree-child).
Comparing taxa
- average pairwise distances on a network:
pairwisetaxondistancematrix, and from data:PhyloNetworks.hammingdistancematrix, that can be followed byPhyloNetworks.distancecorrection_JC! - f2-distances expected from a network:
expectedf2matrixwhich can be used to get expected f3 and expected f4 statistics:PhyloNetworks.expectedf3matrixandexpectedf4table.