elynx-tree-0.1.0: Handle phylogenetic trees

Copyright(c) Dominik Schrempf 2019
LicenseGPL-3
Maintainerdominik.schrempf@gmail.com
Stabilityunstable
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

ELynx.Data.Tree.Bipartition

Contents

Description

Creation date: Fri Aug 30 15:28:17 2019.

Bipartitions are weird in that > Bipartition x y == Bipartition y x is True.

Also, > Bipartition x y > Bipartition y x is False, even when x > y.

That's why we have to make sure that for > Bipartition x y we always have x >= y.

Synopsis

The Bipartition data type.

data Bipartition a Source #

Each branch of a tree partitions the leaves of the tree into two Subsets, or a bipartition. Also the order of the two partitions of the Bipartition is not important (see the Eq instance).

bps :: Bipartition a -> (Subset a, Subset a) Source #

Tuple of partitions

bp :: Ord a => Subset a -> Subset a -> Bipartition a Source #

Create a bipartition from two Sets.

bpmap :: (Ord a, Ord b) => (a -> b) -> Bipartition a -> Bipartition b Source #

Map a function over all elements in the Bipartitions.

bphuman :: (a -> String) -> Bipartition a -> String Source #

Show a bipartition in a human readable form. Use a provided function to extract the valuable information.

Working with Bipartitions.

bipartition :: Ord a => Tree a -> Bipartition a Source #

For a bifurcating root, get the bipartition induced by the root node.

bipartitions :: Ord a => Tree a -> Set (Bipartition a) Source #

Get all bipartitions of the tree.

bipartitionToBranchLength Source #

Arguments

:: (Ord a, Ord b, Monoid c) 
=> (a -> b)

Convert node labels to leaves (usually leaf names)

-> (a -> c)

Get length of branch attached to node

-> Tree a

Tree to dissect

-> Map (Bipartition b) c 

For a given rose Tree, remove all degree two nodes and reconnect the resulting disconnected pairs of branches and sum their branch lengths. For this operation, a combining binary function and a unity element is required, and so we need the Monoid type class constraint. Now, each branch on the tree defines a unique Bipartition of leaves. Convert a tree into a Map from each Bipartition to the length of the branch inducing the respective Bipartition. The relevant information about the leaves is extracted from the (leaf) nodes with a given function. Also check if leaves are unique.

compatible :: (Show a, Ord a) => Bipartition a -> Subset a -> Bool Source #

Determine compatibility between an bipartition and a subset. If both subsets of the bipartition share elements with the given subset, the bipartition is incompatible with this subset. If all elements of the subset are either not in the bipartition or mapping to one of the two subsets of the bipartition, the bipartition and the subset are compatible. See also compatible.