| Copyright | (c) Dominik Schrempf 2020 |
|---|---|
| License | GPL-3.0-or-later |
| Maintainer | dominik.schrempf@gmail.com |
| Stability | unstable |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
ELynx.Tree.Measurable
Description
Creation date: Thu Jan 17 14:16:34 2019.
Non-negativity of lengths is not completely ensured. See the documentation of
Length.
Synopsis
- data Length
- toLength :: Double -> Either String Length
- toLengthUnsafe :: Double -> Length
- checkLength :: Length -> Either String Length
- class Measurable e where
- height :: Measurable e => Tree e a -> Length
- rootHeight :: Measurable e => Tree e a -> Length
- distancesOriginLeaves :: Measurable e => Tree e a -> [Length]
- totalBranchLength :: Measurable e => Tree e a -> Length
- normalizeBranchLengths :: Measurable e => Tree e a -> Tree e a
- normalizeHeight :: Measurable e => Tree e a -> Tree e a
- ultrametric :: Measurable e => Tree e a -> Bool
- makeUltrametric :: Measurable e => Tree e a -> Tree e a
Non-negative length
Non-negative length.
However, non-negativity is only checked with toLength, and negative values
can be obtained using the Num and related instances.
Safe operations with conversion from and to length are roughly 50 percent slower.
benchmarking length/length sum foldl' with safe conversion
time 110.4 ms (109.8 ms .. 111.0 ms)
1.000 R² (1.000 R² .. 1.000 R²)
mean 110.2 ms (110.0 ms .. 110.6 ms)
std dev 501.8 μs (359.1 μs .. 730.0 μs)
benchmarking length/length sum foldl' num instance
time 89.37 ms (85.13 ms .. 94.27 ms)
0.996 R² (0.992 R² .. 1.000 R²)
mean 86.53 ms (85.63 ms .. 88.52 ms)
std dev 2.239 ms (1.069 ms .. 3.421 ms)
benchmarking length/double sum foldl'
time 85.47 ms (84.88 ms .. 86.42 ms)
1.000 R² (0.999 R² .. 1.000 R²)
mean 85.56 ms (85.26 ms .. 86.02 ms)
std dev 611.9 μs (101.5 μs .. 851.7 μs)
Instances
toLengthUnsafe :: Double -> Length Source #
Do not check if support value is negative.
class Measurable e where Source #
A data type with measurable and modifiable length.
Methods
getLen :: e -> Length Source #
Get length.
setLen :: Length -> e -> e Source #
Set length.
modLen :: (Length -> Length) -> e -> e Source #
Modify length.
Instances
| Measurable Length Source # | |
| Measurable PhyloExplicit Source # | |
Defined in ELynx.Tree.Phylogeny Methods getLen :: PhyloExplicit -> Length Source # setLen :: Length -> PhyloExplicit -> PhyloExplicit Source # modLen :: (Length -> Length) -> PhyloExplicit -> PhyloExplicit Source # | |
height :: Measurable e => Tree e a -> Length Source #
The maximum distance between origin and leaves.
The height includes the branch length of the stem.
rootHeight :: Measurable e => Tree e a -> Length Source #
The maximum distance between root node and leaves.
Functions on trees
distancesOriginLeaves :: Measurable e => Tree e a -> [Length] Source #
Distances from the origin of a tree to the leaves.
The distances include the branch length of the stem.
totalBranchLength :: Measurable e => Tree e a -> Length Source #
Total branch length of a tree.
normalizeBranchLengths :: Measurable e => Tree e a -> Tree e a Source #
Normalize branch lengths so that the sum is 1.0.
normalizeHeight :: Measurable e => Tree e a -> Tree e a Source #
Normalize height of tree to 1.0.
ultrametric :: Measurable e => Tree e a -> Bool Source #
Check if a tree is ultrametric.
makeUltrametric :: Measurable e => Tree e a -> Tree e a Source #
Elongate terminal branches such that the tree becomes ultrametric.