Documentation
¶
Overview ¶
Package timetree provides a representation of a time calibrated phylogenetic tree.
Index ¶
- Variables
- type Collection
- type Tree
- func (t *Tree) Add(id int, brLen int64, name string) (int, error)
- func (t *Tree) AddSister(id int, age, brLen int64, name string) (int, error)
- func (t *Tree) Age(id int) int64
- func (t *Tree) Children(id int) []int
- func (t *Tree) Delete(id int) error
- func (t *Tree) Depth(id int) int
- func (t *Tree) Format()
- func (t *Tree) IsRoot(id int) bool
- func (t *Tree) IsTerm(id int) bool
- func (t *Tree) Len() int64
- func (t *Tree) LenToRoot(id int) int64
- func (t *Tree) MRCA(names ...string) int
- func (t *Tree) Move(age int64) error
- func (t *Tree) Name() string
- func (t *Tree) Nodes() []int
- func (t *Tree) NumInternal() int
- func (t *Tree) Parent(id int) int
- func (t *Tree) Root() int
- func (t *Tree) Set(id int, age int64) error
- func (t *Tree) SetName(id int, name string) error
- func (t *Tree) SubTree(id int, name string) *Tree
- func (t *Tree) TaxNode(name string) (int, bool)
- func (t *Tree) Taxa() []string
- func (t *Tree) Taxon(id int) string
- func (t *Tree) Terms() []string
- func (t *Tree) Validate() error
Constants ¶
This section is empty.
Variables ¶
var ( ErrTreeNoName = errors.New("tree without name") ErrTreeRepeated = errors.New("repeated tree name") )
Tree collection errors
var ( // Newick errors ErrNotNewick = fmt.Errorf("not a newick tree file") ErrUnexpBrLen = fmt.Errorf("unexpected branch length") )
var ( // Tree adding errors ErrAddNoParent = errors.New("parent ID not in tree") ErrAddRepeated = errors.New("repeated taxon name") ErrAddInvalidBrLen = errors.New("invalid branch length") ErrAddNoSister = errors.New("sister ID not in tree") ErrAddRootSister = errors.New("sister ID is the root node") // Tree validation errors ErrValSingleChild = errors.New("node with a single descendant") ErrValUnnamedTerm = errors.New("unnamed terminal") // Age assignments ErrInvalidRootAge = errors.New("invalid root age") ErrOlderAge = errors.New("age to old for node") ErrYoungerAge = errors.New("age to young for node") )
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
A Collection is a collection of phylogenetic trees.
func Newick ¶
Newick reads one or more trees in newick (parenthetical) format. Age set the age of the root node (in years), if age is 0, the age of the root node will be inferred from the largest branch length between any terminal and the root. Branch lengths will be interpreted as million years. Name sets the name of the first tree, any other tree name will be in the form <name>.<number> starting from 1.
func Nexus ¶
func Nexus(r io.Reader, age int64) (*Collection, error)
Nexus reads one or more tree from a nexus file. Age set the age of the root node (in years) if age is 0, the age of the root node will be inferred from the largest branch length between any terminal and the root. Branch lengths will be interpreted as million years.
func ReadTSV ¶
func ReadTSV(r io.Reader) (*Collection, error)
ReadTSV reads a phylogenetic tree from a TSV file.
The TSV must contain the following fields:
-tree, for the name of the tree -node, for the ID of the node -parent, for of ID of the parent node (-1 is used for the root) -age, the age of the node (in years) -taxon, the taxonomic name of the node
Parent nodes should be defined, before any children node. Terminal nodes should have a unique taxonomic name.
Here is an example file:
# time calibrated phylogenetic tree tree node parent age taxon dinosaurs 0 -1 235000000 dinosaurs 1 0 230000000 Eoraptor lunensis dinosaurs 2 0 170000000 dinosaurs 3 2 145000000 Ceratosaurus nasicornis dinosaurs 4 2 71000000 Carnotaurus sastrei
func (*Collection) Add ¶
func (c *Collection) Add(t *Tree) error
Add adds a tree to a tree collection. It will return an error if a the collection has a tree with the name of the added tree or the tree name is empty.
func (*Collection) Names ¶
func (c *Collection) Names() []string
Names return the names of the trees in the collection.
func (*Collection) TSV ¶
func (c *Collection) TSV(w io.Writer) error
TSV encodes a collection of phylogenetic trees into a TSV file.
func (*Collection) Tree ¶
func (c *Collection) Tree(name string) *Tree
Tree returns a tree with a given name.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
A Tree is a time calibrated phylogenetic tree, a set of phylogenetic nodes with a single common ancestor.
func (*Tree) Add ¶
Add adds a node as child of the indicated node ID, using the indicated branch length in years, and a taxon name for the node (that can be empty). It returns the ID of the added node or -1 and an error.
func (*Tree) AddSister ¶
AddSister adds a node as a sister group of the indicated node ID, using the indicated age of the added node and the branch length of the new branch, both in years, and the name of the added node (that can be empty). It returns the ID of the added node or -1 and an error.
func (*Tree) Depth ¶
Depth returns the number of nodes between the indicated node and the root of the tree.
func (*Tree) Format ¶
func (t *Tree) Format()
Format sort the nodes of a tree, changing node IDs if necessary.
func (*Tree) LenToRoot ¶
LenToRoot returns the length (in years) from a node to the root of the tree.
func (*Tree) Move ¶
Move sets the age of the root node (in years), and updates all node ages keeping the branch lengths. The age of the root must be at least equal to the distance to the most recent terminal.
func (*Tree) NumInternal ¶
NumInternal returns the number of internal nodes (i.e., nodes with descendants).
func (*Tree) Parent ¶
Parent returns the ID of the parent of the indicated node. It will return -1 for the root or an invalid node.
func (*Tree) SetName ¶
SetName sets the name of a node, removing any previous name of the node. If the node is not a terminal, the new name must be non-empty.
func (*Tree) SubTree ¶
SubTree creates a new tree from a given node using the indicated name. If no name is given, it will use the node name, or a node identifier.
func (*Tree) TaxNode ¶
TaxNode returns the ID of a node with a given taxon name. It returns false if the taxon does not exists.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
timetree
TimeTree is a tool to manipulate time calibrated phylogenetic trees.
|
TimeTree is a tool to manipulate time calibrated phylogenetic trees. |
timetree/add
Package add implements a command to add a new taxon to a tree.
|
Package add implements a command to add a new taxon to a tree. |
timetree/draw
Package draw implements a command to output a phylogenetic tree from a TSV file into an SVG file.
|
Package draw implements a command to output a phylogenetic tree from a TSV file into an SVG file. |
timetree/format
Package format implements a command to format the trees in a tree file.
|
Package format implements a command to format the trees in a tree file. |
timetree/importcmd
Package importcmd implements a command to import phylogenetic trees from a newick file into tsv files.
|
Package importcmd implements a command to import phylogenetic trees from a newick file into tsv files. |
timetree/list
Package list implements a command to print a list of trees in a tree file.
|
Package list implements a command to print a list of trees in a tree file. |
timetree/newick
Package newick implements a command to output a phylogenetic tree from a TSV file into an equivalent Newick file.
|
Package newick implements a command to output a phylogenetic tree from a TSV file into an equivalent Newick file. |
timetree/rename
Package rename implements a command to set the name of a list of terminals in a tree file.
|
Package rename implements a command to set the name of a list of terminals in a tree file. |
timetree/set
Package set implements a command to set node ages for a list of trees.
|
Package set implements a command to set node ages for a list of trees. |
timetree/sim
Package sim implements a command to simulate a phylogenetic tree.
|
Package sim implements a command to simulate a phylogenetic tree. |
timetree/sub
Package sub implements a command to produce a sub-tree from a phylogenetic tree in a tsv file.
|
Package sub implements a command to produce a sub-tree from a phylogenetic tree in a tsv file. |
timetree/tax
Package tax implements a command to validate the terminal names for a list of trees.
|
Package tax implements a command to validate the terminal names for a list of trees. |
timetree/terms
Package terms implements a command to print the list of terminals in a tree file.
|
Package terms implements a command to print the list of terminals in a tree file. |
Package simulate creates random trees.
|
Package simulate creates random trees. |