Most relevant functions
InPhyNet.inphynet — Function
Runs the InPhyNet algorithm on the given distance matrix and constraint networks where the entries in namelist correspond to indices in D.
Arguments
use_heuristic::Bool(default=true): whether or not InPhyNet should use a heuristic to determine whether a given merge will result in a future conflict. Setting this value tofalsewill sharply improve runtimes but will almost always lead to algorithm failure due to merging conflicts if the input data are not very close to ground truth (even with the pairwise fallback algorithminphynetpairwise).refuse_pairwise::Bool(default=false): whether InPhyNet should refuse to run the pairwise fallback algorithminphynetpairwiseif the main algorithm fails. Can lead to algorithm failure if set totrue- only change if you know what you're doing.
InPhyNet.calculateAGID — Function
calculateAGID(Ns::AbstractVector{HybridNetwork})Calculates the Average Gene tree Internode Distance for all pairs of taxa across all networks in Ns.
Returns
- AGID matrix
- names of taxa corresponding to rows/columns in the AGID matrix
All documented functions
InPhyNet.are_compatible_after_mergeInPhyNet.buildgraphInPhyNet.calculateAGICInPhyNet.calculateAGIDInPhyNet.calculateAGIDInPhyNet.calculate_average_network_metricInPhyNet.centroid_edge_decompositionInPhyNet.check_constraint!InPhyNet.check_constraints!InPhyNet.connectnodes!InPhyNet.find_not_in_path_edge_vectorInPhyNet.find_valid_node_pathInPhyNet.findoptQidxInPhyNet.findsiblingpairsInPhyNet.findvalidpairsInPhyNet.fuseredundantedges!InPhyNet.gather_hyb_descendants_outside_of_pathInPhyNet.getLeavesUnderEdgeInPhyNet.getMidSplitEdgeInPhyNet.has_direct_root_connectionInPhyNet.inphynetInPhyNet.inphynetInPhyNet.inphynetpairwiseInPhyNet.internodecountInPhyNet.internodedistanceInPhyNet.loadconflictexampleInPhyNet.log_edge_path_retics_from_nodeInPhyNet.major_mrcaInPhyNet.majorinternodecountInPhyNet.majorinternodedistanceInPhyNet.mergesubnets!InPhyNet.placeretics!InPhyNet.prune_networkInPhyNet.removeredundantedges!InPhyNet.root_constraints!InPhyNet.sateIdecompInPhyNet.splitAtEdgeInPhyNet.updateconstraints!InPhyNet.vecreplace!
InPhyNet.are_compatible_after_merge — Method
Heuristic for determining whether the set of networks ns are compatible.
InPhyNet.buildgraph — Method
Converts the tree/network net into a SimpleGraph to leverage already implemented pathfinding algorithms.
Arguments
- includeminoredges (default=true): if true, the entire network is translated to a graph. Otherwise, only tree-like edges (other than those in
alwaysinclude) are retained. - alwaysinclude (default=nothing): edges that should always be included in the graph, regardless of the value of
includeminoredges - withweights (default=false): return a set of weights corresponding to branch lengths as well
- removeredundantedgecost (default=false): if true, finds all the nodes that would be removed via
removeredundantedges!and sets their weights inWto 0
InPhyNet.calculateAGIC — Method
calculateAGIC(Ns::AbstractVector{HybridNetwork})Calculates the Average Gene tree Internode Counts for all pairs of taxa across all networks in Ns. If allow_missing_pairs is false, an error will be thrown if there are pairs of taxa that never appear in Ns together. Otherwise, entries for taxa that never appear together will be set to default_missing_value.
Returns
- AGIC matrix
- names of taxa corresponding to rows/columns in the AGID matrix
InPhyNet.calculateAGID — Method
calculateAGID(Ns::AbstractVector{HybridNetwork})Calculates the Average Gene tree Internode Distance for all pairs of taxa across all networks in Ns.
Returns
- AGID matrix
- names of taxa corresponding to rows/columns in the AGID matrix
InPhyNet.calculate_average_network_metric — Method
Calculates pairwise_metric on each pair of networks in Ns. Called by calculateAGIC and calculateAGID. pairwise_metric must be a function that takes a HybridNetwork as its first positional input, must accept the named argument namelist, and must return a 2-Tuple of (A, B), where A is the pairwise metric applied to all pairs of taxa in the supplied network, and B is the namelist used or generated by the fxn.
InPhyNet.centroid_edge_decomposition — Method
Slightly adjusted implementation of the decomposition algorithm from SATe-I that takes a maximum and a minimum subset size.
InPhyNet.check_constraint! — Function
Checks validity of a single input constraint networks. Checks include:
- All nodes have exactly 3 edges except the root (unless the network is a single taxa)
- Reticulations do not lead directly into other reticulations
InPhyNet.check_constraints! — Method
Checks validity of input constraints. So far, the only check is to make sure that all nodes have exactly 3 edges except for the root.
InPhyNet.connectnodes! — Method
Deals with all the overhead of connecting two nodes with an edge. Returns the edge used to connect the nodes.
InPhyNet.find_not_in_path_edge_vector — Method
Helper function for when an edge (notinpath_edge) appears on but not within a merge path. Finds and returns: 1. Whether the edge should be logged with direction "to" or "from" 2. Whether the edge should be associated with subnetedgei or subnetedgej
InPhyNet.find_valid_node_path — Method
Helper function that finds a path in net from nodei to nodej. If that path has 2 or more reticulations in it, the cost to include a hybrid in the path is incrementally increased until only 1 reticulation is in the path.
InPhyNet.findoptQidx — Method
findoptQ(D::Matrix{Float64}, idxpairs::Vector{Tuple{<:Integer, <:Integer}})Finds the minimizer (i, j) among all pairs (i, j) in idxpairs for Q, a matrix computed from D.
InPhyNet.findsiblingpairs — Method
findsiblingpairs(net::HybridNetwork)Finds sibling pairings for all the leaves in a single network. These pairs are valid for net but may not be valid when the other constraint networks are also considered. Returns a vector of tuples of nodes corresponding to siblings.
InPhyNet.findvalidpairs — Method
findvalidpairs(constraints::Vector{HybridNetwork}, constraint_sibling_pairs, namelist::AbstractVector{<:AbstractString})Finds all valid sibling pairs among the constraint networks.
InPhyNet.fuseredundantedges! — Method
Helper function to remove redundant edges (e.g. A –> (internal node) –> (internal node)) that arise from one case of the function mergeconstraintnodes!.
Redundant nodes in this case will always have only two edges while not being the root.
InPhyNet.gather_hyb_descendants_outside_of_path — Method
Helper function used at one point in mergeconstraintnodes!. Gets all of the descendants of node that do not have any children and are not in path
InPhyNet.getLeavesUnderEdge — Method
Gets all the leaf nodes underneath edge edge.
InPhyNet.getMidSplitEdge — Method
Finds a branch in tre that, when pruned on, splits the tree roughly in half.
InPhyNet.has_direct_root_connection — Method
Helper function - returns true if the node node is connected directly to the root of net, or if the path connecting node to net's root is multiple redundant edges (e.g. returns true for A in the net: "((((((A))))), (B,C));")
InPhyNet.inphynet — Method
Runs the InPhyNet algorithm on the given distance matrix and constraint networks where the entries in namelist correspond to indices in D.
Arguments
use_heuristic::Bool(default=true): whether or not InPhyNet should use a heuristic to determine whether a given merge will result in a future conflict. Setting this value tofalsewill sharply improve runtimes but will almost always lead to algorithm failure due to merging conflicts if the input data are not very close to ground truth (even with the pairwise fallback algorithminphynetpairwise).refuse_pairwise::Bool(default=false): whether InPhyNet should refuse to run the pairwise fallback algorithminphynetpairwiseif the main algorithm fails. Can lead to algorithm failure if set totrue- only change if you know what you're doing.
InPhyNet.inphynetpairwise — Function
Runs the "pairwise" version of the InPhyNet algorithm, with the following steps:
- Instead of merging all constraints simultaneously, merge
constraints[1]andconstraints[2]into a new intermediate networkNhat12(using the portions ofDandnamelistthat pertain only to these constraints). - Remove
constraints[1]andconstraints[2]from the list of constraints. - Add
Nhat12to the list of constraints. - Repeat until
constraintshas only 1 network remaining: this network is the final inferred network.
This algorithm will never fail and is used as a fallback for when the main InPhyNet algorithm fails in its first round.
For details on the method's arguments, see inphynet (the arguments are identical).
InPhyNet.internodecount — Method
internodecount(N::HybridNetwork; namelist::Union{Nothing,<:AbstractVector{String}}=nothing)Calculates internode counts between all pairs of taxa in network N. WARNING: treats N as unrooted
InPhyNet.internodedistance — Method
internodedistance(N::HybridNetwork; namelist::Union{Nothing,<:AbstractVector{String}}=nothing)Calculates internode distance between all pairs of taxa in network N.
InPhyNet.loadconflictexample — Method
Loads the distance matrix D, namelist namelist, and constraint networks constraints necessary to reproduce the merge conflict example shown in the Appendices of the InPhyNet manuscript. Further details are provided upon executing the function in the terminal.
InPhyNet.log_edge_path_retics_from_node — Method
Helper function
InPhyNet.major_mrca — Method
Gets the MRCA of nodei and nodej along their major tree.
InPhyNet.majorinternodecount — Method
majorinternodecount(N::HybridNetwork)Calculates major internode counts between all pairs of taxa in the major displayed tree of network N. If N is a tree, then internode counts are as expected for a tree.
InPhyNet.majorinternodedistance — Method
majorinternodedistance(N::HybridNetwork)Calculates internode distances between all pairs of taxa in the major displayed tree of network N. If N is a tree, then internode distances are as expected for a tree.
InPhyNet.mergesubnets! — Method
Merges two unrooted SubNets into a single unrooted SubNet Returns the merged subnet AND the edges in the merged net corresponding to where reticulations will be placed if there are corresponding reticulations discovered in the constraints.
IMPORTANT: this function should NOT make copies of edges or nodes, object references are stored and used in the main merging algorithm
InPhyNet.placeretics! — Method
Updates net to include the reticulations that we've kept track of along the way in our algo but haven't placed yet.
InPhyNet.prune_network — Method
Returns a list of networks where each entry is a copy of net pruned to include only the taxa named in each subset contained in subsets. subsets can also be an individual vector of strings instead of a nested vector (see examples below).
Example
net = readnewick("((t1,t2),(t3,t4));")
prune_network(net, [["t1", "t2"], ["t3", "t4"]])
> 2-element Vector{HybridNetwork}: (t1, t2); and (t3, t4);
prune_network(net, ["t1", "t2", "t3"])InPhyNet.removeredundantedges! — Method
Helper function that removes redundant edges in the graph that exist when some hybrids are pruned from the graph.
InPhyNet.root_constraints! — Method
If any constraints are unrooted, picks a root node from any node directly under the root (somewhat randomly).
InPhyNet.sateIdecomp — Method
Performs subset decomposition as outlines in SATe-I on inittree. Returns vector of vector of names, e.g. [["a", "b"], ["c", "d", "e"]]
InPhyNet.splitAtEdge — Method
Splits tre into two trees at its longest branch.
InPhyNet.updateconstraints! — Method
Updates constraint networks after (i, j) with names (nodenamei, nodenamej) have been merged. Also updates reticmap to keep track of any reticulations that get removed in this process.
By convention we keep nodenamei and replace node names with nodenamej
InPhyNet.vecreplace! — Method
Helper function for manipulating graph adjacency lists.