Package Bio :: Package Phylo :: Module Consensus
[hide private]
[frames] | no frames]

Module Consensus

source code

Classes and methods for finding consensus trees.

This module contains a _BitString class to assist the consensus tree searching and some common consensus algorithms such as strict, majority rule and adam consensus.

Classes [hide private]
  _BitString
Helper class for binary string data (PRIVATE).
Functions [hide private]
 
strict_consensus(trees)
Search strict consensus tree from multiple trees.
source code
 
majority_consensus(trees, cutoff=0)
Search majority rule consensus tree from multiple trees.
source code
 
adam_consensus(trees)
Search Adam Consensus tree from multiple trees
source code
 
_part(clades)
recursive function of adam consensus algorithm
source code
 
_sub_clade(clade, term_names)
extract a compatible subclade that only contains the given terminal names
source code
 
_count_clades(trees)
Count distinct clades (different sets of terminal names) in the trees.
source code
 
get_support(target_tree, trees, len_trees=None)
Calculate branch support for a target tree given bootstrap replicate trees.
source code
 
bootstrap(msa, times)
Generate bootstrap replicates from a multiple sequence alignment object
source code
 
bootstrap_trees(msa, times, tree_constructor)
Generate bootstrap replicate trees from a multiple sequence alignment.
source code
 
bootstrap_consensus(msa, times, tree_constructor, consensus)
Consensus tree of a series of bootstrap trees for a multiple sequence alignment
source code
 
_clade_to_bitstr(clade, tree_term_names)
Create a BitString representing a clade, given ordered tree taxon names.
source code
 
_tree_to_bitstrs(tree)
Create a dict of a tree's clades to corresponding BitStrings.
source code
 
_bitstring_topology(tree)
Generates a branch length dict for a tree, keyed by BitStrings.
source code
 
_equal_topology(tree1, tree2)
Are two trees are equal in terms of topology and branch lengths.
source code
Variables [hide private]
  __package__ = 'Bio.Phylo'
Function Details [hide private]

strict_consensus(trees)

source code 
Search strict consensus tree from multiple trees.
Parameters:
  • trees (iterable) - iterable of trees to produce consensus tree.

majority_consensus(trees, cutoff=0)

source code 

Search majority rule consensus tree from multiple trees.

This is a extend majority rule method, which means the you can set any cutoff between 0 ~ 1 instead of 0.5. The default value of cutoff is 0 to create a relaxed binary consensus tree in any condition (as long as one of the provided trees is a binary tree). The branch length of each consensus clade in the result consensus tree is the average length of all counts for that clade.

Parameters:
  • trees (iterable) - iterable of trees to produce consensus tree.

adam_consensus(trees)

source code 
Search Adam Consensus tree from multiple trees
Parameters:
  • trees (list) - list of trees to produce consensus tree.

_count_clades(trees)

source code 

Count distinct clades (different sets of terminal names) in the trees.

Return a tuple first a dict of bitstring (representing clade) and a tuple of its count of occurrences and sum of branch length for that clade, second the number of trees processed.

Parameters:
  • trees (iterable) - An iterable that returns the trees to count

get_support(target_tree, trees, len_trees=None)

source code 
Calculate branch support for a target tree given bootstrap replicate trees.
Parameters:
  • target_tree (Tree) - tree to calculate branch support for.
  • trees (iterable) - iterable of trees used to calculate branch support.
  • len_trees (int) - optional count of replicates in trees. len_trees must be provided when len(trees) is not a valid operation.

bootstrap(msa, times)

source code 
Generate bootstrap replicates from a multiple sequence alignment object
Parameters:
  • msa (MultipleSeqAlignment) - multiple sequence alignment to generate replicates.
  • times (int) - number of bootstrap times.

bootstrap_trees(msa, times, tree_constructor)

source code 
Generate bootstrap replicate trees from a multiple sequence alignment.
Parameters:
  • msa (MultipleSeqAlignment) - multiple sequence alignment to generate replicates.
  • times (int) - number of bootstrap times.
  • tree_constructor (TreeConstructor) - tree constructor to be used to build trees.

bootstrap_consensus(msa, times, tree_constructor, consensus)

source code 
Consensus tree of a series of bootstrap trees for a multiple sequence alignment
Parameters:
  • msa (MultipleSeqAlignment) - Multiple sequence alignment to generate replicates.
  • times (int) - Number of bootstrap times.
  • tree_constructor (TreeConstructor) - Tree constructor to be used to build trees.
  • consensus (function) - Consensus method in this module: strict_consensus, majority_consensus, adam_consensus.

_bitstring_topology(tree)

source code 

Generates a branch length dict for a tree, keyed by BitStrings.

Create a dict of all clades' BitStrings to the corresponding branch lengths (rounded to 5 decimal places).

_equal_topology(tree1, tree2)

source code 

Are two trees are equal in terms of topology and branch lengths.

(Branch lengths checked to 5 decimal places.)