partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
prof2seq
Convert profile to sequence and normalize profile across sites. Parameters ---------- profile : numpy 2D array Profile. Shape of the profile should be (L x a), where L - sequence length, a - alphabet size. gtr : gtr.GTR Instance of the GTR class to supply the sequence alphab...
treetime/seq_utils.py
def prof2seq(profile, gtr, sample_from_prof=False, normalize=True): """ Convert profile to sequence and normalize profile across sites. Parameters ---------- profile : numpy 2D array Profile. Shape of the profile should be (L x a), where L - sequence length, a - alphabet size. ...
def prof2seq(profile, gtr, sample_from_prof=False, normalize=True): """ Convert profile to sequence and normalize profile across sites. Parameters ---------- profile : numpy 2D array Profile. Shape of the profile should be (L x a), where L - sequence length, a - alphabet size. ...
[ "Convert", "profile", "to", "sequence", "and", "normalize", "profile", "across", "sites", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/seq_utils.py#L177-L224
[ "def", "prof2seq", "(", "profile", ",", "gtr", ",", "sample_from_prof", "=", "False", ",", "normalize", "=", "True", ")", ":", "# normalize profile such that probabilities at each site sum to one", "if", "normalize", ":", "tmp_profile", ",", "pre", "=", "normalize_pro...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
normalize_profile
return a normalized version of a profile matrix Parameters ---------- in_profile : np.array shape Lxq, will be normalized to one across each row log : bool, optional treat the input as log probabilities return_offset : bool, optional return the log of the scale factor for ea...
treetime/seq_utils.py
def normalize_profile(in_profile, log=False, return_offset = True): """return a normalized version of a profile matrix Parameters ---------- in_profile : np.array shape Lxq, will be normalized to one across each row log : bool, optional treat the input as log probabilities retur...
def normalize_profile(in_profile, log=False, return_offset = True): """return a normalized version of a profile matrix Parameters ---------- in_profile : np.array shape Lxq, will be normalized to one across each row log : bool, optional treat the input as log probabilities retur...
[ "return", "a", "normalized", "version", "of", "a", "profile", "matrix" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/seq_utils.py#L227-L253
[ "def", "normalize_profile", "(", "in_profile", ",", "log", "=", "False", ",", "return_offset", "=", "True", ")", ":", "if", "log", ":", "tmp_prefactor", "=", "in_profile", ".", "max", "(", "axis", "=", "1", ")", "tmp_prof", "=", "np", ".", "exp", "(", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.logger
Print log message *msg* to stdout. Parameters ----------- msg : str String to print on the screen level : int Log-level. Only the messages with a level higher than the current verbose level will be shown. warn : bool Warning ...
treetime/treeanc.py
def logger(self, msg, level, warn=False): """ Print log message *msg* to stdout. Parameters ----------- msg : str String to print on the screen level : int Log-level. Only the messages with a level higher than the current verbose l...
def logger(self, msg, level, warn=False): """ Print log message *msg* to stdout. Parameters ----------- msg : str String to print on the screen level : int Log-level. Only the messages with a level higher than the current verbose l...
[ "Print", "log", "message", "*", "msg", "*", "to", "stdout", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L130-L155
[ "def", "logger", "(", "self", ",", "msg", ",", "level", ",", "warn", "=", "False", ")", ":", "if", "level", "<", "self", ".", "verbose", "or", "(", "warn", "and", "level", "<=", "self", ".", "verbose", ")", ":", "dt", "=", "time", ".", "time", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.gtr
Set a new GTR object Parameters ----------- value : GTR the new GTR object
treetime/treeanc.py
def gtr(self, value): """ Set a new GTR object Parameters ----------- value : GTR the new GTR object """ if not (isinstance(value, GTR) or isinstance(value, GTR_site_specific)): raise TypeError(" GTR instance expected") self._gtr...
def gtr(self, value): """ Set a new GTR object Parameters ----------- value : GTR the new GTR object """ if not (isinstance(value, GTR) or isinstance(value, GTR_site_specific)): raise TypeError(" GTR instance expected") self._gtr...
[ "Set", "a", "new", "GTR", "object" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L181-L193
[ "def", "gtr", "(", "self", ",", "value", ")", ":", "if", "not", "(", "isinstance", "(", "value", ",", "GTR", ")", "or", "isinstance", "(", "value", ",", "GTR_site_specific", ")", ")", ":", "raise", "TypeError", "(", "\" GTR instance expected\"", ")", "se...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.set_gtr
Create new GTR model if needed, and set the model as an attribute of the TreeAnc class Parameters ----------- in_gtr : str, GTR The gtr model to be assigned. If string is passed, it is taken as the name of a standard GTR model, and is attempted to b...
treetime/treeanc.py
def set_gtr(self, in_gtr, **kwargs): """ Create new GTR model if needed, and set the model as an attribute of the TreeAnc class Parameters ----------- in_gtr : str, GTR The gtr model to be assigned. If string is passed, it is taken as the name o...
def set_gtr(self, in_gtr, **kwargs): """ Create new GTR model if needed, and set the model as an attribute of the TreeAnc class Parameters ----------- in_gtr : str, GTR The gtr model to be assigned. If string is passed, it is taken as the name o...
[ "Create", "new", "GTR", "model", "if", "needed", "and", "set", "the", "model", "as", "an", "attribute", "of", "the", "TreeAnc", "class" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L196-L228
[ "def", "set_gtr", "(", "self", ",", "in_gtr", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "in_gtr", ",", "str", ")", ":", "self", ".", "_gtr", "=", "GTR", ".", "standard", "(", "model", "=", "in_gtr", ",", "*", "*", "kwargs", ")",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.tree
assigns a tree to the internal self._tree variable. The tree is either loaded from file (if in_tree is str) or assigned (if in_tree is a Phylo.tree)
treetime/treeanc.py
def tree(self, in_tree): ''' assigns a tree to the internal self._tree variable. The tree is either loaded from file (if in_tree is str) or assigned (if in_tree is a Phylo.tree) ''' from os.path import isfile if isinstance(in_tree, Phylo.BaseTree.Tree): self....
def tree(self, in_tree): ''' assigns a tree to the internal self._tree variable. The tree is either loaded from file (if in_tree is str) or assigned (if in_tree is a Phylo.tree) ''' from os.path import isfile if isinstance(in_tree, Phylo.BaseTree.Tree): self....
[ "assigns", "a", "tree", "to", "the", "internal", "self", ".", "_tree", "variable", ".", "The", "tree", "is", "either", "loaded", "from", "file", "(", "if", "in_tree", "is", "str", ")", "or", "assigned", "(", "if", "in_tree", "is", "a", "Phylo", ".", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L244-L276
[ "def", "tree", "(", "self", ",", "in_tree", ")", ":", "from", "os", ".", "path", "import", "isfile", "if", "isinstance", "(", "in_tree", ",", "Phylo", ".", "BaseTree", ".", "Tree", ")", ":", "self", ".", "_tree", "=", "in_tree", "elif", "type", "(", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.aln
Reads in the alignment (from a dict, MultipleSeqAlignment, or file, as necessary), sets tree-related parameters, and attaches sequences to the tree nodes. Parameters ---------- in_aln : MultipleSeqAlignment, str, dict/defaultdict The alignment to be read in
treetime/treeanc.py
def aln(self,in_aln): """ Reads in the alignment (from a dict, MultipleSeqAlignment, or file, as necessary), sets tree-related parameters, and attaches sequences to the tree nodes. Parameters ---------- in_aln : MultipleSeqAlignment, str, dict/defaultdict ...
def aln(self,in_aln): """ Reads in the alignment (from a dict, MultipleSeqAlignment, or file, as necessary), sets tree-related parameters, and attaches sequences to the tree nodes. Parameters ---------- in_aln : MultipleSeqAlignment, str, dict/defaultdict ...
[ "Reads", "in", "the", "alignment", "(", "from", "a", "dict", "MultipleSeqAlignment", "or", "file", "as", "necessary", ")", "sets", "tree", "-", "related", "parameters", "and", "attaches", "sequences", "to", "the", "tree", "nodes", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L292-L361
[ "def", "aln", "(", "self", ",", "in_aln", ")", ":", "# load alignment from file if necessary", "from", "os", ".", "path", "import", "isfile", "from", "Bio", ".", "Align", "import", "MultipleSeqAlignment", "self", ".", "_aln", "=", "None", "if", "in_aln", "is",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.seq_len
set the length of the uncompressed sequence. its inverse 'one_mutation' is frequently used as a general length scale. This can't be changed once it is set. Parameters ---------- L : int length of the sequence alignment
treetime/treeanc.py
def seq_len(self,L): """set the length of the uncompressed sequence. its inverse 'one_mutation' is frequently used as a general length scale. This can't be changed once it is set. Parameters ---------- L : int length of the sequence alignment """ ...
def seq_len(self,L): """set the length of the uncompressed sequence. its inverse 'one_mutation' is frequently used as a general length scale. This can't be changed once it is set. Parameters ---------- L : int length of the sequence alignment """ ...
[ "set", "the", "length", "of", "the", "uncompressed", "sequence", ".", "its", "inverse", "one_mutation", "is", "frequently", "used", "as", "a", "general", "length", "scale", ".", "This", "can", "t", "be", "changed", "once", "it", "is", "set", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L371-L385
[ "def", "seq_len", "(", "self", ",", "L", ")", ":", "if", "(", "not", "hasattr", "(", "self", ",", "'_seq_len'", ")", ")", "or", "self", ".", "_seq_len", "is", "None", ":", "if", "L", ":", "self", ".", "_seq_len", "=", "int", "(", "L", ")", "els...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._attach_sequences_to_nodes
For each node of the tree, check whether there is a sequence available in the alignment and assign this sequence as a character array
treetime/treeanc.py
def _attach_sequences_to_nodes(self): ''' For each node of the tree, check whether there is a sequence available in the alignment and assign this sequence as a character array ''' failed_leaves= 0 if self.is_vcf: # if alignment is specified as difference from ...
def _attach_sequences_to_nodes(self): ''' For each node of the tree, check whether there is a sequence available in the alignment and assign this sequence as a character array ''' failed_leaves= 0 if self.is_vcf: # if alignment is specified as difference from ...
[ "For", "each", "node", "of", "the", "tree", "check", "whether", "there", "is", "a", "sequence", "available", "in", "the", "alignment", "and", "assign", "this", "sequence", "as", "a", "character", "array" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L463-L508
[ "def", "_attach_sequences_to_nodes", "(", "self", ")", ":", "failed_leaves", "=", "0", "if", "self", ".", "is_vcf", ":", "# if alignment is specified as difference from ref", "dic_aln", "=", "self", ".", "aln", "else", ":", "# if full alignment is specified", "dic_aln",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.make_reduced_alignment
Create the reduced alignment from the full sequences attached to (some) tree nodes. The methods collects all sequences from the tree nodes, creates the alignment, counts the multiplicity for each column of the alignment ('alignment pattern'), and creates the reduced alignment, where only the ...
treetime/treeanc.py
def make_reduced_alignment(self): """ Create the reduced alignment from the full sequences attached to (some) tree nodes. The methods collects all sequences from the tree nodes, creates the alignment, counts the multiplicity for each column of the alignment ('alignment pattern'),...
def make_reduced_alignment(self): """ Create the reduced alignment from the full sequences attached to (some) tree nodes. The methods collects all sequences from the tree nodes, creates the alignment, counts the multiplicity for each column of the alignment ('alignment pattern'),...
[ "Create", "the", "reduced", "alignment", "from", "the", "full", "sequences", "attached", "to", "(", "some", ")", "tree", "nodes", ".", "The", "methods", "collects", "all", "sequences", "from", "the", "tree", "nodes", "creates", "the", "alignment", "counts", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L511-L681
[ "def", "make_reduced_alignment", "(", "self", ")", ":", "self", ".", "logger", "(", "\"TreeAnc: making reduced alignment...\"", ",", "1", ")", "# bind positions in real sequence to that of the reduced (compressed) sequence", "self", ".", "full_to_reduced_sequence_map", "=", "np...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.process_alignment_dict
prepare the dictionary specifying differences from a reference sequence to construct the reduced alignment with variable sites only. NOTE: - sites can be constant but different from the reference - sites can be constant plus a ambiguous sites assigns ------- - se...
treetime/treeanc.py
def process_alignment_dict(self): """ prepare the dictionary specifying differences from a reference sequence to construct the reduced alignment with variable sites only. NOTE: - sites can be constant but different from the reference - sites can be constant plus a ambiguo...
def process_alignment_dict(self): """ prepare the dictionary specifying differences from a reference sequence to construct the reduced alignment with variable sites only. NOTE: - sites can be constant but different from the reference - sites can be constant plus a ambiguo...
[ "prepare", "the", "dictionary", "specifying", "differences", "from", "a", "reference", "sequence", "to", "construct", "the", "reduced", "alignment", "with", "variable", "sites", "only", ".", "NOTE", ":", "-", "sites", "can", "be", "constant", "but", "different",...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L684-L768
[ "def", "process_alignment_dict", "(", "self", ")", ":", "# number of sequences in alignment", "nseq", "=", "len", "(", "self", ".", "aln", ")", "inv_map", "=", "defaultdict", "(", "list", ")", "for", "k", ",", "v", "in", "self", ".", "aln", ".", "items", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.prepare_tree
Set link to parent and calculate distance to root for all tree nodes. Should be run once the tree is read and after every rerooting, topology change or branch length optimizations.
treetime/treeanc.py
def prepare_tree(self): """ Set link to parent and calculate distance to root for all tree nodes. Should be run once the tree is read and after every rerooting, topology change or branch length optimizations. """ self.tree.root.branch_length = 0.001 self.tree.root...
def prepare_tree(self): """ Set link to parent and calculate distance to root for all tree nodes. Should be run once the tree is read and after every rerooting, topology change or branch length optimizations. """ self.tree.root.branch_length = 0.001 self.tree.root...
[ "Set", "link", "to", "parent", "and", "calculate", "distance", "to", "root", "for", "all", "tree", "nodes", ".", "Should", "be", "run", "once", "the", "tree", "is", "read", "and", "after", "every", "rerooting", "topology", "change", "or", "branch", "length...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L771-L782
[ "def", "prepare_tree", "(", "self", ")", ":", "self", ".", "tree", ".", "root", ".", "branch_length", "=", "0.001", "self", ".", "tree", ".", "root", ".", "mutation_length", "=", "self", ".", "tree", ".", "root", ".", "branch_length", "self", ".", "tre...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._prepare_nodes
Set auxilliary parameters to every node of the tree.
treetime/treeanc.py
def _prepare_nodes(self): """ Set auxilliary parameters to every node of the tree. """ self.tree.root.up = None self.tree.root.bad_branch=self.tree.root.bad_branch if hasattr(self.tree.root, 'bad_branch') else False internal_node_count = 0 for clade in self.tree.g...
def _prepare_nodes(self): """ Set auxilliary parameters to every node of the tree. """ self.tree.root.up = None self.tree.root.bad_branch=self.tree.root.bad_branch if hasattr(self.tree.root, 'bad_branch') else False internal_node_count = 0 for clade in self.tree.g...
[ "Set", "auxilliary", "parameters", "to", "every", "node", "of", "the", "tree", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L785-L806
[ "def", "_prepare_nodes", "(", "self", ")", ":", "self", ".", "tree", ".", "root", ".", "up", "=", "None", "self", ".", "tree", ".", "root", ".", "bad_branch", "=", "self", ".", "tree", ".", "root", ".", "bad_branch", "if", "hasattr", "(", "self", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._calc_dist2root
For each node in the tree, set its root-to-node distance as dist2root attribute
treetime/treeanc.py
def _calc_dist2root(self): """ For each node in the tree, set its root-to-node distance as dist2root attribute """ self.tree.root.dist2root = 0.0 for clade in self.tree.get_nonterminals(order='preorder'): # parents first for c in clade.clades: ...
def _calc_dist2root(self): """ For each node in the tree, set its root-to-node distance as dist2root attribute """ self.tree.root.dist2root = 0.0 for clade in self.tree.get_nonterminals(order='preorder'): # parents first for c in clade.clades: ...
[ "For", "each", "node", "in", "the", "tree", "set", "its", "root", "-", "to", "-", "node", "distance", "as", "dist2root", "attribute" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L809-L819
[ "def", "_calc_dist2root", "(", "self", ")", ":", "self", ".", "tree", ".", "root", ".", "dist2root", "=", "0.0", "for", "clade", "in", "self", ".", "tree", ".", "get_nonterminals", "(", "order", "=", "'preorder'", ")", ":", "# parents first", "for", "c",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.infer_gtr
Calculates a GTR model given the multiple sequence alignment and the tree. It performs ancestral sequence inferrence (joint or marginal), followed by the branch lengths optimization. Then, the numbers of mutations are counted in the optimal tree and related to the time within the mutation happen...
treetime/treeanc.py
def infer_gtr(self, print_raw=False, marginal=False, normalized_rate=True, fixed_pi=None, pc=5.0, **kwargs): """ Calculates a GTR model given the multiple sequence alignment and the tree. It performs ancestral sequence inferrence (joint or marginal), followed by the bra...
def infer_gtr(self, print_raw=False, marginal=False, normalized_rate=True, fixed_pi=None, pc=5.0, **kwargs): """ Calculates a GTR model given the multiple sequence alignment and the tree. It performs ancestral sequence inferrence (joint or marginal), followed by the bra...
[ "Calculates", "a", "GTR", "model", "given", "the", "multiple", "sequence", "alignment", "and", "the", "tree", ".", "It", "performs", "ancestral", "sequence", "inferrence", "(", "joint", "or", "marginal", ")", "followed", "by", "the", "branch", "lengths", "opti...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L827-L910
[ "def", "infer_gtr", "(", "self", ",", "print_raw", "=", "False", ",", "marginal", "=", "False", ",", "normalized_rate", "=", "True", ",", "fixed_pi", "=", "None", ",", "pc", "=", "5.0", ",", "*", "*", "kwargs", ")", ":", "# decide which type of the Maximum...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.reconstruct_anc
Reconstruct ancestral sequences Parameters ---------- method : str Method to use. Supported values are "fitch" and "ml" infer_gtr : bool Infer a GTR model before reconstructing the sequences marginal : bool Assign sequences that are most likely...
treetime/treeanc.py
def reconstruct_anc(self, method='probabilistic', infer_gtr=False, marginal=False, **kwargs): """Reconstruct ancestral sequences Parameters ---------- method : str Method to use. Supported values are "fitch" and "ml" infer_gtr : bool ...
def reconstruct_anc(self, method='probabilistic', infer_gtr=False, marginal=False, **kwargs): """Reconstruct ancestral sequences Parameters ---------- method : str Method to use. Supported values are "fitch" and "ml" infer_gtr : bool ...
[ "Reconstruct", "ancestral", "sequences" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L922-L968
[ "def", "reconstruct_anc", "(", "self", ",", "method", "=", "'probabilistic'", ",", "infer_gtr", "=", "False", ",", "marginal", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", "(", "\"TreeAnc.infer_ancestral_sequences with method: %s, %s\"",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.recover_var_ambigs
Recalculates mutations using the original compressed sequence for terminal nodes which will recover ambiguous bases at variable sites. (See 'get_mutations') Once this has been run, infer_gtr and other functions which depend on self.gtr.alphabet will not work, as ambiguous bases are not part of ...
treetime/treeanc.py
def recover_var_ambigs(self): """ Recalculates mutations using the original compressed sequence for terminal nodes which will recover ambiguous bases at variable sites. (See 'get_mutations') Once this has been run, infer_gtr and other functions which depend on self.gtr.alphabet ...
def recover_var_ambigs(self): """ Recalculates mutations using the original compressed sequence for terminal nodes which will recover ambiguous bases at variable sites. (See 'get_mutations') Once this has been run, infer_gtr and other functions which depend on self.gtr.alphabet ...
[ "Recalculates", "mutations", "using", "the", "original", "compressed", "sequence", "for", "terminal", "nodes", "which", "will", "recover", "ambiguous", "bases", "at", "variable", "sites", ".", "(", "See", "get_mutations", ")" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L971-L981
[ "def", "recover_var_ambigs", "(", "self", ")", ":", "for", "node", "in", "self", ".", "tree", ".", "get_terminals", "(", ")", ":", "node", ".", "mutations", "=", "self", ".", "get_mutations", "(", "node", ",", "keep_var_ambigs", "=", "True", ")" ]
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.get_mutations
Get the mutations on a tree branch. Take compressed sequences from both sides of the branch (attached to the node), compute mutations between them, and expand these mutations to the positions in the real sequences. Parameters ---------- node : PhyloTree.Clade Tree nod...
treetime/treeanc.py
def get_mutations(self, node, keep_var_ambigs=False): """ Get the mutations on a tree branch. Take compressed sequences from both sides of the branch (attached to the node), compute mutations between them, and expand these mutations to the positions in the real sequences. Parame...
def get_mutations(self, node, keep_var_ambigs=False): """ Get the mutations on a tree branch. Take compressed sequences from both sides of the branch (attached to the node), compute mutations between them, and expand these mutations to the positions in the real sequences. Parame...
[ "Get", "the", "mutations", "on", "a", "tree", "branch", ".", "Take", "compressed", "sequences", "from", "both", "sides", "of", "the", "branch", "(", "attached", "to", "the", "node", ")", "compute", "mutations", "between", "them", "and", "expand", "these", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L984-L1023
[ "def", "get_mutations", "(", "self", ",", "node", ",", "keep_var_ambigs", "=", "False", ")", ":", "# if ambiguous site are to be restored and node is terminal,", "# assign original sequence, else reconstructed cseq", "node_seq", "=", "node", ".", "cseq", "if", "keep_var_ambig...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.get_branch_mutation_matrix
uses results from marginal ancestral inference to return a joint distribution of the sequence states at both ends of the branch. Parameters ---------- node : Phylo.clade node of the tree full_sequence : bool, optional expand the sequence to the full seque...
treetime/treeanc.py
def get_branch_mutation_matrix(self, node, full_sequence=False): """uses results from marginal ancestral inference to return a joint distribution of the sequence states at both ends of the branch. Parameters ---------- node : Phylo.clade node of the tree full...
def get_branch_mutation_matrix(self, node, full_sequence=False): """uses results from marginal ancestral inference to return a joint distribution of the sequence states at both ends of the branch. Parameters ---------- node : Phylo.clade node of the tree full...
[ "uses", "results", "from", "marginal", "ancestral", "inference", "to", "return", "a", "joint", "distribution", "of", "the", "sequence", "states", "at", "both", "ends", "of", "the", "branch", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1026-L1061
[ "def", "get_branch_mutation_matrix", "(", "self", ",", "node", ",", "full_sequence", "=", "False", ")", ":", "pp", ",", "pc", "=", "self", ".", "marginal_branch_profile", "(", "node", ")", "# calculate pc_i [e^Qt]_ij pp_j for each site", "expQt", "=", "self", ".",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.expanded_sequence
Expand a nodes compressed sequence into the real sequence Parameters ---------- node : PhyloTree.Clade Tree node Returns ------- seq : np.array Sequence as np.array of chars
treetime/treeanc.py
def expanded_sequence(self, node, include_additional_constant_sites=False): """ Expand a nodes compressed sequence into the real sequence Parameters ---------- node : PhyloTree.Clade Tree node Returns ------- seq : np.array Sequence...
def expanded_sequence(self, node, include_additional_constant_sites=False): """ Expand a nodes compressed sequence into the real sequence Parameters ---------- node : PhyloTree.Clade Tree node Returns ------- seq : np.array Sequence...
[ "Expand", "a", "nodes", "compressed", "sequence", "into", "the", "real", "sequence" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1064-L1083
[ "def", "expanded_sequence", "(", "self", ",", "node", ",", "include_additional_constant_sites", "=", "False", ")", ":", "if", "include_additional_constant_sites", ":", "L", "=", "self", ".", "seq_len", "else", ":", "L", "=", "self", ".", "seq_len", "-", "self"...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.dict_sequence
For VCF-based TreeAnc objects, we do not want to store the entire sequence on every node, as they could be large. Instead, this returns the dict of variants & their positions for this sequence. This is used in place of :py:meth:`treetime.TreeAnc.expanded_sequence` for VCF-based objects throughou...
treetime/treeanc.py
def dict_sequence(self, node, keep_var_ambigs=False): """ For VCF-based TreeAnc objects, we do not want to store the entire sequence on every node, as they could be large. Instead, this returns the dict of variants & their positions for this sequence. This is used in place of :py...
def dict_sequence(self, node, keep_var_ambigs=False): """ For VCF-based TreeAnc objects, we do not want to store the entire sequence on every node, as they could be large. Instead, this returns the dict of variants & their positions for this sequence. This is used in place of :py...
[ "For", "VCF", "-", "based", "TreeAnc", "objects", "we", "do", "not", "want", "to", "store", "the", "entire", "sequence", "on", "every", "node", "as", "they", "could", "be", "large", ".", "Instead", "this", "returns", "the", "dict", "of", "variants", "&",...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1086-L1117
[ "def", "dict_sequence", "(", "self", ",", "node", ",", "keep_var_ambigs", "=", "False", ")", ":", "seq", "=", "{", "}", "node_seq", "=", "node", ".", "cseq", "if", "keep_var_ambigs", "and", "hasattr", "(", "node", ",", "\"original_cseq\"", ")", "and", "n...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._fitch_anc
Reconstruct ancestral states using Fitch's algorithm. The method requires sequences to be assigned to leaves. It implements the iteration from leaves to the root constructing the Fitch profiles for each character of the sequence, and then by propagating from the root to the leaves, recon...
treetime/treeanc.py
def _fitch_anc(self, **kwargs): """ Reconstruct ancestral states using Fitch's algorithm. The method requires sequences to be assigned to leaves. It implements the iteration from leaves to the root constructing the Fitch profiles for each character of the sequence, and then by pr...
def _fitch_anc(self, **kwargs): """ Reconstruct ancestral states using Fitch's algorithm. The method requires sequences to be assigned to leaves. It implements the iteration from leaves to the root constructing the Fitch profiles for each character of the sequence, and then by pr...
[ "Reconstruct", "ancestral", "states", "using", "Fitch", "s", "algorithm", ".", "The", "method", "requires", "sequences", "to", "be", "assigned", "to", "leaves", ".", "It", "implements", "the", "iteration", "from", "leaves", "to", "the", "root", "constructing", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1122-L1194
[ "def", "_fitch_anc", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# set fitch profiiles to each terminal node", "for", "l", "in", "self", ".", "tree", ".", "get_terminals", "(", ")", ":", "l", ".", "state", "=", "[", "[", "k", "]", "for", "k", "in"...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._fitch_state
Determine the Fitch profile for a single character of the node's sequence. The profile is essentially the intersection between the children's profiles or, if the former is empty, the union of the profiles. Parameters ---------- node : PhyloTree.Clade: Internal node...
treetime/treeanc.py
def _fitch_state(self, node, pos): """ Determine the Fitch profile for a single character of the node's sequence. The profile is essentially the intersection between the children's profiles or, if the former is empty, the union of the profiles. Parameters ---------- ...
def _fitch_state(self, node, pos): """ Determine the Fitch profile for a single character of the node's sequence. The profile is essentially the intersection between the children's profiles or, if the former is empty, the union of the profiles. Parameters ---------- ...
[ "Determine", "the", "Fitch", "profile", "for", "a", "single", "character", "of", "the", "node", "s", "sequence", ".", "The", "profile", "is", "essentially", "the", "intersection", "between", "the", "children", "s", "profiles", "or", "if", "the", "former", "i...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1197-L1221
[ "def", "_fitch_state", "(", "self", ",", "node", ",", "pos", ")", ":", "state", "=", "self", ".", "_fitch_intersect", "(", "[", "k", ".", "state", "[", "pos", "]", "for", "k", "in", "node", ".", "clades", "]", ")", "if", "len", "(", "state", ")",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._fitch_intersect
Find the intersection of any number of 1D arrays. Return the sorted, unique values that are in all of the input arrays. Adapted from numpy.lib.arraysetops.intersect1d
treetime/treeanc.py
def _fitch_intersect(self, arrays): """ Find the intersection of any number of 1D arrays. Return the sorted, unique values that are in all of the input arrays. Adapted from numpy.lib.arraysetops.intersect1d """ def pairwise_intersect(arr1, arr2): s2 = set(arr2...
def _fitch_intersect(self, arrays): """ Find the intersection of any number of 1D arrays. Return the sorted, unique values that are in all of the input arrays. Adapted from numpy.lib.arraysetops.intersect1d """ def pairwise_intersect(arr1, arr2): s2 = set(arr2...
[ "Find", "the", "intersection", "of", "any", "number", "of", "1D", "arrays", ".", "Return", "the", "sorted", "unique", "values", "that", "are", "in", "all", "of", "the", "input", "arrays", ".", "Adapted", "from", "numpy", ".", "lib", ".", "arraysetops", "...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1224-L1244
[ "def", "_fitch_intersect", "(", "self", ",", "arrays", ")", ":", "def", "pairwise_intersect", "(", "arr1", ",", "arr2", ")", ":", "s2", "=", "set", "(", "arr2", ")", "b3", "=", "[", "val", "for", "val", "in", "arr1", "if", "val", "in", "s2", "]", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.sequence_LH
return the likelihood of the observed sequences given the tree Parameters ---------- pos : int, optional position in the sequence, if none, the sum over all positions will be returned full_sequence : bool, optional does the position refer to the full or compresse...
treetime/treeanc.py
def sequence_LH(self, pos=None, full_sequence=False): """return the likelihood of the observed sequences given the tree Parameters ---------- pos : int, optional position in the sequence, if none, the sum over all positions will be returned full_sequence : bool, opti...
def sequence_LH(self, pos=None, full_sequence=False): """return the likelihood of the observed sequences given the tree Parameters ---------- pos : int, optional position in the sequence, if none, the sum over all positions will be returned full_sequence : bool, opti...
[ "return", "the", "likelihood", "of", "the", "observed", "sequences", "given", "the", "tree" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1251-L1276
[ "def", "sequence_LH", "(", "self", ",", "pos", "=", "None", ",", "full_sequence", "=", "False", ")", ":", "if", "not", "hasattr", "(", "self", ".", "tree", ",", "\"total_sequence_LH\"", ")", ":", "self", ".", "logger", "(", "\"TreeAnc.sequence_LH: you need t...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.ancestral_likelihood
Calculate the likelihood of the given realization of the sequences in the tree Returns ------- log_lh : float The tree likelihood given the sequences
treetime/treeanc.py
def ancestral_likelihood(self): """ Calculate the likelihood of the given realization of the sequences in the tree Returns ------- log_lh : float The tree likelihood given the sequences """ log_lh = np.zeros(self.multiplicity.shape[0]) ...
def ancestral_likelihood(self): """ Calculate the likelihood of the given realization of the sequences in the tree Returns ------- log_lh : float The tree likelihood given the sequences """ log_lh = np.zeros(self.multiplicity.shape[0]) ...
[ "Calculate", "the", "likelihood", "of", "the", "given", "realization", "of", "the", "sequences", "in", "the", "tree" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1279-L1311
[ "def", "ancestral_likelihood", "(", "self", ")", ":", "log_lh", "=", "np", ".", "zeros", "(", "self", ".", "multiplicity", ".", "shape", "[", "0", "]", ")", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", "order", "=", "'postorder'",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._branch_length_to_gtr
Set branch lengths to either mutation lengths of given branch lengths. The assigend values are to be used in the following ML analysis.
treetime/treeanc.py
def _branch_length_to_gtr(self, node): """ Set branch lengths to either mutation lengths of given branch lengths. The assigend values are to be used in the following ML analysis. """ if self.use_mutation_length: return max(ttconf.MIN_BRANCH_LENGTH*self.one_mutation, n...
def _branch_length_to_gtr(self, node): """ Set branch lengths to either mutation lengths of given branch lengths. The assigend values are to be used in the following ML analysis. """ if self.use_mutation_length: return max(ttconf.MIN_BRANCH_LENGTH*self.one_mutation, n...
[ "Set", "branch", "lengths", "to", "either", "mutation", "lengths", "of", "given", "branch", "lengths", ".", "The", "assigend", "values", "are", "to", "be", "used", "in", "the", "following", "ML", "analysis", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1313-L1321
[ "def", "_branch_length_to_gtr", "(", "self", ",", "node", ")", ":", "if", "self", ".", "use_mutation_length", ":", "return", "max", "(", "ttconf", ".", "MIN_BRANCH_LENGTH", "*", "self", ".", "one_mutation", ",", "node", ".", "mutation_length", ")", "else", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._ml_anc_marginal
Perform marginal ML reconstruction of the ancestral states. In contrast to joint reconstructions, this needs to access the probabilities rather than only log probabilities and is hence handled by a separate function. Parameters ---------- store_compressed : bool, default True ...
treetime/treeanc.py
def _ml_anc_marginal(self, store_compressed=False, final=True, sample_from_profile=False, debug=False, **kwargs): """ Perform marginal ML reconstruction of the ancestral states. In contrast to joint reconstructions, this needs to access the probabilities rather than only...
def _ml_anc_marginal(self, store_compressed=False, final=True, sample_from_profile=False, debug=False, **kwargs): """ Perform marginal ML reconstruction of the ancestral states. In contrast to joint reconstructions, this needs to access the probabilities rather than only...
[ "Perform", "marginal", "ML", "reconstruction", "of", "the", "ancestral", "states", ".", "In", "contrast", "to", "joint", "reconstructions", "this", "needs", "to", "access", "the", "probabilities", "rather", "than", "only", "log", "probabilities", "and", "is", "h...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1324-L1461
[ "def", "_ml_anc_marginal", "(", "self", ",", "store_compressed", "=", "False", ",", "final", "=", "True", ",", "sample_from_profile", "=", "False", ",", "debug", "=", "False", ",", "*", "*", "kwargs", ")", ":", "tree", "=", "self", ".", "tree", "# number...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._ml_anc_joint
Perform joint ML reconstruction of the ancestral states. In contrast to marginal reconstructions, this only needs to compare and multiply LH and can hence operate in log space. Parameters ---------- store_compressed : bool, default True attach a reduced representat...
treetime/treeanc.py
def _ml_anc_joint(self, store_compressed=True, final=True, sample_from_profile=False, debug=False, **kwargs): """ Perform joint ML reconstruction of the ancestral states. In contrast to marginal reconstructions, this only needs to compare and multiply LH and ...
def _ml_anc_joint(self, store_compressed=True, final=True, sample_from_profile=False, debug=False, **kwargs): """ Perform joint ML reconstruction of the ancestral states. In contrast to marginal reconstructions, this only needs to compare and multiply LH and ...
[ "Perform", "joint", "ML", "reconstruction", "of", "the", "ancestral", "states", ".", "In", "contrast", "to", "marginal", "reconstructions", "this", "only", "needs", "to", "compare", "and", "multiply", "LH", "and", "can", "hence", "operate", "in", "log", "space...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1464-L1596
[ "def", "_ml_anc_joint", "(", "self", ",", "store_compressed", "=", "True", ",", "final", "=", "True", ",", "sample_from_profile", "=", "False", ",", "debug", "=", "False", ",", "*", "*", "kwargs", ")", ":", "N_diff", "=", "0", "# number of sites differ from ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._store_compressed_sequence_to_node
make a compressed representation of a pair of sequences only counting the number of times a particular pair of states (e.g. (A,T)) is observed the the aligned sequences of parent and child. Parameters ----------- node : PhyloTree.Clade Tree node. **Note** because t...
treetime/treeanc.py
def _store_compressed_sequence_to_node(self, node): """ make a compressed representation of a pair of sequences only counting the number of times a particular pair of states (e.g. (A,T)) is observed the the aligned sequences of parent and child. Parameters ----------- ...
def _store_compressed_sequence_to_node(self, node): """ make a compressed representation of a pair of sequences only counting the number of times a particular pair of states (e.g. (A,T)) is observed the the aligned sequences of parent and child. Parameters ----------- ...
[ "make", "a", "compressed", "representation", "of", "a", "pair", "of", "sequences", "only", "counting", "the", "number", "of", "times", "a", "particular", "pair", "of", "states", "(", "e", ".", "g", ".", "(", "A", "T", "))", "is", "observed", "the", "th...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1599-L1618
[ "def", "_store_compressed_sequence_to_node", "(", "self", ",", "node", ")", ":", "seq_pairs", ",", "multiplicity", "=", "self", ".", "gtr", ".", "compress_sequence_pair", "(", "node", ".", "up", ".", "cseq", ",", "node", ".", "cseq", ",", "pattern_multiplicity...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc._store_compressed_sequence_pairs
Traverse the tree, and for each node store the compressed sequence pair. **Note** sequence reconstruction should be performed prior to calling this method.
treetime/treeanc.py
def _store_compressed_sequence_pairs(self): """ Traverse the tree, and for each node store the compressed sequence pair. **Note** sequence reconstruction should be performed prior to calling this method. """ self.logger("TreeAnc._store_compressed_sequence_pairs...",2) ...
def _store_compressed_sequence_pairs(self): """ Traverse the tree, and for each node store the compressed sequence pair. **Note** sequence reconstruction should be performed prior to calling this method. """ self.logger("TreeAnc._store_compressed_sequence_pairs...",2) ...
[ "Traverse", "the", "tree", "and", "for", "each", "node", "store", "the", "compressed", "sequence", "pair", ".", "**", "Note", "**", "sequence", "reconstruction", "should", "be", "performed", "prior", "to", "calling", "this", "method", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1621-L1632
[ "def", "_store_compressed_sequence_pairs", "(", "self", ")", ":", "self", ".", "logger", "(", "\"TreeAnc._store_compressed_sequence_pairs...\"", ",", "2", ")", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", ")", ":", "if", "node", ".", "up"...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.optimize_branch_length
Perform optimization for the branch lengths of the entire tree. This method only does a single path and needs to be iterated. **Note** this method assumes that each node stores information about its sequence as numpy.array object (node.sequence attribute). Therefore, before calling this...
treetime/treeanc.py
def optimize_branch_length(self, mode='joint', **kwargs): """ Perform optimization for the branch lengths of the entire tree. This method only does a single path and needs to be iterated. **Note** this method assumes that each node stores information about its sequence as numpy....
def optimize_branch_length(self, mode='joint', **kwargs): """ Perform optimization for the branch lengths of the entire tree. This method only does a single path and needs to be iterated. **Note** this method assumes that each node stores information about its sequence as numpy....
[ "Perform", "optimization", "for", "the", "branch", "lengths", "of", "the", "entire", "tree", ".", "This", "method", "only", "does", "a", "single", "path", "and", "needs", "to", "be", "iterated", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1641-L1724
[ "def", "optimize_branch_length", "(", "self", ",", "mode", "=", "'joint'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", "(", "\"TreeAnc.optimize_branch_length: running branch length optimization in mode %s...\"", "%", "mode", ",", "1", ")", "if", "(", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.optimize_branch_length_global
EXPERIMENTAL GLOBAL OPTIMIZATION
treetime/treeanc.py
def optimize_branch_length_global(self, **kwargs): """ EXPERIMENTAL GLOBAL OPTIMIZATION """ self.logger("TreeAnc.optimize_branch_length_global: running branch length optimization...",1) def neg_log(s): for si, n in zip(s, self.tree.find_clades(order='preorder')): ...
def optimize_branch_length_global(self, **kwargs): """ EXPERIMENTAL GLOBAL OPTIMIZATION """ self.logger("TreeAnc.optimize_branch_length_global: running branch length optimization...",1) def neg_log(s): for si, n in zip(s, self.tree.find_clades(order='preorder')): ...
[ "EXPERIMENTAL", "GLOBAL", "OPTIMIZATION" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1727-L1775
[ "def", "optimize_branch_length_global", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", "(", "\"TreeAnc.optimize_branch_length_global: running branch length optimization...\"", ",", "1", ")", "def", "neg_log", "(", "s", ")", ":", "for", "si", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.optimal_branch_length
Calculate optimal branch length given the sequences of node and parent Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- new_len : float Optimal length of the given branch
treetime/treeanc.py
def optimal_branch_length(self, node): ''' Calculate optimal branch length given the sequences of node and parent Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- new_len : float Optimal...
def optimal_branch_length(self, node): ''' Calculate optimal branch length given the sequences of node and parent Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- new_len : float Optimal...
[ "Calculate", "optimal", "branch", "length", "given", "the", "sequences", "of", "node", "and", "parent" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1778-L1804
[ "def", "optimal_branch_length", "(", "self", ",", "node", ")", ":", "if", "node", ".", "up", "is", "None", ":", "return", "self", ".", "one_mutation", "parent", "=", "node", ".", "up", "if", "hasattr", "(", "node", ",", "'compressed_sequence'", ")", ":",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.marginal_branch_profile
calculate the marginal distribution of sequence states on both ends of the branch leading to node, Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- pp, pc : Pair of vectors (profile parent, pp) and (profi...
treetime/treeanc.py
def marginal_branch_profile(self, node): ''' calculate the marginal distribution of sequence states on both ends of the branch leading to node, Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- ...
def marginal_branch_profile(self, node): ''' calculate the marginal distribution of sequence states on both ends of the branch leading to node, Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- ...
[ "calculate", "the", "marginal", "distribution", "of", "sequence", "states", "on", "both", "ends", "of", "the", "branch", "leading", "to", "node" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1807-L1832
[ "def", "marginal_branch_profile", "(", "self", ",", "node", ")", ":", "parent", "=", "node", ".", "up", "if", "parent", "is", "None", ":", "raise", "Exception", "(", "\"Branch profiles can't be calculated for the root!\"", ")", "if", "not", "hasattr", "(", "node...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.optimal_marginal_branch_length
calculate the marginal distribution of sequence states on both ends of the branch leading to node, Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ------- branch_length : float branch length of the bra...
treetime/treeanc.py
def optimal_marginal_branch_length(self, node, tol=1e-10): ''' calculate the marginal distribution of sequence states on both ends of the branch leading to node, Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ...
def optimal_marginal_branch_length(self, node, tol=1e-10): ''' calculate the marginal distribution of sequence states on both ends of the branch leading to node, Parameters ---------- node : PhyloTree.Clade TreeNode, attached to the branch. Returns ...
[ "calculate", "the", "marginal", "distribution", "of", "sequence", "states", "on", "both", "ends", "of", "the", "branch", "leading", "to", "node" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1835-L1855
[ "def", "optimal_marginal_branch_length", "(", "self", ",", "node", ",", "tol", "=", "1e-10", ")", ":", "if", "node", ".", "up", "is", "None", ":", "return", "self", ".", "one_mutation", "pp", ",", "pc", "=", "self", ".", "marginal_branch_profile", "(", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.prune_short_branches
If the branch length is less than the minimal value, remove the branch from the tree. **Requires** ancestral sequence reconstruction
treetime/treeanc.py
def prune_short_branches(self): """ If the branch length is less than the minimal value, remove the branch from the tree. **Requires** ancestral sequence reconstruction """ self.logger("TreeAnc.prune_short_branches: pruning short branches (max prob at zero)...", 1) for no...
def prune_short_branches(self): """ If the branch length is less than the minimal value, remove the branch from the tree. **Requires** ancestral sequence reconstruction """ self.logger("TreeAnc.prune_short_branches: pruning short branches (max prob at zero)...", 1) for no...
[ "If", "the", "branch", "length", "is", "less", "than", "the", "minimal", "value", "remove", "the", "branch", "from", "the", "tree", ".", "**", "Requires", "**", "ancestral", "sequence", "reconstruction" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1858-L1874
[ "def", "prune_short_branches", "(", "self", ")", ":", "self", ".", "logger", "(", "\"TreeAnc.prune_short_branches: pruning short branches (max prob at zero)...\"", ",", "1", ")", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", ")", ":", "if", "n...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.optimize_seq_and_branch_len
Iteratively set branch lengths and reconstruct ancestral sequences until the values of either former or latter do not change. The algorithm assumes knowing only the topology of the tree, and requires that sequences are assigned to all leaves of the tree. The first step is to pre-reconst...
treetime/treeanc.py
def optimize_seq_and_branch_len(self,reuse_branch_len=True, prune_short=True, marginal_sequences=False, branch_length_mode='joint', max_iter=5, infer_gtr=False, **kwargs): """ Iteratively set branch lengths and reconstruct ancestral...
def optimize_seq_and_branch_len(self,reuse_branch_len=True, prune_short=True, marginal_sequences=False, branch_length_mode='joint', max_iter=5, infer_gtr=False, **kwargs): """ Iteratively set branch lengths and reconstruct ancestral...
[ "Iteratively", "set", "branch", "lengths", "and", "reconstruct", "ancestral", "sequences", "until", "the", "values", "of", "either", "former", "or", "latter", "do", "not", "change", ".", "The", "algorithm", "assumes", "knowing", "only", "the", "topology", "of", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1884-L1960
[ "def", "optimize_seq_and_branch_len", "(", "self", ",", "reuse_branch_len", "=", "True", ",", "prune_short", "=", "True", ",", "marginal_sequences", "=", "False", ",", "branch_length_mode", "=", "'joint'", ",", "max_iter", "=", "5", ",", "infer_gtr", "=", "False...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.get_reconstructed_alignment
Get the multiple sequence alignment, including reconstructed sequences for the internal nodes. Returns ------- new_aln : MultipleSeqAlignment Alignment including sequences of all internal nodes
treetime/treeanc.py
def get_reconstructed_alignment(self): """ Get the multiple sequence alignment, including reconstructed sequences for the internal nodes. Returns ------- new_aln : MultipleSeqAlignment Alignment including sequences of all internal nodes """ fr...
def get_reconstructed_alignment(self): """ Get the multiple sequence alignment, including reconstructed sequences for the internal nodes. Returns ------- new_aln : MultipleSeqAlignment Alignment including sequences of all internal nodes """ fr...
[ "Get", "the", "multiple", "sequence", "alignment", "including", "reconstructed", "sequences", "for", "the", "internal", "nodes", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1966-L1988
[ "def", "get_reconstructed_alignment", "(", "self", ")", ":", "from", "Bio", ".", "Align", "import", "MultipleSeqAlignment", "from", "Bio", ".", "Seq", "import", "Seq", "from", "Bio", ".", "SeqRecord", "import", "SeqRecord", "self", ".", "logger", "(", "\"TreeA...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeAnc.get_tree_dict
For VCF-based objects, returns a nested dict with all the information required to reconstruct sequences for all nodes (terminal and internal). Parameters ---------- keep_var_ambigs : boolean If true, generates dict sequences based on the *original* compressed sequences, whic...
treetime/treeanc.py
def get_tree_dict(self, keep_var_ambigs=False): """ For VCF-based objects, returns a nested dict with all the information required to reconstruct sequences for all nodes (terminal and internal). Parameters ---------- keep_var_ambigs : boolean If true, generat...
def get_tree_dict(self, keep_var_ambigs=False): """ For VCF-based objects, returns a nested dict with all the information required to reconstruct sequences for all nodes (terminal and internal). Parameters ---------- keep_var_ambigs : boolean If true, generat...
[ "For", "VCF", "-", "based", "objects", "returns", "a", "nested", "dict", "with", "all", "the", "information", "required", "to", "reconstruct", "sequences", "for", "all", "nodes", "(", "terminal", "and", "internal", ")", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1991-L2053
[ "def", "get_tree_dict", "(", "self", ",", "keep_var_ambigs", "=", "False", ")", ":", "if", "self", ".", "is_vcf", ":", "tree_dict", "=", "{", "}", "tree_dict", "[", "'reference'", "]", "=", "self", ".", "ref", "tree_dict", "[", "'positions'", "]", "=", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR_site_specific.Q
function that return the product of the transition matrix and the equilibrium frequencies to obtain the rate matrix of the GTR model
treetime/gtr_site_specific.py
def Q(self): """function that return the product of the transition matrix and the equilibrium frequencies to obtain the rate matrix of the GTR model """ tmp = np.einsum('ia,ij->ija', self.Pi, self.W) diag_vals = np.sum(tmp, axis=0) for x in range(tmp.shape[-...
def Q(self): """function that return the product of the transition matrix and the equilibrium frequencies to obtain the rate matrix of the GTR model """ tmp = np.einsum('ia,ij->ija', self.Pi, self.W) diag_vals = np.sum(tmp, axis=0) for x in range(tmp.shape[-...
[ "function", "that", "return", "the", "product", "of", "the", "transition", "matrix", "and", "the", "equilibrium", "frequencies", "to", "obtain", "the", "rate", "matrix", "of", "the", "GTR", "model" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr_site_specific.py#L22-L31
[ "def", "Q", "(", "self", ")", ":", "tmp", "=", "np", ".", "einsum", "(", "'ia,ij->ija'", ",", "self", ".", "Pi", ",", "self", ".", "W", ")", "diag_vals", "=", "np", ".", "sum", "(", "tmp", ",", "axis", "=", "0", ")", "for", "x", "in", "range"...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR_site_specific.assign_rates
Overwrite the GTR model given the provided data Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequencies
treetime/gtr_site_specific.py
def assign_rates(self, mu=1.0, pi=None, W=None): """ Overwrite the GTR model given the provided data Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequenc...
def assign_rates(self, mu=1.0, pi=None, W=None): """ Overwrite the GTR model given the provided data Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequenc...
[ "Overwrite", "the", "GTR", "model", "given", "the", "provided", "data" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr_site_specific.py#L33-L79
[ "def", "assign_rates", "(", "self", ",", "mu", "=", "1.0", ",", "pi", "=", "None", ",", "W", "=", "None", ")", ":", "n", "=", "len", "(", "self", ".", "alphabet", ")", "self", ".", "mu", "=", "np", ".", "copy", "(", "mu", ")", "if", "pi", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR_site_specific.random
Creates a random GTR model Parameters ---------- mu : float Substitution rate alphabet : str Alphabet name (should be standard: 'nuc', 'nuc_gap', 'aa', 'aa_gap')
treetime/gtr_site_specific.py
def random(cls, L=1, avg_mu=1.0, alphabet='nuc', pi_dirichlet_alpha=1, W_dirichlet_alpha=3.0, mu_gamma_alpha=3.0): """ Creates a random GTR model Parameters ---------- mu : float Substitution rate alphabet : str Alphabet name (s...
def random(cls, L=1, avg_mu=1.0, alphabet='nuc', pi_dirichlet_alpha=1, W_dirichlet_alpha=3.0, mu_gamma_alpha=3.0): """ Creates a random GTR model Parameters ---------- mu : float Substitution rate alphabet : str Alphabet name (s...
[ "Creates", "a", "random", "GTR", "model" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr_site_specific.py#L83-L125
[ "def", "random", "(", "cls", ",", "L", "=", "1", ",", "avg_mu", "=", "1.0", ",", "alphabet", "=", "'nuc'", ",", "pi_dirichlet_alpha", "=", "1", ",", "W_dirichlet_alpha", "=", "3.0", ",", "mu_gamma_alpha", "=", "3.0", ")", ":", "from", "scipy", ".", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR_site_specific.custom
Create a GTR model by specifying the matrix explicitly Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequencies **kwargs: Key word arguments to be p...
treetime/gtr_site_specific.py
def custom(cls, mu=1.0, pi=None, W=None, **kwargs): """ Create a GTR model by specifying the matrix explicitly Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibriu...
def custom(cls, mu=1.0, pi=None, W=None, **kwargs): """ Create a GTR model by specifying the matrix explicitly Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibriu...
[ "Create", "a", "GTR", "model", "by", "specifying", "the", "matrix", "explicitly" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr_site_specific.py#L128-L158
[ "def", "custom", "(", "cls", ",", "mu", "=", "1.0", ",", "pi", "=", "None", ",", "W", "=", "None", ",", "*", "*", "kwargs", ")", ":", "gtr", "=", "cls", "(", "*", "*", "kwargs", ")", "gtr", ".", "assign_rates", "(", "mu", "=", "mu", ",", "p...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR_site_specific.infer
Infer a GTR model by specifying the number of transitions and time spent in each character. The basic equation that is being solved is :math:`n_{ij} = pi_i W_{ij} T_j` where :math:`n_{ij}` are the transitions, :math:`pi_i` are the equilibrium state frequencies, :math:`W_{ij}` is the "s...
treetime/gtr_site_specific.py
def infer(cls, sub_ija, T_ia, root_state, pc=0.01, gap_limit=0.01, Nit=30, dp=1e-5, **kwargs): """ Infer a GTR model by specifying the number of transitions and time spent in each character. The basic equation that is being solved is :math:`n_{ij} = pi_i W_{ij} T_j` ...
def infer(cls, sub_ija, T_ia, root_state, pc=0.01, gap_limit=0.01, Nit=30, dp=1e-5, **kwargs): """ Infer a GTR model by specifying the number of transitions and time spent in each character. The basic equation that is being solved is :math:`n_{ij} = pi_i W_{ij} T_j` ...
[ "Infer", "a", "GTR", "model", "by", "specifying", "the", "number", "of", "transitions", "and", "time", "spent", "in", "each", "character", ".", "The", "basic", "equation", "that", "is", "being", "solved", "is" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr_site_specific.py#L161-L258
[ "def", "infer", "(", "cls", ",", "sub_ija", ",", "T_ia", ",", "root_state", ",", "pc", "=", "0.01", ",", "gap_limit", "=", "0.01", ",", "Nit", "=", "30", ",", "dp", "=", "1e-5", ",", "*", "*", "kwargs", ")", ":", "from", "scipy", "import", "linal...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR_site_specific.prob_t
Compute the probability to observe seq_ch (child sequence) after time t starting from seq_p (parent sequence). Parameters ---------- seq_p : character array Parent sequence seq_c : character array Child sequence t : double Time (...
treetime/gtr_site_specific.py
def prob_t(self, seq_p, seq_ch, t, pattern_multiplicity = None, return_log=False, ignore_gaps=True): """ Compute the probability to observe seq_ch (child sequence) after time t starting from seq_p (parent sequence). Parameters ---------- seq_p : characte...
def prob_t(self, seq_p, seq_ch, t, pattern_multiplicity = None, return_log=False, ignore_gaps=True): """ Compute the probability to observe seq_ch (child sequence) after time t starting from seq_p (parent sequence). Parameters ---------- seq_p : characte...
[ "Compute", "the", "probability", "to", "observe", "seq_ch", "(", "child", "sequence", ")", "after", "time", "t", "starting", "from", "seq_p", "(", "parent", "sequence", ")", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr_site_specific.py#L366-L417
[ "def", "prob_t", "(", "self", ",", "seq_p", ",", "seq_ch", ",", "t", ",", "pattern_multiplicity", "=", "None", ",", "return_log", "=", "False", ",", "ignore_gaps", "=", "True", ")", ":", "if", "t", "<", "0", ":", "logP", "=", "-", "ttconf", ".", "B...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.assign_rates
Overwrite the GTR model given the provided data Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequencies
treetime/gtr.py
def assign_rates(self, mu=1.0, pi=None, W=None): """ Overwrite the GTR model given the provided data Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequenc...
def assign_rates(self, mu=1.0, pi=None, W=None): """ Overwrite the GTR model given the provided data Parameters ---------- mu : float Substitution rate W : nxn matrix Substitution matrix pi : n vector Equilibrium frequenc...
[ "Overwrite", "the", "GTR", "model", "given", "the", "provided", "data" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L149-L192
[ "def", "assign_rates", "(", "self", ",", "mu", "=", "1.0", ",", "pi", "=", "None", ",", "W", "=", "None", ")", ":", "n", "=", "len", "(", "self", ".", "alphabet", ")", "self", ".", "mu", "=", "mu", "if", "pi", "is", "not", "None", "and", "len...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.standard
Create standard model of molecular evolution. Parameters ---------- model : str Model to create. See list of available models below **kwargs: Key word arguments to be passed to the model **Available models** - JC69: Jukes-Cantor 1...
treetime/gtr.py
def standard(model, **kwargs): """ Create standard model of molecular evolution. Parameters ---------- model : str Model to create. See list of available models below **kwargs: Key word arguments to be passed to the model **Available ...
def standard(model, **kwargs): """ Create standard model of molecular evolution. Parameters ---------- model : str Model to create. See list of available models below **kwargs: Key word arguments to be passed to the model **Available ...
[ "Create", "standard", "model", "of", "molecular", "evolution", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L229-L369
[ "def", "standard", "(", "model", ",", "*", "*", "kwargs", ")", ":", "from", ".", "nuc_models", "import", "JC69", ",", "K80", ",", "F81", ",", "HKY85", ",", "T92", ",", "TN93", "from", ".", "aa_models", "import", "JTT92", "if", "model", ".", "lower", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.random
Creates a random GTR model Parameters ---------- mu : float Substitution rate alphabet : str Alphabet name (should be standard: 'nuc', 'nuc_gap', 'aa', 'aa_gap')
treetime/gtr.py
def random(cls, mu=1.0, alphabet='nuc'): """ Creates a random GTR model Parameters ---------- mu : float Substitution rate alphabet : str Alphabet name (should be standard: 'nuc', 'nuc_gap', 'aa', 'aa_gap') """ alphabet=alph...
def random(cls, mu=1.0, alphabet='nuc'): """ Creates a random GTR model Parameters ---------- mu : float Substitution rate alphabet : str Alphabet name (should be standard: 'nuc', 'nuc_gap', 'aa', 'aa_gap') """ alphabet=alph...
[ "Creates", "a", "random", "GTR", "model" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L372-L395
[ "def", "random", "(", "cls", ",", "mu", "=", "1.0", ",", "alphabet", "=", "'nuc'", ")", ":", "alphabet", "=", "alphabets", "[", "alphabet", "]", "gtr", "=", "cls", "(", "alphabet", ")", "n", "=", "gtr", ".", "alphabet", ".", "shape", "[", "0", "]...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.infer
Infer a GTR model by specifying the number of transitions and time spent in each character. The basic equation that is being solved is :math:`n_{ij} = pi_i W_{ij} T_j` where :math:`n_{ij}` are the transitions, :math:`pi_i` are the equilibrium state frequencies, :math:`W_{ij}` is the "s...
treetime/gtr.py
def infer(cls, nij, Ti, root_state, fixed_pi=None, pc=5.0, gap_limit=0.01, **kwargs): """ Infer a GTR model by specifying the number of transitions and time spent in each character. The basic equation that is being solved is :math:`n_{ij} = pi_i W_{ij} T_j` where :math:`n_{ij}`...
def infer(cls, nij, Ti, root_state, fixed_pi=None, pc=5.0, gap_limit=0.01, **kwargs): """ Infer a GTR model by specifying the number of transitions and time spent in each character. The basic equation that is being solved is :math:`n_{ij} = pi_i W_{ij} T_j` where :math:`n_{ij}`...
[ "Infer", "a", "GTR", "model", "by", "specifying", "the", "number", "of", "transitions", "and", "time", "spent", "in", "each", "character", ".", "The", "basic", "equation", "that", "is", "being", "solved", "is" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L399-L491
[ "def", "infer", "(", "cls", ",", "nij", ",", "Ti", ",", "root_state", ",", "fixed_pi", "=", "None", ",", "pc", "=", "5.0", ",", "gap_limit", "=", "0.01", ",", "*", "*", "kwargs", ")", ":", "from", "scipy", "import", "linalg", "as", "LA", "gtr", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR._check_fix_Q
Check the main diagonal of Q and fix it in case it does not corresond the definition of the rate matrix. Should be run every time when creating custom GTR model.
treetime/gtr.py
def _check_fix_Q(self, fixed_mu=False): """ Check the main diagonal of Q and fix it in case it does not corresond the definition of the rate matrix. Should be run every time when creating custom GTR model. """ # fix Q self.Pi /= self.Pi.sum() # correct the Pi manu...
def _check_fix_Q(self, fixed_mu=False): """ Check the main diagonal of Q and fix it in case it does not corresond the definition of the rate matrix. Should be run every time when creating custom GTR model. """ # fix Q self.Pi /= self.Pi.sum() # correct the Pi manu...
[ "Check", "the", "main", "diagonal", "of", "Q", "and", "fix", "it", "in", "case", "it", "does", "not", "corresond", "the", "definition", "of", "the", "rate", "matrix", ".", "Should", "be", "run", "every", "time", "when", "creating", "custom", "GTR", "mode...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L496-L517
[ "def", "_check_fix_Q", "(", "self", ",", "fixed_mu", "=", "False", ")", ":", "# fix Q", "self", ".", "Pi", "/=", "self", ".", "Pi", ".", "sum", "(", ")", "# correct the Pi manually", "# NEEDED TO BREAK RATE MATRIX DEGENERACY AND FORCE NP TO RETURN REAL ORTHONORMAL EIGEN...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR._eig
Perform eigendecompositon of the rate matrix and stores the left- and right- matrices to convert the sequence profiles to the GTR matrix eigenspace and hence to speed-up the computations.
treetime/gtr.py
def _eig(self): """ Perform eigendecompositon of the rate matrix and stores the left- and right- matrices to convert the sequence profiles to the GTR matrix eigenspace and hence to speed-up the computations. """ # eigendecomposition of the rate matrix eigvals, eig...
def _eig(self): """ Perform eigendecompositon of the rate matrix and stores the left- and right- matrices to convert the sequence profiles to the GTR matrix eigenspace and hence to speed-up the computations. """ # eigendecomposition of the rate matrix eigvals, eig...
[ "Perform", "eigendecompositon", "of", "the", "rate", "matrix", "and", "stores", "the", "left", "-", "and", "right", "-", "matrices", "to", "convert", "the", "sequence", "profiles", "to", "the", "GTR", "matrix", "eigenspace", "and", "hence", "to", "speed", "-...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L520-L530
[ "def", "_eig", "(", "self", ")", ":", "# eigendecomposition of the rate matrix", "eigvals", ",", "eigvecs", "=", "np", ".", "linalg", ".", "eig", "(", "self", ".", "Q", ")", "self", ".", "v", "=", "np", ".", "real", "(", "eigvecs", ")", "self", ".", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR._eig_sym
Perform eigendecompositon of the rate matrix and stores the left- and right- matrices to convert the sequence profiles to the GTR matrix eigenspace and hence to speed-up the computations.
treetime/gtr.py
def _eig_sym(self): """ Perform eigendecompositon of the rate matrix and stores the left- and right- matrices to convert the sequence profiles to the GTR matrix eigenspace and hence to speed-up the computations. """ # eigendecomposition of the rate matrix tmpp = n...
def _eig_sym(self): """ Perform eigendecompositon of the rate matrix and stores the left- and right- matrices to convert the sequence profiles to the GTR matrix eigenspace and hence to speed-up the computations. """ # eigendecomposition of the rate matrix tmpp = n...
[ "Perform", "eigendecompositon", "of", "the", "rate", "matrix", "and", "stores", "the", "left", "-", "and", "right", "-", "matrices", "to", "convert", "the", "sequence", "profiles", "to", "the", "GTR", "matrix", "eigenspace", "and", "hence", "to", "speed", "-...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L533-L547
[ "def", "_eig_sym", "(", "self", ")", ":", "# eigendecomposition of the rate matrix", "tmpp", "=", "np", ".", "sqrt", "(", "self", ".", "Pi", ")", "symQ", "=", "self", ".", "W", "*", "np", ".", "outer", "(", "tmpp", ",", "tmpp", ")", "eigvals", ",", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.compress_sequence_pair
Make a compressed representation of a pair of sequences, only counting the number of times a particular pair of states (e.g. (A,T)) is observed in the aligned sequences of parent and child. Parameters ---------- seq_p: numpy array Parent sequence as numpy array of ...
treetime/gtr.py
def compress_sequence_pair(self, seq_p, seq_ch, pattern_multiplicity=None, ignore_gaps=False): ''' Make a compressed representation of a pair of sequences, only counting the number of times a particular pair of states (e.g. (A,T)) is observed in the aligned...
def compress_sequence_pair(self, seq_p, seq_ch, pattern_multiplicity=None, ignore_gaps=False): ''' Make a compressed representation of a pair of sequences, only counting the number of times a particular pair of states (e.g. (A,T)) is observed in the aligned...
[ "Make", "a", "compressed", "representation", "of", "a", "pair", "of", "sequences", "only", "counting", "the", "number", "of", "times", "a", "particular", "pair", "of", "states", "(", "e", ".", "g", ".", "(", "A", "T", "))", "is", "observed", "in", "the...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L550-L625
[ "def", "compress_sequence_pair", "(", "self", ",", "seq_p", ",", "seq_ch", ",", "pattern_multiplicity", "=", "None", ",", "ignore_gaps", "=", "False", ")", ":", "if", "pattern_multiplicity", "is", "None", ":", "pattern_multiplicity", "=", "np", ".", "ones_like",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.prob_t_compressed
Calculate the probability of observing a sequence pair at a distance t, for compressed sequences Parameters ---------- seq_pair : numpy array :code:`np.array([(0,1), (2,2), ()..])` as indicies of pairs of aligned positions. (e.g. 'A'==0, 'C'==1 etc). ...
treetime/gtr.py
def prob_t_compressed(self, seq_pair, multiplicity, t, return_log=False): ''' Calculate the probability of observing a sequence pair at a distance t, for compressed sequences Parameters ---------- seq_pair : numpy array :code:`np.array([(0,1), (2,2), ()..]...
def prob_t_compressed(self, seq_pair, multiplicity, t, return_log=False): ''' Calculate the probability of observing a sequence pair at a distance t, for compressed sequences Parameters ---------- seq_pair : numpy array :code:`np.array([(0,1), (2,2), ()..]...
[ "Calculate", "the", "probability", "of", "observing", "a", "sequence", "pair", "at", "a", "distance", "t", "for", "compressed", "sequences" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L631-L664
[ "def", "prob_t_compressed", "(", "self", ",", "seq_pair", ",", "multiplicity", ",", "t", ",", "return_log", "=", "False", ")", ":", "if", "t", "<", "0", ":", "logP", "=", "-", "ttconf", ".", "BIG_NUMBER", "else", ":", "tmp_eQT", "=", "self", ".", "ex...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.prob_t
Compute the probability to observe seq_ch (child sequence) after time t starting from seq_p (parent sequence). Parameters ---------- seq_p : character array Parent sequence seq_c : character array Child sequence t : double Time (...
treetime/gtr.py
def prob_t(self, seq_p, seq_ch, t, pattern_multiplicity = None, return_log=False, ignore_gaps=True): """ Compute the probability to observe seq_ch (child sequence) after time t starting from seq_p (parent sequence). Parameters ---------- seq_p : characte...
def prob_t(self, seq_p, seq_ch, t, pattern_multiplicity = None, return_log=False, ignore_gaps=True): """ Compute the probability to observe seq_ch (child sequence) after time t starting from seq_p (parent sequence). Parameters ---------- seq_p : characte...
[ "Compute", "the", "probability", "to", "observe", "seq_ch", "(", "child", "sequence", ")", "after", "time", "t", "starting", "from", "seq_p", "(", "parent", "sequence", ")", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L667-L702
[ "def", "prob_t", "(", "self", ",", "seq_p", ",", "seq_ch", ",", "t", ",", "pattern_multiplicity", "=", "None", ",", "return_log", "=", "False", ",", "ignore_gaps", "=", "True", ")", ":", "seq_pair", ",", "multiplicity", "=", "self", ".", "compress_sequence...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.optimal_t
Find the optimal distance between the two sequences Parameters ---------- seq_p : character array Parent sequence seq_c : character array Child sequence pattern_multiplicity : numpy array If sequences are reduced by combining identical a...
treetime/gtr.py
def optimal_t(self, seq_p, seq_ch, pattern_multiplicity=None, ignore_gaps=False): ''' Find the optimal distance between the two sequences Parameters ---------- seq_p : character array Parent sequence seq_c : character array Child sequence ...
def optimal_t(self, seq_p, seq_ch, pattern_multiplicity=None, ignore_gaps=False): ''' Find the optimal distance between the two sequences Parameters ---------- seq_p : character array Parent sequence seq_c : character array Child sequence ...
[ "Find", "the", "optimal", "distance", "between", "the", "two", "sequences" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L705-L731
[ "def", "optimal_t", "(", "self", ",", "seq_p", ",", "seq_ch", ",", "pattern_multiplicity", "=", "None", ",", "ignore_gaps", "=", "False", ")", ":", "seq_pair", ",", "multiplicity", "=", "self", ".", "compress_sequence_pair", "(", "seq_p", ",", "seq_ch", ",",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.optimal_t_compressed
Find the optimal distance between the two sequences, for compressed sequences Parameters ---------- seq_pair : compressed_sequence_pair Compressed representation of sequences along a branch, either as tuple of state pairs or as tuple of profiles. multiplicity...
treetime/gtr.py
def optimal_t_compressed(self, seq_pair, multiplicity, profiles=False, tol=1e-10): """ Find the optimal distance between the two sequences, for compressed sequences Parameters ---------- seq_pair : compressed_sequence_pair Compressed representation of sequences alo...
def optimal_t_compressed(self, seq_pair, multiplicity, profiles=False, tol=1e-10): """ Find the optimal distance between the two sequences, for compressed sequences Parameters ---------- seq_pair : compressed_sequence_pair Compressed representation of sequences alo...
[ "Find", "the", "optimal", "distance", "between", "the", "two", "sequences", "for", "compressed", "sequences" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L734-L818
[ "def", "optimal_t_compressed", "(", "self", ",", "seq_pair", ",", "multiplicity", ",", "profiles", "=", "False", ",", "tol", "=", "1e-10", ")", ":", "def", "_neg_prob", "(", "t", ",", "seq_pair", ",", "multiplicity", ")", ":", "\"\"\"\n Probability ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.prob_t_profiles
Calculate the probability of observing a node pair at a distance t Parameters ---------- profile_pair: numpy arrays Probability distributions of the nucleotides at either end of the branch. pp[0] = parent, pp[1] = child multiplicity : numpy array ...
treetime/gtr.py
def prob_t_profiles(self, profile_pair, multiplicity, t, return_log=False, ignore_gaps=True): ''' Calculate the probability of observing a node pair at a distance t Parameters ---------- profile_pair: numpy arrays Probability distributions ...
def prob_t_profiles(self, profile_pair, multiplicity, t, return_log=False, ignore_gaps=True): ''' Calculate the probability of observing a node pair at a distance t Parameters ---------- profile_pair: numpy arrays Probability distributions ...
[ "Calculate", "the", "probability", "of", "observing", "a", "node", "pair", "at", "a", "distance", "t" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L821-L861
[ "def", "prob_t_profiles", "(", "self", ",", "profile_pair", ",", "multiplicity", ",", "t", ",", "return_log", "=", "False", ",", "ignore_gaps", "=", "True", ")", ":", "if", "t", "<", "0", ":", "logP", "=", "-", "ttconf", ".", "BIG_NUMBER", "else", ":",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.propagate_profile
Compute the probability of the sequence state of the parent at time (t+t0, backwards), given the sequence state of the child (profile) at time t0. Parameters ---------- profile : numpy.array Sequence profile. Shape = (L, a), where L - sequence length, a...
treetime/gtr.py
def propagate_profile(self, profile, t, return_log=False): """ Compute the probability of the sequence state of the parent at time (t+t0, backwards), given the sequence state of the child (profile) at time t0. Parameters ---------- profile : numpy.array ...
def propagate_profile(self, profile, t, return_log=False): """ Compute the probability of the sequence state of the parent at time (t+t0, backwards), given the sequence state of the child (profile) at time t0. Parameters ---------- profile : numpy.array ...
[ "Compute", "the", "probability", "of", "the", "sequence", "state", "of", "the", "parent", "at", "time", "(", "t", "+", "t0", "backwards", ")", "given", "the", "sequence", "state", "of", "the", "child", "(", "profile", ")", "at", "time", "t0", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L864-L894
[ "def", "propagate_profile", "(", "self", ",", "profile", ",", "t", ",", "return_log", "=", "False", ")", ":", "Qt", "=", "self", ".", "expQt", "(", "t", ")", "res", "=", "profile", ".", "dot", "(", "Qt", ")", "return", "np", ".", "log", "(", "res...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.evolve
Compute the probability of the sequence state of the child at time t later, given the parent profile. Parameters ---------- profile : numpy.array Sequence profile. Shape = (L, a), where L - sequence length, a - alphabet size. t : double Ti...
treetime/gtr.py
def evolve(self, profile, t, return_log=False): """ Compute the probability of the sequence state of the child at time t later, given the parent profile. Parameters ---------- profile : numpy.array Sequence profile. Shape = (L, a), where L - seq...
def evolve(self, profile, t, return_log=False): """ Compute the probability of the sequence state of the child at time t later, given the parent profile. Parameters ---------- profile : numpy.array Sequence profile. Shape = (L, a), where L - seq...
[ "Compute", "the", "probability", "of", "the", "sequence", "state", "of", "the", "child", "at", "time", "t", "later", "given", "the", "parent", "profile", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L897-L925
[ "def", "evolve", "(", "self", ",", "profile", ",", "t", ",", "return_log", "=", "False", ")", ":", "Qt", "=", "self", ".", "expQt", "(", "t", ")", ".", "T", "res", "=", "profile", ".", "dot", "(", "Qt", ")", "return", "np", ".", "log", "(", "...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR._exp_lt
Parameters ---------- t : float time to propagate Returns -------- exp_lt : numpy.array Array of values exp(lambda(i) * t), where (i) - alphabet index (the eigenvalue number).
treetime/gtr.py
def _exp_lt(self, t): """ Parameters ---------- t : float time to propagate Returns -------- exp_lt : numpy.array Array of values exp(lambda(i) * t), where (i) - alphabet index (the eigenvalue number). """ r...
def _exp_lt(self, t): """ Parameters ---------- t : float time to propagate Returns -------- exp_lt : numpy.array Array of values exp(lambda(i) * t), where (i) - alphabet index (the eigenvalue number). """ r...
[ "Parameters", "----------" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L928-L943
[ "def", "_exp_lt", "(", "self", ",", "t", ")", ":", "return", "np", ".", "exp", "(", "self", ".", "mu", "*", "t", "*", "self", ".", "eigenvals", ")" ]
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.expQt
Parameters ---------- t : float Time to propagate Returns -------- expQt : numpy.array Matrix exponential of exo(Qt)
treetime/gtr.py
def expQt(self, t): ''' Parameters ---------- t : float Time to propagate Returns -------- expQt : numpy.array Matrix exponential of exo(Qt) ''' eLambdaT = np.diag(self._exp_lt(t)) # vector length = a Qs = self....
def expQt(self, t): ''' Parameters ---------- t : float Time to propagate Returns -------- expQt : numpy.array Matrix exponential of exo(Qt) ''' eLambdaT = np.diag(self._exp_lt(t)) # vector length = a Qs = self....
[ "Parameters", "----------" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L946-L962
[ "def", "expQt", "(", "self", ",", "t", ")", ":", "eLambdaT", "=", "np", ".", "diag", "(", "self", ".", "_exp_lt", "(", "t", ")", ")", "# vector length = a", "Qs", "=", "self", ".", "v", ".", "dot", "(", "eLambdaT", ".", "dot", "(", "self", ".", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.expQsds
Returns ------- Qtds : Returns 2 V_{ij} \lambda_j s e^{\lambda_j s**2 } V^{-1}_{jk} This is the derivative of the branch probability with respect to s=\sqrt(t)
treetime/gtr.py
def expQsds(self, s): ''' Returns ------- Qtds : Returns 2 V_{ij} \lambda_j s e^{\lambda_j s**2 } V^{-1}_{jk} This is the derivative of the branch probability with respect to s=\sqrt(t) ''' lambda_eLambdaT = np.diag(2.0*self._exp_lt(s**2)*self.eigenvals*s...
def expQsds(self, s): ''' Returns ------- Qtds : Returns 2 V_{ij} \lambda_j s e^{\lambda_j s**2 } V^{-1}_{jk} This is the derivative of the branch probability with respect to s=\sqrt(t) ''' lambda_eLambdaT = np.diag(2.0*self._exp_lt(s**2)*self.eigenvals*s...
[ "Returns", "-------", "Qtds", ":", "Returns", "2", "V_", "{", "ij", "}", "\\", "lambda_j", "s", "e^", "{", "\\", "lambda_j", "s", "**", "2", "}", "V^", "{", "-", "1", "}", "_", "{", "jk", "}", "This", "is", "the", "derivative", "of", "the", "br...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L971-L980
[ "def", "expQsds", "(", "self", ",", "s", ")", ":", "lambda_eLambdaT", "=", "np", ".", "diag", "(", "2.0", "*", "self", ".", "_exp_lt", "(", "s", "**", "2", ")", "*", "self", ".", "eigenvals", "*", "s", ")", "# vector length = a", "Qsds", "=", "self...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.expQsdsds
Returns ------- Qtdtdt : Returns V_{ij} \lambda_j^2 e^{\lambda_j s**2} V^{-1}_{jk} This is the second derivative of the branch probability wrt time
treetime/gtr.py
def expQsdsds(self, s): ''' Returns ------- Qtdtdt : Returns V_{ij} \lambda_j^2 e^{\lambda_j s**2} V^{-1}_{jk} This is the second derivative of the branch probability wrt time ''' t=s**2 elt = self._exp_lt(t) lambda_eLambdaT = np.diag(elt*...
def expQsdsds(self, s): ''' Returns ------- Qtdtdt : Returns V_{ij} \lambda_j^2 e^{\lambda_j s**2} V^{-1}_{jk} This is the second derivative of the branch probability wrt time ''' t=s**2 elt = self._exp_lt(t) lambda_eLambdaT = np.diag(elt*...
[ "Returns", "-------", "Qtdtdt", ":", "Returns", "V_", "{", "ij", "}", "\\", "lambda_j^2", "e^", "{", "\\", "lambda_j", "s", "**", "2", "}", "V^", "{", "-", "1", "}", "_", "{", "jk", "}", "This", "is", "the", "second", "derivative", "of", "the", "...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L983-L994
[ "def", "expQsdsds", "(", "self", ",", "s", ")", ":", "t", "=", "s", "**", "2", "elt", "=", "self", ".", "_exp_lt", "(", "t", ")", "lambda_eLambdaT", "=", "np", ".", "diag", "(", "elt", "*", "(", "4.0", "*", "t", "*", "self", ".", "eigenvals", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
GTR.sequence_logLH
Returns the log-likelihood of sampling a sequence from equilibrium frequency. Expects a sequence as numpy array Parameters ---------- seq : numpy array Compressed sequence as an array of chars pattern_multiplicity : numpy_array The number of times eac...
treetime/gtr.py
def sequence_logLH(self,seq, pattern_multiplicity=None): """ Returns the log-likelihood of sampling a sequence from equilibrium frequency. Expects a sequence as numpy array Parameters ---------- seq : numpy array Compressed sequence as an array of chars ...
def sequence_logLH(self,seq, pattern_multiplicity=None): """ Returns the log-likelihood of sampling a sequence from equilibrium frequency. Expects a sequence as numpy array Parameters ---------- seq : numpy array Compressed sequence as an array of chars ...
[ "Returns", "the", "log", "-", "likelihood", "of", "sampling", "a", "sequence", "from", "equilibrium", "frequency", ".", "Expects", "a", "sequence", "as", "numpy", "array" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/gtr.py#L997-L1016
[ "def", "sequence_logLH", "(", "self", ",", "seq", ",", "pattern_multiplicity", "=", "None", ")", ":", "if", "pattern_multiplicity", "is", "None", ":", "pattern_multiplicity", "=", "np", ".", "ones_like", "(", "seq", ",", "dtype", "=", "float", ")", "return",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
plot_vs_years
Converts branch length to years and plots the time tree on a time axis. Parameters ---------- tt : TreeTime object A TreeTime instance after a time tree is inferred step : int Width of shaded boxes indicating blocks of years. Will be inferred if not specified. To switch off d...
treetime/treetime.py
def plot_vs_years(tt, step = None, ax=None, confidence=None, ticks=True, **kwargs): ''' Converts branch length to years and plots the time tree on a time axis. Parameters ---------- tt : TreeTime object A TreeTime instance after a time tree is inferred step : int Width of sha...
def plot_vs_years(tt, step = None, ax=None, confidence=None, ticks=True, **kwargs): ''' Converts branch length to years and plots the time tree on a time axis. Parameters ---------- tt : TreeTime object A TreeTime instance after a time tree is inferred step : int Width of sha...
[ "Converts", "branch", "length", "to", "years", "and", "plots", "the", "time", "tree", "on", "a", "time", "axis", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L798-L904
[ "def", "plot_vs_years", "(", "tt", ",", "step", "=", "None", ",", "ax", "=", "None", ",", "confidence", "=", "None", ",", "ticks", "=", "True", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "tt", ".", "branc...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.run
Run TreeTime reconstruction. Based on the input parameters, it divides the analysis into semi-independent jobs and conquers them one-by-one, gradually optimizing the tree given the temporal constarints and leaf node sequences. Parameters ---------- root : str ...
treetime/treetime.py
def run(self, root=None, infer_gtr=True, relaxed_clock=None, n_iqd = None, resolve_polytomies=True, max_iter=0, Tc=None, fixed_clock_rate=None, time_marginal=False, sequence_marginal=False, branch_length_mode='auto', vary_rate=False, use_covariation=False, **kwargs): """ ...
def run(self, root=None, infer_gtr=True, relaxed_clock=None, n_iqd = None, resolve_polytomies=True, max_iter=0, Tc=None, fixed_clock_rate=None, time_marginal=False, sequence_marginal=False, branch_length_mode='auto', vary_rate=False, use_covariation=False, **kwargs): """ ...
[ "Run", "TreeTime", "reconstruction", ".", "Based", "on", "the", "input", "parameters", "it", "divides", "the", "analysis", "into", "semi", "-", "independent", "jobs", "and", "conquers", "them", "one", "-", "by", "-", "one", "gradually", "optimizing", "the", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L36-L271
[ "def", "run", "(", "self", ",", "root", "=", "None", ",", "infer_gtr", "=", "True", ",", "relaxed_clock", "=", "None", ",", "n_iqd", "=", "None", ",", "resolve_polytomies", "=", "True", ",", "max_iter", "=", "0", ",", "Tc", "=", "None", ",", "fixed_c...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime._set_branch_length_mode
if branch_length mode is not explicitly set, set according to empirical branch length distribution in input tree Parameters ---------- branch_length_mode : str, 'input', 'joint', 'marginal' if the maximal branch length in the tree is longer than 0.05, this will ...
treetime/treetime.py
def _set_branch_length_mode(self, branch_length_mode): ''' if branch_length mode is not explicitly set, set according to empirical branch length distribution in input tree Parameters ---------- branch_length_mode : str, 'input', 'joint', 'marginal' if the m...
def _set_branch_length_mode(self, branch_length_mode): ''' if branch_length mode is not explicitly set, set according to empirical branch length distribution in input tree Parameters ---------- branch_length_mode : str, 'input', 'joint', 'marginal' if the m...
[ "if", "branch_length", "mode", "is", "not", "explicitly", "set", "set", "according", "to", "empirical", "branch", "length", "distribution", "in", "input", "tree" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L274-L298
[ "def", "_set_branch_length_mode", "(", "self", ",", "branch_length_mode", ")", ":", "if", "branch_length_mode", "in", "[", "'joint'", ",", "'marginal'", ",", "'input'", "]", ":", "self", ".", "branch_length_mode", "=", "branch_length_mode", "elif", "self", ".", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.clock_filter
Labels outlier branches that don't seem to follow a molecular clock and excludes them from subsequent molecular clock estimation and the timetree propagation. Parameters ---------- reroot : str Method to find the best root in the tree (see :py:meth:`treetime.TreeTim...
treetime/treetime.py
def clock_filter(self, reroot='least-squares', n_iqd=None, plot=False): ''' Labels outlier branches that don't seem to follow a molecular clock and excludes them from subsequent molecular clock estimation and the timetree propagation. Parameters ---------- reroo...
def clock_filter(self, reroot='least-squares', n_iqd=None, plot=False): ''' Labels outlier branches that don't seem to follow a molecular clock and excludes them from subsequent molecular clock estimation and the timetree propagation. Parameters ---------- reroo...
[ "Labels", "outlier", "branches", "that", "don", "t", "seem", "to", "follow", "a", "molecular", "clock", "and", "excludes", "them", "from", "subsequent", "molecular", "clock", "estimation", "and", "the", "timetree", "propagation", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L301-L358
[ "def", "clock_filter", "(", "self", ",", "reroot", "=", "'least-squares'", ",", "n_iqd", "=", "None", ",", "plot", "=", "False", ")", ":", "if", "n_iqd", "is", "None", ":", "n_iqd", "=", "ttconf", ".", "NIQD", "if", "type", "(", "reroot", ")", "is", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.plot_root_to_tip
Plot root-to-tip regression Parameters ---------- add_internal : bool If true, plot inte`rnal node positions label : bool If true, label the plots ax : matplotlib axes If not None, use the provided matplotlib axes to plot the results
treetime/treetime.py
def plot_root_to_tip(self, add_internal=False, label=True, ax=None): """ Plot root-to-tip regression Parameters ---------- add_internal : bool If true, plot inte`rnal node positions label : bool If true, label the plots ax : matplotlib axe...
def plot_root_to_tip(self, add_internal=False, label=True, ax=None): """ Plot root-to-tip regression Parameters ---------- add_internal : bool If true, plot inte`rnal node positions label : bool If true, label the plots ax : matplotlib axe...
[ "Plot", "root", "-", "to", "-", "tip", "regression" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L361-L382
[ "def", "plot_root_to_tip", "(", "self", ",", "add_internal", "=", "False", ",", "label", "=", "True", ",", "ax", "=", "None", ")", ":", "Treg", "=", "self", ".", "setup_TreeRegression", "(", ")", "if", "self", ".", "clock_model", "and", "'cov'", "in", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.reroot
Find best root and re-root the tree to the new root Parameters ---------- root : str Which method should be used to find the best root. Available methods are: :code:`best`, `least-squares` - minimize squared residual or likelihood of root-to-tip regression ...
treetime/treetime.py
def reroot(self, root='least-squares', force_positive=True, covariation=None): """ Find best root and re-root the tree to the new root Parameters ---------- root : str Which method should be used to find the best root. Available methods are: :code:`bes...
def reroot(self, root='least-squares', force_positive=True, covariation=None): """ Find best root and re-root the tree to the new root Parameters ---------- root : str Which method should be used to find the best root. Available methods are: :code:`bes...
[ "Find", "best", "root", "and", "re", "-", "root", "the", "tree", "to", "the", "new", "root" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L385-L482
[ "def", "reroot", "(", "self", ",", "root", "=", "'least-squares'", ",", "force_positive", "=", "True", ",", "covariation", "=", "None", ")", ":", "if", "type", "(", "root", ")", "is", "list", "and", "len", "(", "root", ")", "==", "1", ":", "root", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.resolve_polytomies
Resolve the polytomies on the tree. The function scans the tree, resolves polytomies if present, and re-optimizes the tree with new topology. Note that polytomies are only resolved if that would result in higher likelihood. Sometimes, stretching two or more branches that carry several m...
treetime/treetime.py
def resolve_polytomies(self, merge_compressed=False): """ Resolve the polytomies on the tree. The function scans the tree, resolves polytomies if present, and re-optimizes the tree with new topology. Note that polytomies are only resolved if that would result in higher likelihoo...
def resolve_polytomies(self, merge_compressed=False): """ Resolve the polytomies on the tree. The function scans the tree, resolves polytomies if present, and re-optimizes the tree with new topology. Note that polytomies are only resolved if that would result in higher likelihoo...
[ "Resolve", "the", "polytomies", "on", "the", "tree", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L485-L527
[ "def", "resolve_polytomies", "(", "self", ",", "merge_compressed", "=", "False", ")", ":", "self", ".", "logger", "(", "\"TreeTime.resolve_polytomies: resolving multiple mergers...\"", ",", "1", ")", "poly_found", "=", "0", "for", "n", "in", "self", ".", "tree", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime._poly
Function to resolve polytomies for a given parent node. If the number of the direct decendants is less than three (not a polytomy), does nothing. Otherwise, for each pair of nodes, assess the possible LH increase which could be gained by merging the two nodes. The increase in the LH is b...
treetime/treetime.py
def _poly(self, clade, merge_compressed): """ Function to resolve polytomies for a given parent node. If the number of the direct decendants is less than three (not a polytomy), does nothing. Otherwise, for each pair of nodes, assess the possible LH increase which could be gaine...
def _poly(self, clade, merge_compressed): """ Function to resolve polytomies for a given parent node. If the number of the direct decendants is less than three (not a polytomy), does nothing. Otherwise, for each pair of nodes, assess the possible LH increase which could be gaine...
[ "Function", "to", "resolve", "polytomies", "for", "a", "given", "parent", "node", ".", "If", "the", "number", "of", "the", "direct", "decendants", "is", "less", "than", "three", "(", "not", "a", "polytomy", ")", "does", "nothing", ".", "Otherwise", "for", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L530-L652
[ "def", "_poly", "(", "self", ",", "clade", ",", "merge_compressed", ")", ":", "from", ".", "branch_len_interpolator", "import", "BranchLenInterpolator", "zero_branch_slope", "=", "self", ".", "gtr", ".", "mu", "*", "self", ".", "seq_len", "def", "_c_gain", "("...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.print_lh
Print the total likelihood of the tree given the constrained leaves Parameters ---------- joint : bool If true, print joint LH, else print marginal LH
treetime/treetime.py
def print_lh(self, joint=True): """ Print the total likelihood of the tree given the constrained leaves Parameters ---------- joint : bool If true, print joint LH, else print marginal LH """ try: u_lh = self.tree.unconstrained_sequence_...
def print_lh(self, joint=True): """ Print the total likelihood of the tree given the constrained leaves Parameters ---------- joint : bool If true, print joint LH, else print marginal LH """ try: u_lh = self.tree.unconstrained_sequence_...
[ "Print", "the", "total", "likelihood", "of", "the", "tree", "given", "the", "constrained", "leaves" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L655-L684
[ "def", "print_lh", "(", "self", ",", "joint", "=", "True", ")", ":", "try", ":", "u_lh", "=", "self", ".", "tree", ".", "unconstrained_sequence_LH", "if", "joint", ":", "s_lh", "=", "self", ".", "tree", ".", "sequence_joint_LH", "t_lh", "=", "self", "....
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.add_coalescent_model
Add a coalescent model to the tree and optionally optimze Parameters ---------- Tc : float,str If this is a float, it will be interpreted as the inverse merger rate in molecular clock units, if its is a
treetime/treetime.py
def add_coalescent_model(self, Tc, **kwargs): """Add a coalescent model to the tree and optionally optimze Parameters ---------- Tc : float,str If this is a float, it will be interpreted as the inverse merger rate in molecular clock units, if its is a """...
def add_coalescent_model(self, Tc, **kwargs): """Add a coalescent model to the tree and optionally optimze Parameters ---------- Tc : float,str If this is a float, it will be interpreted as the inverse merger rate in molecular clock units, if its is a """...
[ "Add", "a", "coalescent", "model", "to", "the", "tree", "and", "optionally", "optimze" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L687-L714
[ "def", "add_coalescent_model", "(", "self", ",", "Tc", ",", "*", "*", "kwargs", ")", ":", "from", ".", "merger_models", "import", "Coalescent", "self", ".", "logger", "(", "'TreeTime.run: adding coalescent prior with Tc='", "+", "str", "(", "Tc", ")", ",", "1"...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime.relaxed_clock
Allow the mutation rate to vary on the tree (relaxed molecular clock). Changes of the mutation rates from one branch to another are penalized. In addition, deviation of the mutation rate from the mean rate is penalized. Parameters ---------- slack : float Ma...
treetime/treetime.py
def relaxed_clock(self, slack=None, coupling=None, **kwargs): """ Allow the mutation rate to vary on the tree (relaxed molecular clock). Changes of the mutation rates from one branch to another are penalized. In addition, deviation of the mutation rate from the mean rate is penal...
def relaxed_clock(self, slack=None, coupling=None, **kwargs): """ Allow the mutation rate to vary on the tree (relaxed molecular clock). Changes of the mutation rates from one branch to another are penalized. In addition, deviation of the mutation rate from the mean rate is penal...
[ "Allow", "the", "mutation", "rate", "to", "vary", "on", "the", "tree", "(", "relaxed", "molecular", "clock", ")", ".", "Changes", "of", "the", "mutation", "rates", "from", "one", "branch", "to", "another", "are", "penalized", ".", "In", "addition", "deviat...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L717-L767
[ "def", "relaxed_clock", "(", "self", ",", "slack", "=", "None", ",", "coupling", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "slack", "is", "None", ":", "slack", "=", "ttconf", ".", "MU_ALPHA", "if", "coupling", "is", "None", ":", "coupling...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
TreeTime._find_best_root
Determine the node that, when the tree is rooted on this node, results in the best regression of temporal constraints and root to tip distances. Parameters ---------- infer_gtr : bool If True, infer new GTR model after re-root covariation : bool accou...
treetime/treetime.py
def _find_best_root(self, covariation=True, force_positive=True, slope=0, **kwarks): ''' Determine the node that, when the tree is rooted on this node, results in the best regression of temporal constraints and root to tip distances. Parameters ---------- infer_gtr : b...
def _find_best_root(self, covariation=True, force_positive=True, slope=0, **kwarks): ''' Determine the node that, when the tree is rooted on this node, results in the best regression of temporal constraints and root to tip distances. Parameters ---------- infer_gtr : b...
[ "Determine", "the", "node", "that", "when", "the", "tree", "is", "rooted", "on", "this", "node", "results", "in", "the", "best", "regression", "of", "temporal", "constraints", "and", "root", "to", "tip", "distances", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treetime.py#L773-L795
[ "def", "_find_best_root", "(", "self", ",", "covariation", "=", "True", ",", "force_positive", "=", "True", ",", "slope", "=", "0", ",", "*", "*", "kwarks", ")", ":", "for", "n", "in", "self", ".", "tree", ".", "find_clades", "(", ")", ":", "n", "....
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
assure_tree
Function that attempts to load a tree and build it from the alignment if no tree is provided.
treetime/wrappers.py
def assure_tree(params, tmp_dir='treetime_tmp'): """ Function that attempts to load a tree and build it from the alignment if no tree is provided. """ if params.tree is None: params.tree = os.path.basename(params.aln)+'.nwk' print("No tree given: inferring tree") utils.tree_i...
def assure_tree(params, tmp_dir='treetime_tmp'): """ Function that attempts to load a tree and build it from the alignment if no tree is provided. """ if params.tree is None: params.tree = os.path.basename(params.aln)+'.nwk' print("No tree given: inferring tree") utils.tree_i...
[ "Function", "that", "attempts", "to", "load", "a", "tree", "and", "build", "it", "from", "the", "alignment", "if", "no", "tree", "is", "provided", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L16-L34
[ "def", "assure_tree", "(", "params", ",", "tmp_dir", "=", "'treetime_tmp'", ")", ":", "if", "params", ".", "tree", "is", "None", ":", "params", ".", "tree", "=", "os", ".", "path", ".", "basename", "(", "params", ".", "aln", ")", "+", "'.nwk'", "prin...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
create_gtr
parse the arguments referring to the GTR model and return a GTR structure
treetime/wrappers.py
def create_gtr(params): """ parse the arguments referring to the GTR model and return a GTR structure """ model = params.gtr gtr_params = params.gtr_params if model == 'infer': gtr = GTR.standard('jc', alphabet='aa' if params.aa else 'nuc') else: try: kwargs = {} ...
def create_gtr(params): """ parse the arguments referring to the GTR model and return a GTR structure """ model = params.gtr gtr_params = params.gtr_params if model == 'infer': gtr = GTR.standard('jc', alphabet='aa' if params.aa else 'nuc') else: try: kwargs = {} ...
[ "parse", "the", "arguments", "referring", "to", "the", "GTR", "model", "and", "return", "a", "GTR", "structure" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L36-L66
[ "def", "create_gtr", "(", "params", ")", ":", "model", "=", "params", ".", "gtr", "gtr_params", "=", "params", ".", "gtr_params", "if", "model", "==", "'infer'", ":", "gtr", "=", "GTR", ".", "standard", "(", "'jc'", ",", "alphabet", "=", "'aa'", "if", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
read_if_vcf
Checks if input is VCF and reads in appropriately if it is
treetime/wrappers.py
def read_if_vcf(params): """ Checks if input is VCF and reads in appropriately if it is """ ref = None aln = params.aln fixed_pi = None if hasattr(params, 'aln') and params.aln is not None: if any([params.aln.lower().endswith(x) for x in ['.vcf', '.vcf.gz']]): if not para...
def read_if_vcf(params): """ Checks if input is VCF and reads in appropriately if it is """ ref = None aln = params.aln fixed_pi = None if hasattr(params, 'aln') and params.aln is not None: if any([params.aln.lower().endswith(x) for x in ['.vcf', '.vcf.gz']]): if not para...
[ "Checks", "if", "input", "is", "VCF", "and", "reads", "in", "appropriately", "if", "it", "is" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L124-L148
[ "def", "read_if_vcf", "(", "params", ")", ":", "ref", "=", "None", "aln", "=", "params", ".", "aln", "fixed_pi", "=", "None", "if", "hasattr", "(", "params", ",", "'aln'", ")", "and", "params", ".", "aln", "is", "not", "None", ":", "if", "any", "("...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
scan_homoplasies
the function implementing treetime homoplasies
treetime/wrappers.py
def scan_homoplasies(params): """ the function implementing treetime homoplasies """ if assure_tree(params, tmp_dir='homoplasy_tmp'): return 1 gtr = create_gtr(params) ########################################################################### ### READ IN VCF ##################...
def scan_homoplasies(params): """ the function implementing treetime homoplasies """ if assure_tree(params, tmp_dir='homoplasy_tmp'): return 1 gtr = create_gtr(params) ########################################################################### ### READ IN VCF ##################...
[ "the", "function", "implementing", "treetime", "homoplasies" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L254-L458
[ "def", "scan_homoplasies", "(", "params", ")", ":", "if", "assure_tree", "(", "params", ",", "tmp_dir", "=", "'homoplasy_tmp'", ")", ":", "return", "1", "gtr", "=", "create_gtr", "(", "params", ")", "####################################################################...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
timetree
implementeing treetime tree
treetime/wrappers.py
def timetree(params): """ implementeing treetime tree """ if params.relax is None: relaxed_clock_params = None elif params.relax==[]: relaxed_clock_params=True elif len(params.relax)==2: relaxed_clock_params={'slack':params.relax[0], 'coupling':params.relax[1]} date...
def timetree(params): """ implementeing treetime tree """ if params.relax is None: relaxed_clock_params = None elif params.relax==[]: relaxed_clock_params=True elif len(params.relax)==2: relaxed_clock_params={'slack':params.relax[0], 'coupling':params.relax[1]} date...
[ "implementeing", "treetime", "tree" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L461-L609
[ "def", "timetree", "(", "params", ")", ":", "if", "params", ".", "relax", "is", "None", ":", "relaxed_clock_params", "=", "None", "elif", "params", ".", "relax", "==", "[", "]", ":", "relaxed_clock_params", "=", "True", "elif", "len", "(", "params", ".",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ancestral_reconstruction
implementing treetime ancestral
treetime/wrappers.py
def ancestral_reconstruction(params): """ implementing treetime ancestral """ # set up if assure_tree(params, tmp_dir='ancestral_tmp'): return 1 outdir = get_outdir(params, '_ancestral') basename = get_basename(params, outdir) gtr = create_gtr(params) ####################...
def ancestral_reconstruction(params): """ implementing treetime ancestral """ # set up if assure_tree(params, tmp_dir='ancestral_tmp'): return 1 outdir = get_outdir(params, '_ancestral') basename = get_basename(params, outdir) gtr = create_gtr(params) ####################...
[ "implementing", "treetime", "ancestral" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L612-L650
[ "def", "ancestral_reconstruction", "(", "params", ")", ":", "# set up", "if", "assure_tree", "(", "params", ",", "tmp_dir", "=", "'ancestral_tmp'", ")", ":", "return", "1", "outdir", "=", "get_outdir", "(", "params", ",", "'_ancestral'", ")", "basename", "=", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
mugration
implementing treetime mugration
treetime/wrappers.py
def mugration(params): """ implementing treetime mugration """ ########################################################################### ### Parse states ########################################################################### if os.path.isfile(params.states): states = pd.read_...
def mugration(params): """ implementing treetime mugration """ ########################################################################### ### Parse states ########################################################################### if os.path.isfile(params.states): states = pd.read_...
[ "implementing", "treetime", "mugration" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L652-L779
[ "def", "mugration", "(", "params", ")", ":", "###########################################################################", "### Parse states", "###########################################################################", "if", "os", ".", "path", ".", "isfile", "(", "params", ".",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
estimate_clock_model
implementing treetime clock
treetime/wrappers.py
def estimate_clock_model(params): """ implementing treetime clock """ if assure_tree(params, tmp_dir='clock_model_tmp'): return 1 dates = utils.parse_dates(params.dates) if len(dates)==0: return 1 outdir = get_outdir(params, '_clock') ##################################...
def estimate_clock_model(params): """ implementing treetime clock """ if assure_tree(params, tmp_dir='clock_model_tmp'): return 1 dates = utils.parse_dates(params.dates) if len(dates)==0: return 1 outdir = get_outdir(params, '_clock') ##################################...
[ "implementing", "treetime", "clock" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/wrappers.py#L782-L894
[ "def", "estimate_clock_model", "(", "params", ")", ":", "if", "assure_tree", "(", "params", ",", "tmp_dir", "=", "'clock_model_tmp'", ")", ":", "return", "1", "dates", "=", "utils", ".", "parse_dates", "(", "params", ".", "dates", ")", "if", "len", "(", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
Distribution.calc_fwhm
Assess the width of the probability distribution. This returns full-width-half-max
treetime/distribution.py
def calc_fwhm(distribution, is_neg_log=True): """ Assess the width of the probability distribution. This returns full-width-half-max """ if isinstance(distribution, interp1d): if is_neg_log: ymin = distribution.y.min() log_prob = dist...
def calc_fwhm(distribution, is_neg_log=True): """ Assess the width of the probability distribution. This returns full-width-half-max """ if isinstance(distribution, interp1d): if is_neg_log: ymin = distribution.y.min() log_prob = dist...
[ "Assess", "the", "width", "of", "the", "probability", "distribution", ".", "This", "returns", "full", "-", "width", "-", "half", "-", "max" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/distribution.py#L20-L55
[ "def", "calc_fwhm", "(", "distribution", ",", "is_neg_log", "=", "True", ")", ":", "if", "isinstance", "(", "distribution", ",", "interp1d", ")", ":", "if", "is_neg_log", ":", "ymin", "=", "distribution", ".", "y", ".", "min", "(", ")", "log_prob", "=", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
Distribution.delta_function
Create delta function distribution.
treetime/distribution.py
def delta_function(cls, x_pos, weight=1., min_width=MIN_INTEGRATION_PEAK): """ Create delta function distribution. """ distribution = cls(x_pos,0.,is_log=True, min_width=min_width) distribution.weight = weight return distribution
def delta_function(cls, x_pos, weight=1., min_width=MIN_INTEGRATION_PEAK): """ Create delta function distribution. """ distribution = cls(x_pos,0.,is_log=True, min_width=min_width) distribution.weight = weight return distribution
[ "Create", "delta", "function", "distribution", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/distribution.py#L59-L66
[ "def", "delta_function", "(", "cls", ",", "x_pos", ",", "weight", "=", "1.", ",", "min_width", "=", "MIN_INTEGRATION_PEAK", ")", ":", "distribution", "=", "cls", "(", "x_pos", ",", "0.", ",", "is_log", "=", "True", ",", "min_width", "=", "min_width", ")"...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
Distribution.multiply
multiplies a list of Distribution objects
treetime/distribution.py
def multiply(dists): ''' multiplies a list of Distribution objects ''' if not all([isinstance(k, Distribution) for k in dists]): raise NotImplementedError("Can only multiply Distribution objects") n_delta = np.sum([k.is_delta for k in dists]) min_width = np....
def multiply(dists): ''' multiplies a list of Distribution objects ''' if not all([isinstance(k, Distribution) for k in dists]): raise NotImplementedError("Can only multiply Distribution objects") n_delta = np.sum([k.is_delta for k in dists]) min_width = np....
[ "multiplies", "a", "list", "of", "Distribution", "objects" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/distribution.py#L75-L114
[ "def", "multiply", "(", "dists", ")", ":", "if", "not", "all", "(", "[", "isinstance", "(", "k", ",", "Distribution", ")", "for", "k", "in", "dists", "]", ")", ":", "raise", "NotImplementedError", "(", "\"Can only multiply Distribution objects\"", ")", "n_de...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree._assign_dates
assign dates to nodes Returns ------- str success/error code
treetime/clock_tree.py
def _assign_dates(self): """assign dates to nodes Returns ------- str success/error code """ if self.tree is None: self.logger("ClockTree._assign_dates: tree is not set, can't assign dates", 0) return ttconf.ERROR bad_branch_c...
def _assign_dates(self): """assign dates to nodes Returns ------- str success/error code """ if self.tree is None: self.logger("ClockTree._assign_dates: tree is not set, can't assign dates", 0) return ttconf.ERROR bad_branch_c...
[ "assign", "dates", "to", "nodes" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L86-L134
[ "def", "_assign_dates", "(", "self", ")", ":", "if", "self", ".", "tree", "is", "None", ":", "self", ".", "logger", "(", "\"ClockTree._assign_dates: tree is not set, can't assign dates\"", ",", "0", ")", "return", "ttconf", ".", "ERROR", "bad_branch_counter", "=",...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree._set_precision
function that sets precision to an (hopfully) reasonable guess based on the length of the sequence if not explicitly set
treetime/clock_tree.py
def _set_precision(self, precision): ''' function that sets precision to an (hopfully) reasonable guess based on the length of the sequence if not explicitly set ''' # if precision is explicitly specified, use it. if self.one_mutation: self.min_width = 10*sel...
def _set_precision(self, precision): ''' function that sets precision to an (hopfully) reasonable guess based on the length of the sequence if not explicitly set ''' # if precision is explicitly specified, use it. if self.one_mutation: self.min_width = 10*sel...
[ "function", "that", "sets", "precision", "to", "an", "(", "hopfully", ")", "reasonable", "guess", "based", "on", "the", "length", "of", "the", "sequence", "if", "not", "explicitly", "set" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L137-L179
[ "def", "_set_precision", "(", "self", ",", "precision", ")", ":", "# if precision is explicitly specified, use it.", "if", "self", ".", "one_mutation", ":", "self", ".", "min_width", "=", "10", "*", "self", ".", "one_mutation", "else", ":", "self", ".", "min_wid...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.setup_TreeRegression
instantiate a TreeRegression object and set its tip_value and branch_value function to defaults that are sensible for treetime instances. Parameters ---------- covariation : bool, optional account for phylogenetic covariation Returns ------- TreeRegre...
treetime/clock_tree.py
def setup_TreeRegression(self, covariation=True): """instantiate a TreeRegression object and set its tip_value and branch_value function to defaults that are sensible for treetime instances. Parameters ---------- covariation : bool, optional account for phylogenetic ...
def setup_TreeRegression(self, covariation=True): """instantiate a TreeRegression object and set its tip_value and branch_value function to defaults that are sensible for treetime instances. Parameters ---------- covariation : bool, optional account for phylogenetic ...
[ "instantiate", "a", "TreeRegression", "object", "and", "set", "its", "tip_value", "and", "branch_value", "function", "to", "defaults", "that", "are", "sensible", "for", "treetime", "instances", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L195-L221
[ "def", "setup_TreeRegression", "(", "self", ",", "covariation", "=", "True", ")", ":", "from", ".", "treeregression", "import", "TreeRegression", "tip_value", "=", "lambda", "x", ":", "np", ".", "mean", "(", "x", ".", "raw_date_constraint", ")", "if", "(", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.init_date_constraints
Get the conversion coefficients between the dates and the branch lengths as they are used in ML computations. The conversion formula is assumed to be 'length = k*numdate + b'. For convenience, these coefficients as well as regression parameters are stored in the 'dates2dist' object. ...
treetime/clock_tree.py
def init_date_constraints(self, ancestral_inference=False, clock_rate=None, **kwarks): """ Get the conversion coefficients between the dates and the branch lengths as they are used in ML computations. The conversion formula is assumed to be 'length = k*numdate + b'. For convenience, thes...
def init_date_constraints(self, ancestral_inference=False, clock_rate=None, **kwarks): """ Get the conversion coefficients between the dates and the branch lengths as they are used in ML computations. The conversion formula is assumed to be 'length = k*numdate + b'. For convenience, thes...
[ "Get", "the", "conversion", "coefficients", "between", "the", "dates", "and", "the", "branch", "lengths", "as", "they", "are", "used", "in", "ML", "computations", ".", "The", "conversion", "formula", "is", "assumed", "to", "be", "length", "=", "k", "*", "n...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L237-L316
[ "def", "init_date_constraints", "(", "self", ",", "ancestral_inference", "=", "False", ",", "clock_rate", "=", "None", ",", "*", "*", "kwarks", ")", ":", "self", ".", "logger", "(", "\"ClockTree.init_date_constraints...\"", ",", "2", ")", "self", ".", "tree", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.make_time_tree
Use the date constraints to calculate the most likely positions of unconstrained nodes. Parameters ---------- time_marginal : bool If true, use marginal reconstruction for node positions **kwargs Key word arguments to initialize dates constraints
treetime/clock_tree.py
def make_time_tree(self, time_marginal=False, clock_rate=None, **kwargs): ''' Use the date constraints to calculate the most likely positions of unconstrained nodes. Parameters ---------- time_marginal : bool If true, use marginal reconstruction for node po...
def make_time_tree(self, time_marginal=False, clock_rate=None, **kwargs): ''' Use the date constraints to calculate the most likely positions of unconstrained nodes. Parameters ---------- time_marginal : bool If true, use marginal reconstruction for node po...
[ "Use", "the", "date", "constraints", "to", "calculate", "the", "most", "likely", "positions", "of", "unconstrained", "nodes", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L319-L343
[ "def", "make_time_tree", "(", "self", ",", "time_marginal", "=", "False", ",", "clock_rate", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "logger", "(", "\"ClockTree: Maximum likelihood tree optimization with temporal constraints\"", ",", "1", ")", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree._ml_t_joint
Compute the joint maximum likelihood assignment of the internal nodes positions by propagating from the tree leaves towards the root. Given the assignment of parent nodes, reconstruct the maximum-likelihood positions of the child nodes by propagating from the root to the leaves. The result of th...
treetime/clock_tree.py
def _ml_t_joint(self): """ Compute the joint maximum likelihood assignment of the internal nodes positions by propagating from the tree leaves towards the root. Given the assignment of parent nodes, reconstruct the maximum-likelihood positions of the child nodes by propagating fr...
def _ml_t_joint(self): """ Compute the joint maximum likelihood assignment of the internal nodes positions by propagating from the tree leaves towards the root. Given the assignment of parent nodes, reconstruct the maximum-likelihood positions of the child nodes by propagating fr...
[ "Compute", "the", "joint", "maximum", "likelihood", "assignment", "of", "the", "internal", "nodes", "positions", "by", "propagating", "from", "the", "tree", "leaves", "towards", "the", "root", ".", "Given", "the", "assignment", "of", "parent", "nodes", "reconstr...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L346-L460
[ "def", "_ml_t_joint", "(", "self", ")", ":", "def", "_cleanup", "(", ")", ":", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", ")", ":", "del", "node", ".", "joint_pos_Lx", "del", "node", ".", "joint_pos_Cx", "self", ".", "logger", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.timetree_likelihood
Return the likelihood of the data given the current branch length in the tree
treetime/clock_tree.py
def timetree_likelihood(self): ''' Return the likelihood of the data given the current branch length in the tree ''' LH = 0 for node in self.tree.find_clades(order='preorder'): # sum the likelihood contributions of all branches if node.up is None: # root node ...
def timetree_likelihood(self): ''' Return the likelihood of the data given the current branch length in the tree ''' LH = 0 for node in self.tree.find_clades(order='preorder'): # sum the likelihood contributions of all branches if node.up is None: # root node ...
[ "Return", "the", "likelihood", "of", "the", "data", "given", "the", "current", "branch", "length", "in", "the", "tree" ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L463-L476
[ "def", "timetree_likelihood", "(", "self", ")", ":", "LH", "=", "0", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", "order", "=", "'preorder'", ")", ":", "# sum the likelihood contributions of all branches", "if", "node", ".", "up", "is", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree._ml_t_marginal
Compute the marginal probability distribution of the internal nodes positions by propagating from the tree leaves towards the root. The result of this operation are the probability distributions of each internal node, conditional on the constraints on all leaves of the tree, which have sampling ...
treetime/clock_tree.py
def _ml_t_marginal(self, assign_dates=False): """ Compute the marginal probability distribution of the internal nodes positions by propagating from the tree leaves towards the root. The result of this operation are the probability distributions of each internal node, conditional ...
def _ml_t_marginal(self, assign_dates=False): """ Compute the marginal probability distribution of the internal nodes positions by propagating from the tree leaves towards the root. The result of this operation are the probability distributions of each internal node, conditional ...
[ "Compute", "the", "marginal", "probability", "distribution", "of", "the", "internal", "nodes", "positions", "by", "propagating", "from", "the", "tree", "leaves", "towards", "the", "root", ".", "The", "result", "of", "this", "operation", "are", "the", "probabilit...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L479-L648
[ "def", "_ml_t_marginal", "(", "self", ",", "assign_dates", "=", "False", ")", ":", "def", "_cleanup", "(", ")", ":", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", ")", ":", "try", ":", "del", "node", ".", "marginal_pos_Lx", "del", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.convert_dates
This function converts the estimated "time_before_present" properties of all nodes to numerical dates stored in the "numdate" attribute. This date is further converted into a human readable date string in format %Y-%m-%d assuming the usual calendar. Returns ------- None ...
treetime/clock_tree.py
def convert_dates(self): ''' This function converts the estimated "time_before_present" properties of all nodes to numerical dates stored in the "numdate" attribute. This date is further converted into a human readable date string in format %Y-%m-%d assuming the usual calendar. ...
def convert_dates(self): ''' This function converts the estimated "time_before_present" properties of all nodes to numerical dates stored in the "numdate" attribute. This date is further converted into a human readable date string in format %Y-%m-%d assuming the usual calendar. ...
[ "This", "function", "converts", "the", "estimated", "time_before_present", "properties", "of", "all", "nodes", "to", "numerical", "dates", "stored", "in", "the", "numdate", "attribute", ".", "This", "date", "is", "further", "converted", "into", "a", "human", "re...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L651-L687
[ "def", "convert_dates", "(", "self", ")", ":", "from", "datetime", "import", "datetime", ",", "timedelta", "now", "=", "numeric_date", "(", ")", "for", "node", "in", "self", ".", "tree", ".", "find_clades", "(", ")", ":", "years_bp", "=", "self", ".", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.branch_length_to_years
This function sets branch length to reflect the date differences between parent and child nodes measured in years. Should only be called after :py:meth:`timetree.ClockTree.convert_dates` has been called. Returns ------- None All manipulations are done in place on the tree
treetime/clock_tree.py
def branch_length_to_years(self): ''' This function sets branch length to reflect the date differences between parent and child nodes measured in years. Should only be called after :py:meth:`timetree.ClockTree.convert_dates` has been called. Returns ------- None ...
def branch_length_to_years(self): ''' This function sets branch length to reflect the date differences between parent and child nodes measured in years. Should only be called after :py:meth:`timetree.ClockTree.convert_dates` has been called. Returns ------- None ...
[ "This", "function", "sets", "branch", "length", "to", "reflect", "the", "date", "differences", "between", "parent", "and", "child", "nodes", "measured", "in", "years", ".", "Should", "only", "be", "called", "after", ":", "py", ":", "meth", ":", "timetree", ...
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L690-L707
[ "def", "branch_length_to_years", "(", "self", ")", ":", "self", ".", "logger", "(", "'ClockTree.branch_length_to_years: setting node positions in units of years'", ",", "2", ")", "if", "not", "hasattr", "(", "self", ".", "tree", ".", "root", ",", "'numdate'", ")", ...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0
test
ClockTree.calc_rate_susceptibility
return the time tree estimation of evolutionary rates +/- one standard deviation form the ML estimate. Returns ------- TreeTime.return_code : str success or failure
treetime/clock_tree.py
def calc_rate_susceptibility(self, rate_std=None, params=None): """return the time tree estimation of evolutionary rates +/- one standard deviation form the ML estimate. Returns ------- TreeTime.return_code : str success or failure """ params = params...
def calc_rate_susceptibility(self, rate_std=None, params=None): """return the time tree estimation of evolutionary rates +/- one standard deviation form the ML estimate. Returns ------- TreeTime.return_code : str success or failure """ params = params...
[ "return", "the", "time", "tree", "estimation", "of", "evolutionary", "rates", "+", "/", "-", "one", "standard", "deviation", "form", "the", "ML", "estimate", "." ]
neherlab/treetime
python
https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/clock_tree.py#L710-L757
[ "def", "calc_rate_susceptibility", "(", "self", ",", "rate_std", "=", "None", ",", "params", "=", "None", ")", ":", "params", "=", "params", "or", "{", "}", "if", "rate_std", "is", "None", ":", "if", "not", "(", "self", ".", "clock_model", "[", "'valid...
f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0