toMoment: Convert a Tree from Newick or Matching to Moment Format

toMomentR Documentation

Convert a Tree from Newick or Matching to Moment Format

Description

Converts a phylogenetic tree from a Newick character string or an ape matching matrix into a moment L-matrix object.

Usage

toMoment(inputobject, tip.label = NULL)

Arguments

inputobject

A tree structure represented as a Newick format character string, or a matching object as defined in the ape package.

tip.label

A character vector specifying rearranged labels for the tips. If provided, these must be the original tip labels. Defaults to NULL.

Details

The returned L-matrix class object consists of 5 internal components:

  • L: The L-matrix represented in full square form.

  • L.ut: The L-matrix represented in upper-triangular form.

  • Newick: The Newick string representation of the tree structure.

  • tip.label: A character vector holding the labels of the tips.

  • tip.label.n: An integer specifying the total number of tips.

Value

A moment L-matrix object corresponding to the input phylogenetic tree object.

Author(s)

Kem Phillips kemphillips@comcast.net

References

\insertRef

Phillips2010symmoments

Felsenstein, J. (1990). The Newick tree format. http://evolution.genetics.washington.edu/phylip/newicktree.html

\insertRefDiaconis1998symmoments

See Also

toNewick, toMatching

Examples

# Create a Newick character string
exam.Newick <- "(((a,b),c),d);"

# Convert to a moment L-matrix
exam.moment <- toMoment(exam.Newick)

# Convert to a matching object
exam.matching <- toMatching(exam.moment)

# Convert back to a moment object
backto.moment <- toMoment(exam.matching)


symmoments documentation built on May 27, 2026, 9:06 a.m.