tree

package
v0.0.0-...-318585b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2014 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotEnoughWeightsError     = errors.New("Not enough weight parameters.")
	NotBinarySpeciesTreeError = errors.New("Species tree is not binary.")
)
View Source
var (
	SpeciesTreeNotUniquelyLabeledError = errors.New("Species tree is not uniquely labeled.")
)

Functions

func BinaryCost

func BinaryCost(gt *Tree, st *SpeciesTree) (dup, loss, dc int, err error)

BinaryCost finds the duplication, loss, and deep coalescence cost for input binary gene tree and species tree.

func RF

func RF(gt *Tree, st *SpeciesTree) (rf int, err error)

RF finds the Robinson-Folds distance for uniquely labeled binary gene tree and species tree.

func RefineGt

func RefineGt(gt *Tree, st *SpeciesTree, method string, weights ...float64) error

A dispatch function

Types

type InvalidEdgeLengthError

type InvalidEdgeLengthError struct {
	EdgeLength string
}

func (InvalidEdgeLengthError) Error

func (err InvalidEdgeLengthError) Error() string

type InvalidMethodError

type InvalidMethodError struct {
	Method string
}

func (InvalidMethodError) Error

func (err InvalidMethodError) Error() string

type InvalidTreeError

type InvalidTreeError struct {
	TreeString string
}

func (InvalidTreeError) Error

func (err InvalidTreeError) Error() string

type Lcamap

type Lcamap struct {
	G   *Tree
	S   *SpeciesTree
	Map []*Node
}

func LcaMap

func LcaMap(t *Tree, st *SpeciesTree) (*Lcamap, error)

Generate `Lcamap` for gene tree and species tree. Assume that every internal genetree node has at least two children

type NoTaxaError

type NoTaxaError struct {
	Taxa string
}

func (NoTaxaError) Error

func (err NoTaxaError) Error() string

type Node

type Node struct {
	Father   *Node
	Children []*Node
	// contains filtered or unexported fields
}

func (*Node) AddChild

func (n *Node) AddChild(c *Node)

func (*Node) IsBinary

func (node *Node) IsBinary() bool

func (*Node) IsInternal

func (node *Node) IsInternal() bool

func (*Node) IsLeaf

func (node *Node) IsLeaf() bool

func (*Node) IsRoot

func (node *Node) IsRoot() bool

func (*Node) NewChild

func (n *Node) NewChild() (child *Node)

func (*Node) Post2List

func (node *Node) Post2List() []*Node

Postorder iterate the tree and put nodes into a list

func (*Node) String

func (n *Node) String() string

Represent the tree (rooted at `n`) in newick format.

type SpeciesTree

type SpeciesTree struct {
	*Tree
	Taxon Taxonmap
	Lca   func(a, b *Node) *Node
}

type Taxonmap

type Taxonmap map[string]*Node

A map that maps taxa to (one of) the corresponding leaf node

type Tree

type Tree struct {
	*Node
	Nodes []*Node
}

func ExampleTree

func ExampleTree(nleaves int) *Tree

func LineTree

func LineTree(nleaves int) *Tree

func LineTree2

func LineTree2(nleaves int) *Tree

func Make

func Make(s string) (*Tree, error)

Make a tree from a string

func SimuTree

func SimuTree(size int) *Tree

func SimuTreeRandomTaxon

func SimuTreeRandomTaxon(size, ntaxon int) *Tree

func YuleTree

func YuleTree(size int) *Tree

func (*Tree) AssignLeafName

func (t *Tree) AssignLeafName()

func (*Tree) ContractByLength

func (t *Tree) ContractByLength(length float64)

Contract tree branches whose lengthes are less than the given one.

func (*Tree) ContractSingleChild

func (t *Tree) ContractSingleChild()

Contract tree branches which have only one child.

func (*Tree) IsBinary

func (t *Tree) IsBinary() bool

A tree is binary tree <=> every internal node has two children. Overwrite `node.IsBinary` method.

func (*Tree) LCAer

func (t *Tree) LCAer() func(a, b *Node) *Node

Make a LCAer function for species tree t.

Usage:
    Lca := st.LCAer()
    Lca(a, b)

func (*Tree) PruneFromTaxon

func (t *Tree) PruneFromTaxon(taxon Taxonmap)

Prune tree according to the taxonmap

func (*Tree) PruneFromTree

func (t *Tree) PruneFromTree(gt *Tree)

Prune tree according to another tree

func (*Tree) RandomContract

func (t *Tree) RandomContract(rate float64)

Randomly contract tree branches according to the given rate.

func (*Tree) SpeciesTree

func (t *Tree) SpeciesTree() (*SpeciesTree, error)

func (*Tree) TaxonMap

func (t *Tree) TaxonMap() (taxon Taxonmap, unique bool)

`TaxonMap` return the `Taxonmap` for a tree, and the uniqueness of its taxon.

func (*Tree) Update

func (t *Tree) Update()

Update everything of a tree from `tree.Node`, including `tree.Nodes, size, node.id, level`. Useful after the tree was manually edited

func (*Tree) UpdateInfo

func (t *Tree) UpdateInfo()

Update node.Level and node.Id for tree `t`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL