Table of Contents#
- math.Skewness
- math.Variance
- math.Std
- math.GatherDescriptiveStats
- math.GetIC
- math.HolmBonferroniCorrection
- math.BenjaminiHochbergFDR
- math.minNormalizedRange
- math.DoLRT
- math.Sum
- math
- math.Median
- math.Int
- math.Mean
- math.Kurtosis
- matrix
- matrix.Symmetrize
- random
- regexp.Split
- regexp
- regexp.Replace
- regexp.Find
- regexp.FindSubexpressions
- regexp.PartitionByRegularExpressions
- models.binary.generic.Time
- models.binary.generic.DefineQMatrix
- models.binary
- models.codon.generate_stencil
- models.codon.generic.DefineQMatrix
- models.codon
- models.codon.MapCode
- models.DNA.generic.Time
- models.DNA.generic.DefineQMatrix
- models.DNA
- frequencies.empirical.binary
- frequencies.empirical.binary
- frequencies.empirical.protein
- frequencies.empirical.protein
- frequencies.empirical.protein
- frequencies.equal
- frequencies.empirical.F3x4
- frequencies.empirical.F1x4
- frequencies.empirical.corrected.CF3x4
- frequencies.mle
- frequencies.empirical.nucleotide
- frequencies.empirical.nucleotide
- frequencies
- model.ApplyToBranch
- model.define_from_components
- model.generic.AddLocal
- model.generic.AddGlobal
- model.generic.GetLocalParameter
- model.generic.GetLocalParameter
- model.generic.GetGlobalParameter
- model.generic.get_a_parameter
- model.generic.get_rate_variation
- model.generic.DefineModel
- model.generic.DefineMixtureModel
- model.ApplyModelToTree
- models.generic.ConstrainBranchLength
- models.generic.SetBranchLength
- models.generic.AttachFilter
- model.Dimension
- model.parameters.Local
- model.parameters.Global
- model.MatchAlphabets
- model
- model.GetParameters_RegExp
- parameters.DeclareCategory
- parameters.NormalizeRatio
- parameters.SetValue
- parameters.SetLocalValue
- parameters.SetValues
- parameters.ConstrainMeanOfSet
- parameters.UnconstrainParameterSet
- parameters.Mean
- parameters.Quote
- parameters.AppendMultiplicativeTerm
- parameters.AddMultiplicativeTerm
- parameters.StringMatrixToFormulas
- parameters.GenerateAttributedNames
- parameters
- parameters.GenerateSequentialNames
- parameters.GetRange
- parameters.SetRange
- parameters.DeclareGlobal
- parameters.IsIndependent
- parameters.SetConstraint
- parameters.SetProprtionalConstraint
- parameters.ConstrainSets
- parameters.RemoveConstraint
- parameters.helper.copy_definitions
- pparameters.SetStickBreakingDistribution
- pparameters.GetStickBreakingDistribution
- parameters.helper.stick_breaking
- parameters.helper.dump_matrix
- parameters.helper.tree_lengths_to_initial_values
- parameters.GetProfileCI
- parameters.ExportParameterDefinition
- parameters.SetLocalModelParameters
- parameters.SetLocalModelParameters
- parameters.ApplyNameSpace
- parameters.ValidateID
- parameters.DeclareGlobalWithRanges
- models.protein.generic.Time
- models.protein
- models.protein.generic.DefineQMatrix
- rate_variation
- alignments.GetSequenceNames
- alignments.GetSequenceNames
- alignments.GetIthSequence
- alignments.LoadGeneticCode
- alignments.GetIthSequenceOriginalName
- alignments.GetAllSequences
- alignments.ReadNucleotideDataSet
- alignments.FilterType
- alignments.ReadProteinDataSet
- alignments.AlphabetType
- alignments.EnsureMapping
- alignments.ReadNucleotideDataSetString
- alignments.PromptForGeneticCodeAndAlignment
- alignments.LoadGeneticCodeAndAlignment
- alignments.LoadCodonDataFile
- alignments.ReadCodonDataSetFromPath
- alignments.ReadNucleotideAlignment
- alignments.CompressDuplicateSequences
- alignments.DefineFiltersForPartitions
- alignments.serialize_site_filter
- alignments.ReadCodonDataSet
- alignments.ReadCodonDataSetFromPathGivenCode
- alignments.Extract_site_patterns
- ancestral.Sequences
- ancestral.ComputeSubstitutionCounts
- ancestral
- ancestral.build
- distances.nucleotide.tn93
- distances.nucleotide.p_distance
- estimators.FitCodonModel
- estimators.FitMGREV
- estimators.FitMGREV
- estimators.ComputeLF
- estimators.CreateInitialGrid
- estimators.LHC
- estimators.SetGlobals
- estimators.SetCategory
- estimators.ExtractBranchInformation.copy_local
- estimators.ExtractBranchInformation
- estimators.branch_lengths_in_string
- estimators.ExtractMLEs
- estimators.ExtractMLEsOptions
- estimators.TraverseLocalParameters
- estimators.GetGlobalMLE
- estimators.FitExistingLF
- estimators.FitLF
- estimators.FitLF
- estimators.GetBranchEstimates
- estimators.TakeLFStateSnapshot
- estimators.GetGlobalMLE_RegExp
- estimators.FitSingleModel_Ext
- estimators.FitGTR_Ext
- estimators.FitGTR
- genetic_code.DefineCodonToAAMapping
- genetic_code.DefineCodonToAAMapping
- genetic_code.IsStop
- genetic_code.DefineCodonToAAGivenCode
- genetic_code
- trees.infer.NJ
- trees.GetTreeString
- trees._matrix2string
- trees.PartitionTree
- trees.LoadAnnotatedTopology
- trees.LoadAnnotatedTopologyAndMap
- trees.LoadAnnotatedTreeTopology.match_partitions
- trees.branch_names
- trees.RootTree
- trees.ExtractTreeInfo
- trees.HasBranchLengths
- trees.BootstrapSupport
- trees.GetBranchCount
- trees.SortedBranchLengths
- trees.BranchNames
- trees.ParsimonyLabel
- trees.ParsimonyLabel
- trees.ConjunctionLabel
- trees.GenerateSymmetricTree
- trees.GenerateSymmetricTree
- trees
- trees.GenerateRandomTree
math.Skewness#
Returns skewness of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math.Variance#
Returns variance of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math.Std#
Returns standard deviation of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math.GatherDescriptiveStats#
Returns suite of statistical information for a 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math.GetIC#
Computes small-sample AIC
Parameters
logl
params
samples
math.HolmBonferroniCorrection#
Returns Holm-Bonferroni corrected p-values
Parameters
ps
Dict a key -> p-value (or null, for not done)
math.BenjaminiHochbergFDR#
Returns Benjamini-Hochberg corrected q-values (FDR)
Parameters
ps
Dict a key -> p-value (or null, for not done)
math.minNormalizedRange#
Returns the range normalized to the lowest value
Returns number
math.DoLRT#
Computes the LRT and p-value
Parameters
lognull
logalt
df
math.Sum#
Computes sum of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math#
math.Median#
Returns median average of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math.Int#
Converts a float to integer by rounding
Parameters
float
math.Mean#
Returns mean average of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
math.Kurtosis#
Returns kurtosis of 1xN vector
Parameters
_data_vector
Matrix 1xN vector
matrix#
matrix.Symmetrize#
upper triangle gets copied to lower triangle for non-square matrices, the largest square minor is symmetrized
Parameters
mx
Matrix matrix to perform transform on
Returns any nothing
random#
#
Parameters
strings
Dict/Matrix set of strings to partition (if Dict, will use the set of VALUES)rex
Dict/Matrix string matrix of regular expressions (if Dict, will use the set of VALUES)
Returns Dict "reg-exp" : "set of matched strings" (as dict) PLUS a special key ("") which did not match any regular expression
regexp.Split#
Parameters
Returns Dictionary a dictionary containing split strings
regexp#
regexp.Replace#
Parameters
string
Stringre
String search for this expressionrepl
String replace each occurence of re with repl
Returns Dictionary a dictionary containing split strings
regexp.Find#
Parameters
Returns String the portion of the string that is matching
regexp.FindSubexpressions#
Parameters
Returns AssociativeList all matched RE subsexpressions
regexp.PartitionByRegularExpressions#
Parameters
strings
Dict/Matrix set of strings to partition (if Dict, will use the set of VALUES)rex
Dict/Matrix string matrix of regular expressions ((if Dict, will use the set of VALUES)
Returns Dict "reg-exp" : "set of matched strings" (as dict) PLUS a special key ("") which did not match any regular expression
models.binary.generic.Time#
Parameters
option
does nothing
Returns any default time
models.binary.generic.DefineQMatrix#
Parameters
modelSpec
Dictionarynamespace
String
models.binary#
models.codon.generate_stencil#
Generates a branch length extraction stencil for synonymous and non-synonymous rates
Parameters
type
String terms.genetic_code.synonymous or terms.genetic_code.nonsynonymous or callbackmodel
Dictionary the model object
Returns Matrix the appropriate NxN matrix stencil
models.codon.generic.DefineQMatrix#
Parameters
modelSpect
namespace
#
return complete differences between two codons *
models.codon#
models.codon.MapCode#
Parameters
genetic_code
String
Returns Dictionary the sense, stop, and translation-table for the genetic code
models.DNA.generic.Time#
Parameters
option
does nothing
Returns any default time
models.DNA.generic.DefineQMatrix#
Parameters
modelSpec
Dictionarynamespace
String
models.DNA#
frequencies.empirical.binary#
Sets model's equilibrium frequency estimator to ML for binary data
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.empirical.binary#
Sets model's equilibrium frequency estimator to Binary chatacter 2x1 estimator
Parameters
model
Dictionarynamespace
String does nothingdatafilter
DataSetFilter does nothing
Returns Dictionary updated model
frequencies.empirical.protein#
Sets model's equilibrium frequency estimator to protein 20x1 estimator
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.empirical.protein#
Sets model's equilibrium frequency estimator to ML for protein data
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.empirical.protein#
Multiplies nucleotide frequencies into the empirical codon estimate
Parameters
model
Dictionary__estimates
Matrix 4x3 matrix of frequency estimates
Returns Dictionary updated model
frequencies.equal#
Sets model's equilibrium frequency estimator to equal frequencies
Parameters
model
Dictionarynamespace
String does nothingdatafilter
DataSetFilter does nothing
Returns Dictionary updated model
frequencies.empirical.F3x4#
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.empirical.F1x4#
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.empirical.corrected.CF3x4#
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.mle#
To be implemented
Parameters
model
namespace
datafilter
frequencies.empirical.nucleotide#
Sets model's equilibrium frequency estimator to Nucleotide 4x1 estimator
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies.empirical.nucleotide#
Compute equilibrium frequencies at run-time using Q inversion
Parameters
model
Dictionarynamespace
Stringdatafilter
DataSetFilter
Returns Dictionary updated model
frequencies#
#
This is an function that computes stationary frequencies of Markov process based on its
rate matrix
Parameters
Q
Matrix matrix
model.ApplyToBranch#
Parameters
model_id
tree
branch
model.define_from_components#
Parameters
id
{String} Name of of Modelq
{Matrix} instantaneous transition matrixevf
{Matrix} the equilibrium frequenciescanonical
Number matrix exponential
Examples
q = {{*,t,kappa*t,t}
{t,*,t,t*kappa}
{t*kappa,t,*,t}
{t,t*kappa,t,*}};
evf = {{0.4}{0.3}{0.2}{0.1}};
model.define_from_components(q,evf,1);
Returns any nothing, sets a global {Model}
model.generic.AddLocal#
Parameters
model_spec
id
tag
model.generic.AddGlobal#
Parameters
model_spec
id
tag
model.generic.GetLocalParameter#
Parameters
model_spec
tag
model.generic.GetLocalParameter#
Parameters
model
Model
Returns String
model.generic.GetGlobalParameter#
Parameters
model_spec
tag
model.generic.get_a_parameter#
Parameters
model_spec
tag
type
model.generic.get_rate_variation#
Parameters
model_spec
tag
type
model.generic.DefineModel#
Parameters
model_spec
id
arguments
data_filter
estimator_type
model.generic.DefineMixtureModel#
Parameters
model_spec
id
arguments
data_filter
estimator_type
model.ApplyModelToTree#
Parameters
id
{String}tree
model_list
rules
models.generic.ConstrainBranchLength#
Parameters
model
Modelor
AssociativeList {Number} valueparameter
String
Returns any the number of constraints generated (0 or 1)
models.generic.SetBranchLength#
Parameters
model
Modelor
AssociativeList {Number} valueparameter
String
Returns any the number of constraints generated (0 or 1)
models.generic.AttachFilter#
Parameters
model
Modelfilter
DataSetFilter
Returns any 0
model.Dimension#
Parameters
model
Model
Returns Matrix dimensions of model
model.parameters.Local#
Parameters
model
Model
Returns Matrix local parameters
model.parameters.Global#
Parameters
model
Model
Returns Matrix global parameters
model.MatchAlphabets#
Parameters
a1
Matrix first alphabet to comparea2
Matrix second alphabet to compare
Returns Number 1 if they are equal, 0 if they are not
#
Parameters
models
Dict list of model objectsfilter
RegEx only apply to parameters matching this expression
Returns Dict the set of constraints applied
#
Parameters
model
Dict first alphabet to compare
Returns String the branch length expression string
model#
model.GetParameters_RegExp#
Parameters
model
{String} - model IDre
{String} - regular expression
Returns any a dictionary of global model parameters that match a regexp
parameters.DeclareCategory#
Parameters
def
Dict category definition components
parameters.NormalizeRatio#
Parameters
Returns any n/d
parameters.SetValue#
Sets value of passed parameter id
Parameters
Returns any nothing
parameters.SetLocalValue#
Sets value of passed parameter tree.branch.id
Parameters
tree
String id of treebranch
String id of branchid
String id of parameter to set value tovalue
Number value to set
Returns any nothing
parameters.SetValues#
Sets value of passed parameter id
Parameters
desc
dict -> {id : id, mle : value}
Returns any nothing
parameters.ConstrainMeanOfSet#
Ensures that the mean of parameters in a set is maintained
Parameters
set
Dict/Matrix list of variable idsweights
Dict/Matrix weights to applymean
Number desired meannamespace
String desired mean
Returns any nothing
parameters.UnconstrainParameterSet#
Parameters
lf
LikelihoodFunction the likelihood function to operate onset
Matrix set of parameters to unconstrain
Returns any nothing
parameters.Mean#
Returns mean of values
Parameters
values
Matrix values to return mean ofweights
Matrix weights to multiply values byd
Number does nothing
Returns Number mean
parameters.Quote#
Quotes the argument
Parameters
arg
String string to be quoted
Returns String string in quotes
parameters.AppendMultiplicativeTerm#
Parameters
Returns String (expression) * (term)
parameters.AddMultiplicativeTerm#
Parameters
matrix
Matrix matrix to scaleterm
Number scalar to multiply matrix bydo_empties
Number if element matrix is empty, fill with term
Returns Matrix New matrix
parameters.StringMatrixToFormulas#
Parameters
id
String matrix to scalematrix
Matrix if element matrix is empty, fill with term
Returns any nothing
parameters.GenerateAttributedNames#
Parameters
parameters#
parameters.GenerateSequentialNames#
Parameters
Returns Matrix 1 x
parameters.GetRange#
Parameters
id
Returns any variable range
parameters.SetRange#
Parameters
id
ranges
Returns any nothing
parameters.DeclareGlobal#
Parameters
id
Stringcache
Matrix
Returns any nothing
parameters.IsIndependent#
Check if parameter is independent
Parameters
parameter
id of parameter to check
Returns Bool TRUE if independent, FALSE otherwise
parameters.SetConstraint#
sets constraint on parameter
Parameters
or
String {AssociativeList} id - id(s) of parameter(s) to set constraint onvalue
Number the constraint to set on the parameterglobal_tag
String the global namespace of the parameter
Returns any nothing
parameters.SetProprtionalConstraint#
constrain x to be x := C * (current value of x)
Parameters
id
String of parameter(s) to set constraint onscaler
String variable - the ID of the 'C' scaler variable above; could also be an expression
Returns any nothing
parameters.ConstrainSets#
constraint set of parameters
Parameters
set1
AssociativeList -set2
AssociativeList -
Returns any nothing
parameters.RemoveConstraint#
Removes a constraint from a parameter
Parameters
id
String id of parameter to remove constraint from
Returns any nothing
parameters.helper.copy_definitions#
Copies definitions from target to source
Parameters
target
Dictionary the target dictionarysource
Dictionary the source element to copy to target
Returns any nothing
pparameters.SetStickBreakingDistribution#
Parameters
parameters
AssociativeListvalues
Matrix
Returns any nothing
pparameters.GetStickBreakingDistribution#
Parameters
parameters
AssociativeList
Returns Matrix computed distribution (Nx2)
parameters.helper.stick_breaking#
Parameters
parameters
AssociativeListinitial_values
Matrix
Returns any weights
parameters.helper.dump_matrix#
Prints matrix to screen
Parameters
matrix
Matrix
Returns any nothing
parameters.helper.tree_lengths_to_initial_values#
Sets tree lengths to initial values
Parameters
dict
a [0 to N-1] dictrionary of tree objectstype
codon or nucleotide
Returns Dictionary dictionary of initial branch lengths
parameters.GetProfileCI#
Profiles likelihood function based on covariance precision level
Parameters
id
String covariance parameter idlf
LikelihoodFunction likelihood function to profilenull-null
Number Covariance precision level
Returns Dictionary a dictionary containing profiling information
parameters.ExportParameterDefinition#
Geneate an HBL string needed to define a parameter
Parameters
id
String the name of the parameter to export;
Returns String the string for an HBL definition of the parameter e.g. "global x := 2.3; x :> 1; x :< 3"; note that the definition will be NOT recursive, so if x depends on y and z, then y and z need to be exported separately
parameters.SetLocalModelParameters#
Copy local parameters from a node to 'template' variables
Parameters
model
Dict model descriptiontree
String idnode
String ide.g. set alpha = Tree.Node.alpha set beta = Tree.Node.beta
parameters.SetLocalModelParameters#
Set category variables to their mean values for branch length calculations
Parameters
model
Dict model description
parameters.ApplyNameSpace#
Applies a namespace to parameter ids
Parameters
parameters.ValidateID#
Given a set of strings, convert them to valid IDs that don't clash following renames
Parameters
ids
Array/Dict the ids to validate (should be unique), if dict, should be i -> ID
Returns Dictionary a dictionary containing old -> new id map
parameters.DeclareGlobalWithRanges#
Parameters
id
String variable idinit
Number initial value (could be None)lb
Number lower bound (could be None)ub
Number upper bound (could be None)
Returns any nothing
models.protein.generic.Time#
Parameters
option
does nothing
Returns any default time
models.protein#
models.protein.generic.DefineQMatrix#
Parameters
modelSpec
Dictionarynamespace
String
rate_variation#
alignments.GetSequenceNames#
Get sequence names from existing dataset
Parameters
dataset_name
String name of dataset to get sequence names from
Returns Matrix list of sequence names
alignments.GetSequenceNames#
Get sequence from existing dataset by name
Parameters
dataset_name
String name of dataset to get sequence names fromsequence_name
(String | None) the name of the sequence to extract or None to set up the initial mapping
Returns String the corresponding sequence string
alignments.GetIthSequence#
Get i-th sequence name/value from an alignment
Parameters
dataset_name
String name of dataset to get sequence names fromindex
String the name of the sequence to extract or None to set up the initial mapping
Returns Dict {"id" : sequence name, "sequence" : sequence data}
alignments.LoadGeneticCode#
Reads dataset from a file path
Parameters
code
String name - name of the genetic code to load, or None to prompt
Returns Dictionary metadata pertaining to the genetic code
alignments.GetIthSequenceOriginalName#
Get i-th sequence name/value from an alignment; retrieve the original sequence name if available
Parameters
dataset_name
String name of dataset to get sequence names fromindex
String the name of the sequence to extract or None to set up the initial mapping
Returns Dict {"id" : sequence name, "sequence" : sequence data}
alignments.GetAllSequences#
Get all sequences as "id" : "sequence" dictionary
Parameters
dataset_name
String name of dataset to get sequence names from
Returns Dict { id -> sequence}
alignments.ReadNucleotideDataSet#
Read Nucleotide dataset from file_name
Parameters
dataset_name
the name of the dataset you wish to usefile_name
path to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.FilterType#
Determine what type of data are in the filter
Parameters
filter_name
String the name of the dataset filter object
Returns String one of the standard datatypes, or the alphabet string if it's non-standard
alignments.ReadProteinDataSet#
Read a protein dataset from file_name
Parameters
dataset_name
the name of the dataset you wish to usefile_name
path to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.AlphabetType#
Categorize an alphabet for an alignment
Parameters
alphabet
the alphabet vector, e.g. fetched by GetDataInfo (alphabet, ..., "CHARACTERS");
Returns String one of standard alphabet types or None if unknown
alignments.EnsureMapping#
Ensure that name mapping is not None by creating a f(x)=x map if needed
Parameters
dataset_name
the name of the dataset you wish to user
Dictionary metadata pertaining to the datasetfile_name
path to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.ReadNucleotideDataSetString#
Read dataset from data
Parameters
Returns Dictionary r - metadata pertaining to the dataset
alignments.PromptForGeneticCodeAndAlignment#
Prompts user for genetic code and alignment
Parameters
dataset_name
String the name of the dataset you wish to usedatafilter_name
String the name of the dataset filter you wish to use
Returns Dictionary r - metadata pertaining to the dataset
alignments.LoadGeneticCodeAndAlignment#
Loads genetic code and alignment from file path
Parameters
dataset_name
String the name of the dataset you wish to usedatafilter_name
String the name of the dataset filter you wish to usepath
String path to file
Returns Dictionary r - metadata pertaining to the dataset
alignments.LoadCodonDataFile#
Creates codon dataset filter from data set
Parameters
datafilter_name
String the name of the dataset filter you wish to usedataset_name
String the name of the existing datasetdata_info
Dictionary DataSet metadata information
Returns Dictionary updated data_info that includes the number of sites, dataset, and datafilter name
alignments.ReadCodonDataSetFromPath#
Reads dataset from a file path
Parameters
dataset_name
String name of variable you would like to set the dataset topath
String path to alignment file
Returns Dictionary r - metadata pertaining to the dataset
alignments.ReadNucleotideAlignment#
Creates nucleotide dataset filter from file
Parameters
file_name
String The location of the alignment filedatafilter_name
String the name of the dataset filter you wish to usedataset_name
String the name of the dataset you wish to use
Returns Dictionary updated data_info that includes the number of sites, dataset, and datafilter name
alignments.CompressDuplicateSequences#
Take an input filter, replace all identical sequences with a single copy Optionally, rename the sequences to indicate copy # by adding ':copies'
Parameters
filter_in
String The name of an existing filterfilter_out
String the name (to be created) of the filter where the compressed sequences will go)rename
Bool if true, rename the sequences
Returns any the number of unique sequences
alignments.DefineFiltersForPartitions#
Defines filters for multiple partitions
Parameters
partitions
Matrix a row vector of dictionaries with partition information containing "name" and "filter-string" attributessource_data
DataSet the existing dataset to partition
Returns Matrix filters - a list of newly created dataset filters
alignments.serialize_site_filter#
Parameters
data_filter
DataFiltersite_index
Number
Returns String a string representation of data_filter
alignments.ReadCodonDataSet#
Get metadata from existing dataset
Parameters
dataset_name
id of dataset
Returns Dictionary r - metadata pertaining to the dataset
alignments.ReadCodonDataSetFromPathGivenCode#
Reads a codon dataset from a file path given a genetic code
Parameters
dataset_name
String name of variable you would like to set the dataset topath
String path to alignment filecode
Matrix genetic codestop_codons
String the list of stopcodons
Returns Dictionary r - metadata pertaining to the dataset
#
Parameters
sequence
String the string to translateoffset
Number start at this position (should be in {0,1,2})code
Dictionary genetic code description (e.g. returned by alignments.LoadGeneticCode)
Returns String the amino-acid translation ('?' is used to represent ambiguities; 'X' - stop codons)
#
Parameters
sequence
String the string to translateoffset
Number start at this position (should be in {0,1,2})code
Dictionary genetic code description (e.g. returned by alignments.LoadGeneticCode)code
lookup resolution lookup dictionary
Returns Dict list of possible amino-acids (as dicts) at this position
#
Parameters
sequence
String the string to translatecode
Dictionary genetic code description (e.g. returned by alignments.LoadGeneticCode)code
lookup resolution lookup dictionary
Returns Dict for each reading frame F in {0, 1, 2} returnsF -> { terms.data.sequence: translated sequence (always choose X if available, otherwise first sense resolution) terms.sense_codons : N, // number of sense A/A terms.stop_codons : N, // number of stop codons terms.terminal_stop : T/F // true if there is a terminal stop codon }
#
Parameters
sequence
String the string to translate
Returns String the amino-acid translation ('?' is used to represent ambiguities; 'X' - stop codons)
alignments.Extract_site_patterns#
Parameters
data_filter
DataFilter
Returns any for a data filter, returns a dictionary like this "pattern id": "sites" : sites (0-based) mapping to this pattern "is_constant" : T/F (is the site constant w/matching ambigs) "0":{ "sites":{ "0":0 }, "is_constant":0 },
"1":{
"sites":{
"0":1
},
"is_constant":1
},...
"34":{
"sites":{
"0":34,
"1":113
},
"is_constant":1
},
...
#
Parameters
sequence
String the input sequence
Returns String the sequence with all gaps removed
#
Parameters
sequence
String the input sequence
Returns String the sequence with all gaps removed
#
Parameters
codon_sequence
String the codon sequence to mapaa_sequence
String the matching aligned a.a. sequenceno
Number more than this many mismatches - the codon sequence to mapmapping
Dict code ["terms.code.mapping"]
Examples
GCAAAATCATTAGGGACTATGGAAAACAGA
-AKSLGTMEN-R
maps to
---GCAAAATCATTAGGGACTATGGAAAAC---AGA
Returns String the mapped sequence
#
Parameters
filter
String filter namebreakPoints
Matrix locations of breakpoints (Nx1)trees
Matrix tree strings for partitions (Nx1)file
String write the result hereisCodon
Bool is the filter a codon filter?
Examples
GCAAAATCATTAGGGACTATGGAAAACAGA
-AKSLGTMEN-R
maps to
---GCAAAATCATTAGGGACTATGGAAAAC---AGA
Returns String the mapped sequence
#
ancestral.Sequences#
Parameters
ancestral_data
Dictionary the dictionary returned by ancestral.build
Returns any { "Node Name" : {String} inferred ancestral sequence, }
ancestral.ComputeSubstitutionCounts#
Parameters
ancestral_data
Dictionary the dictionary returned by ancestral.buildbranch_filter
Dictionary/Function/None now to determine the subset of branches to count on None -- all branches Dictionary -- all branches that appear as keys in this dict Function -- all branches on which the function (called with branch name) returns 1substitution_filter
Function/None how to decide if the substitution should count None -- different characters (except anything vs a gap) yields a 1 Function -- callback (state1, state2, ancestral_data) will return the valuesite_filter
Function/None how to decide which sites will be kept None -- at least one substitution Function -- callback (substitution vector) will T/F
Returns any { "Branches" : {Matrix Nx1} names of selected branches, "Sites" : {Matrix Sx1} indices of sites passing filter, "Counts" : {Matrix NxS} of substitution counts, }N = number of selected branches S = number of sites passing filter
ancestral#
ancestral.build#
Builds ancestral states
Parameters
Returns any an integer index to reference the opaque structure for subsequent operations
distances.nucleotide.tn93#
Compute all pairwise distances between sequences in a data set
Parameters
filter
{String} - id of datasetfreqs
{Matrix/null} - if not null, use these nucleotide frequenciesoptions
{Dict/null} - options for ambiguity treatment
Returns Matrix r - pairwise TN93 distances
distances.nucleotide.p_distance#
Compute all pairwise percent distances between sequences in a data set
Parameters
filter
{String} - id of datasetoptions
{Dict/null} - options for ambiguity treatment
Returns Matrix r - pairwise TN93 distances
estimators.FitCodonModel#
Parameters
codon_data
DataFiltertree
Treegenetic_code
Stringoption
Dictionaryinitial_values
Dictionary
Returns any MGREV results
estimators.FitMGREV#
Parameters
codon_data
DataFiltertree
Treegenetic_code
Stringoption
Dictionaryinitial_values
Dictionary
Returns any MGREV results
estimators.FitMGREV#
compute the asymptotic (chi^2) p-value for the LRT
Parameters
alternative
Number log likelihood for the alternative (more general model)Null
Number log likelihood for the nulldf
Number degrees of freedom
Returns any p-value
estimators.ComputeLF#
compute the current value of the log likelihood function
Parameters
lfid
String name of the function
Returns any log likelihood
estimators.CreateInitialGrid#
prepare a Dict object suitable for seeding initial LF values
Parameters
values
Dict : "parameter_id" -> {{initial values}} [row matrix], e.g. ... "busted.test.bsrel_mixture_aux_0": { {0.1, 0.25, 0.4, 0.55, 0.7, 0.85, 0.9} }, "busted.test.bsrel_mixture_aux_1": { {0.1, 0.25, 0.4, 0.55, 0.7, 0.85, 0.9} } ...N
int how many points to sampleinit
Dict/null if not null, taken to be the initial template for variables i.e. random draws will be one index change from this vector
Returns Dict like in{ "0":{ "busted.test.bsrel_mixture_aux_0":{ "ID":"busted.test.bsrel_mixture_aux_0", "MLE":0.4 }, "busted.test.bsrel_mixture_aux_1":{ "ID":"busted.test.bsrel_mixture_aux_1", "MLE":0.7 }, "busted.test.omega1":{ "ID":"busted.test.omega1", "MLE":0.01 }, "busted.test.omega2":{ "ID":"busted.test.omega2", "MLE":0.1 }, "busted.test.omega3":{ "ID":"busted.test.omega3", "MLE":1.5 } } ....
estimators.LHC#
prepare a Dict object suitable for seeding initial LF values based on Latin Hypercube Sampling
Parameters
ranges
Dict : "parameter_id" -> range, i.e. { lower_bound: 0, upper_bound: 1 }.samples
Number : the # of samples to draw
estimators.SetGlobals#
Parameters
Returns any nothing
estimators.SetCategory#
Parameters
Returns any nothing
estimators.ExtractBranchInformation.copy_local#
Parameters
estimators.ExtractBranchInformation#
Parameters
Returns Dictionary branch information
estimators.branch_lengths_in_string#
Parameters
Returns String branch lenghts in tree string
estimators.ExtractMLEs#
Parameters
Returns any results
estimators.ExtractMLEsOptions#
Parameters
Returns any results
estimators.TraverseLocalParameters#
Parameters
likelihood_function_id
Stringmodel_descriptions
Dictionarycallback
String (tree, node, parameter_list)
#
Parameters
tree_name
Stringmodel_descriptions
Dictionaryinitial_values
Matrixbranch_length_conditions
Returns any number of constrained parameters;
#
Parameters
likelihood_function_id
Stringmodel_descriptions
Dictionaryinitial_values
Matrixbranch_length_conditions
Returns any estimators.ApplyExistingEstimates.df_correction - Abs(estimators.ApplyExistingEstimates.keep_track_of_proportional_scalers);
estimators.GetGlobalMLE#
Parameters
results
Dictionarytag
String
Returns any None
estimators.FitExistingLF#
Fits a LikelihoodFunction
Parameters
model_map
Returns any LF results
estimators.FitLF#
Makes a likelihood function object with the desired parameters
Parameters
data_filters_list
Matrix a vector of {DataFilter}stree_list
Matrix a vector of {Tree}smodel_map
initial_values
Returns any LF results
estimators.FitLF#
Fits a LikelihoodFunction
Parameters
data_filters_list
Matrix a vector of {DataFilter}stree_list
Matrix a vector of {Tree}smodel_map
initial_values
Returns any LF results
estimators.GetBranchEstimates#
Parameters
Returns any None
estimators.TakeLFStateSnapshot#
Parameters
lf_id
String
Returns Dict parameter -> {"MLE" : value, "constraint" : string (if present)}
estimators.GetGlobalMLE_RegExp#
Extract global scope parameter estimates that match a regular expression
Parameters
results
Dictionaryregular
String expression to match
Returns Dict parameter description : value (could be empty)
estimators.FitSingleModel_Ext#
Parameters
data_filter
DataFiltertree
Treemodel
Dictinitial_values
Matrixrun_options
Dict
Returns any results
estimators.FitGTR_Ext#
Parameters
data_filter
DataFiltertree
Treeinitial_values
Matrixrun_options
Dict
Returns any results
estimators.FitGTR#
Parameters
data_filter
DataFiltertree
Treeinitial_values
Matrix
Returns any results
genetic_code.DefineCodonToAAMapping#
genetic_code.DefineCodonToAAMapping
Parameters
code
AssociativeList the nucleotide to codon mapping
Returns any returns ordered codon to amino acid map
genetic_code.DefineCodonToAAMapping#
genetic_code.DefineIntegerToAAMapping
Parameters
code
AssociativeList the nucleotide to codon mappingonly_sense
Boolean if true, do not include stop codons in mapping
Returns any returns an integer to AA map { "0" : "K" .. "60" : "F" }
genetic_code.IsStop#
genetic_code.IsStop
Parameters
Returns any whether or not the codon is a stop codon
#
genetic_code.DefineCodonToAAGivenCode#
genetic_code.DefineCodonToAAGivenCode
Parameters
code
AssociativeList the nucleotide to codon mapping
Returns any the amino acid map
genetic_code#
#
trees.infer.NJ#
Infer a neighbor joining tree from a data filter using a specific distance
Parameters
datafilter
String the ID of an existing datafilternull
null/String/Matrix , null : use the default distance calculation appropriate for the datatype String : a callback which takes (filter_id, seq1, seq2) arguments and returns d(seq1,seq2) Matrix : a precomputed distance matrix (same order of rows/column as datafilter names)
Returns String inferred tree string
trees.GetTreeString#
Looks for a newick tree in an alignment file
Parameters
look_for_newick_tree
(String | Bool) If a string, sanitizes and returns the string. If TRUE, search the alignment file for a newick tree. If FALSE, the user will be prompted for a nwk tree file.
Returns String a newick tree string
trees._matrix2string#
Convert a matrix representation of a tree into Newick
Parameters
matrix_form
Matrix : Kx3 matrix; each row represents ?N
Number : number of leavesnames
Matrix/Dict : leaf index -> namedo_lengths
Bool : include branch lengths in the output
Returns String newick tree string
trees.PartitionTree#
Partitions a tree by assigning nodes to either being internal or leaf
Parameters
avl
Dictionary an AVL representation of the tree to be partitioned
Returns any nothing
trees.LoadAnnotatedTopology#
Loads an annatotaed tree topology from a newick tree
Parameters
look_for_newick_tree
(String | Bool) If a string, sanitizes and returns the string. If TRUE, search the alignment file for a newick tree. If FALSE, the user will be prompted for a nwk tree file.
Returns Dictionary an annotated tree
trees.LoadAnnotatedTopologyAndMap#
Parameters
dataset_name
Returns Dictionary an annotated tree
trees.LoadAnnotatedTreeTopology.match_partitions#
Loads a tree topology with node name label mappings and annotations from a list of partitions
Parameters
partitions
Matrix a 1xN vector of partition names, typically retrieved from thepartitions
key in the dictionary returned from an alignments parser function.mapping
Dictionary a mapping of node names to labels
Examples
hky85_nucdata_info = alignments.ReadNucleotideAlignment(file_name, "hky85.nuc_data", "hky85.nuc_filter");
name_mapping = {
"HUMAN":"HUMAN",
"CHIMP":"CHIMP",
"BABOON":"BABOON",
"RHMONKEY":"RHMONKEY",
"COW":"COW",
"PIG":"PIG",
"HORSE":"HORSE",
"CAT":"CAT",
"MOUSE":"MOUSE",
"RAT":"RAT"
};
trees.LoadAnnotatedTreeTopology.match_partitions(hky85_nucdata_info[terms.json.partitions], name_mapping);
=>
{
"0":{
"name":"default",
"filter-string":"",
"tree": * }
}
Returns Dictionary of matched partitions
trees.branch_names#
Parameters
tree
respect_case
Returns any result
trees.RootTree#
Parameters
tree_info
Dictroot
String on this node (or prompt if empty)
Returns any a {Dictionary} (same as ExtractTreeInfo) for the rerooted tree
trees.ExtractTreeInfo#
Parameters
tree_string
String
Returns any a {Dictionary} of the following tree information :- newick string - newick string with branch lengths - annotated string - model map - internal leaves - list of models
trees.HasBranchLengths#
Parameters
tree
Dictionary information object (e.g. as returned by LoadAnnotatedTopology)
Returns any a {Boolean} to indicate whether the tree has a valid branch length array
trees.BootstrapSupport#
Parameters
tree
Dictionary information object (e.g. as returned by LoadAnnotatedTopology)
Returns any a {Dictionary} (could be empty or partially filled) with "node name" -> bootstrap support
trees.GetBranchCount#
Gets total branch count of supplied tree
Parameters
tree_string
String
Returns Number total branch count
trees.SortedBranchLengths#
Sorts branch lengths in a descending order
Parameters
tree_string
String
Returns Number total branch count
trees.BranchNames#
Return branch names
Parameters
tree_string
String
Returns Matrix 1xN sorted branch names
trees.ParsimonyLabel#
Compute branch labeling using parsimony
Parameters
tree
String IDleaf
Dict -> label labels may be missing for some of the leaves to induce partial labeling of the tree
Returns Dict {"score" : value, "labels" : Internal Branch -> label}
trees.ParsimonyLabel#
Annotate a tree string with using user-specified labels
Parameters
tree
String IDnode_name
Dict/String -> label OR (if string) (node_name) => name + annotationa
String pair of characters to enclose the label innode_name
Dict/String -> length OR (if string) (node_name) => length annotation
Returns String annotated string
trees.ConjunctionLabel#
Compute branch labeling using conjunction, i.e. node N is labeled 'X' iff all of the nodes that are in the subtree rooted at 'N' are also labeled 'N'
Parameters
tree
String IDleaf
Dict -> label labels may be missing for some of the leaves to induce partial labeling of the tree
Returns Dict {"labeled" : # of labeled internal nodes, "labels" : Internal Branch -> label}
trees.GenerateSymmetricTree#
Generate a symmetric binary tree on N leaves (only perfectly symmetric if N is a power of 2)
Parameters
N
Number : number of leaversrooted
Bool : whether the tree is rootedbranch_name
None/String : if a string, then it is assumed to be a function with an integer argument (node index) that generates branch names default is to use numeric namesbranch_length
None/String : if a string, then it is assumed to be a function with no arguments that generates branch lengths
Returns String Newick tree string
trees.GenerateSymmetricTree#
Generate a ladder tree on N leaves
Parameters
N
Number : number of leaversrooted
Bool : whether the tree is rootedbranch_name
None/String : if a string, then it is assumed to be a function with an integer argument (node index) that generates branch names default is to use numeric namesbranch_length
None/String : if a string, then it is assumed to be a function with no arguments that generates branch lengths
Returns String Newick tree string
trees#
trees.GenerateRandomTree#
Generate a RANDOM tree on N leaves
Parameters
N
Number : number of leaversrooted
Bool : whether the tree is rootedbranch_name
None/String : if a string, then it is assumed to be a function with an integer argument (node index) that generates branch names default is to use numeric namesbranch_length
None/String : if a string, then it is assumed to be a function with no arguments that generates branch lengths
Returns String Newick tree string