NexusTokensToInteger() converts the character matrix returned by
ReadCharacters() to an integer matrix, mapping polymorphic,
ambiguous (?), and inapplicable (-) tokens to NA_integer_ or to the
first/last state listed in the polymorphism, depending on polymorphism.
Usage
NexusTokensToInteger(tokens, polymorphism = c("?", "first", "last"))Arguments
- tokens
Character matrix as returned by
ReadCharacters(), a character vector as returned byNexusTokens(), or aphyDatobject.- polymorphism
Character string specifying how to handle polymorphic tokens such as
"(01)"or"{12}":"?"(default)Treat as the NEXUS missing-data token: map to
NA_integer_."first"Use the first state digit inside the brackets.
"last"Use the last state digit inside the brackets.
Tokens
"?"and"-"always map toNA_integer_regardless ofpolymorphism.
Details
Only digit states 0..9 are recognised; non-digit symbols (and any
token whose interior contains no digits) become NA_integer_.
Polymorphism extraction (polymorphism = "first"/"last") likewise
considers digits only.
If tokens is a phyDat object it is first converted via
PhyDatToMatrix() with ambigNA = TRUE, inappNA = TRUE, so that
fully-ambiguous and inapplicable rows become NA_integer_ and only
true partial polymorphisms are subject to the polymorphism rule.
See also
Other phylogenetic matrix conversion functions:
Decompose(),
MatrixToPhyDat(),
Reweight(),
StringToPhyDat()