View source: R/tree_generation.R
Hamming | R Documentation |
The Hamming distance between a pair of taxa is the number of characters with a different coding, i.e. the smallest number of evolutionary steps that must have occurred since their common ancestor.
Hamming(
dataset,
ratio = TRUE,
ambig = c("median", "mean", "zero", "one", "na", "nan")
)
dataset |
Object of class |
ratio |
Logical specifying whether to weight distance against maximum possible, given that a token that is ambiguous in either of two taxa cannot contribute to the total distance between the pair. |
ambig |
Character specifying value to return when a pair of taxa
have a zero maximum distance (perhaps due to a preponderance of ambiguous
tokens).
"median", the default, take the median of all other distance values;
"mean", the mean;
"zero" sets to zero; "one" to one;
"NA" to |
Tokens that contain the inapplicable state are treated as requiring no steps to transform into any applicable token.
Hamming()
returns an object of class dist
listing the Hamming
distance between each pair of taxa.
Martin R. Smith (martin.smith@durham.ac.uk)
Used to construct neighbour joining trees in NJTree()
.
dist.hamming()
in the phangorn package provides an alternative
implementation.
tokens <- matrix(c(0, 0, "0", 0, "?",
0, 0, "1", 0, 1,
0, 0, "1", 0, 1,
0, 0, "2", 0, 1,
1, 1, "-", "?", 0,
1, 1, "2", 1, "{01}"),
nrow = 6, ncol = 5, byrow = TRUE,
dimnames = list(
paste0("Taxon_", LETTERS[1:6]),
paste0("Char_", 1:5)))
dataset <- MatrixToPhyDat(tokens)
Hamming(dataset)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.