Calculate the parsimony score of a tree given a dataset
Source:R/IWScore.R
, R/tree_length.R
TreeLength.Rd
TreeLength()
uses the Morphy library Brazeau2017TreeSearch
to calculate a parsimony score for a tree, handling inapplicable data
according to the algorithm of Brazeau2019;textualTreeSearch.
Trees may be scored using equal weights, implied weights
Goloboff1993TreeSearch, or profile parsimony
Faith2001TreeSearch.
Usage
IWScore(tree, dataset, concavity = 10L, ...)
TreeLength(tree, dataset, concavity = Inf)
# S3 method for class 'phylo'
TreeLength(tree, dataset, concavity = Inf)
# S3 method for class 'numeric'
TreeLength(tree, dataset, concavity = Inf)
# S3 method for class 'list'
TreeLength(tree, dataset, concavity = Inf)
# S3 method for class 'multiPhylo'
TreeLength(tree, dataset, concavity = Inf)
Fitch(tree, dataset)
Arguments
- tree
A tree of class
phylo
, a list thereof (optionally of classmultiPhylo
), or an integer – in which casetree
random trees will be uniformly sampled.- dataset
A phylogenetic data matrix of phangorn class
phyDat
, whose names correspond to the labels of any accompanying tree.- concavity
Determines the degree to which extra steps beyond the first are penalized. Specify a numeric value to use implied weighting Goloboff1993TreeSearch;
concavity
specifies k in k / e + k. A value of 10 is recommended; TNT sets a default of 3, but this is too low in some circumstances Goloboff2018,Smith2019TreeSearch. Better still explore the sensitivity of results under a range of concavity values, e.g.k = 2 ^ (1:7)
. SpecifyInf
to weight each additional step equally. Specify"profile"
to employ profile parsimony Faith2001TreeSearch.- ...
unused; allows additional parameters specified within ... to be received by the function without throwing an error.
See also
Conduct tree search using
MaximizeParsimony()
(command line),EasyTrees()
(graphical user interface), orTreeSearch()
(custom optimality criteria).See score for each character:
CharacterLength()
.
Other tree scoring:
CharacterLength()
,
LengthAdded()
,
MinimumLength()
,
MorphyTreeLength()
,
TaxonInfluence()
Examples
data("inapplicable.datasets")
tree <- TreeTools::BalancedTree(inapplicable.phyData[[1]])
TreeLength(tree, inapplicable.phyData[[1]])
#> [1] 1117
TreeLength(tree, inapplicable.phyData[[1]], concavity = 10)
#> [1] 52.75785
TreeLength(tree, inapplicable.phyData[[1]], concavity = "profile")
#> → Inapplicable tokens treated as ambiguous for profile parsimony
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> Warning: Can handle max. 2 informative tokens. Dropping others.
#> [1] 3941.387
TreeLength(5, inapplicable.phyData[[1]])
#> [1] 1974 1985 1907 1948 1926