Documentation
¶
Index ¶
- func AssertNumChars(chars1, chars2 []float64)
- func AssertNumMis(chars1, chars2 []bool, node *Node)
- func AssertUnrootedTree(tree *Node)
- func BMParallelPruneRooted(n *Node, lab int)
- func BMPruneRooted(n *Node)
- func BMPruneRootedSingle(n *Node, i int)
- func BMPruneRootedSub(n *Node, sites []int)
- func CalcExpectedTraits(tree *Node)
- func CalcExpectedTraitsSub(tree *Node, sites []int)
- func CalcRootedLogLike(n *Node, nlikes *float64, startFresh bool)
- func CalcSiteMeans(nodes []*Node) (siteSum []float64)
- func CalcTreeAIC(tree *Node, crit int) (aic float64)
- func CalcUnrootedLogLike(tree *Node, startFresh bool) (chll float64)
- func ClusterMissingTraitsEM(tree *Node, cluster *Cluster, niter int)
- func ColumnMatrixToSlice(m *mat.Dense) []float64
- func DMtoPhylip(dm map[string][]float64, nodes []*Node) (lines []string)
- func DirichletBranchLengthLogPrior(nodes []*Node, pr *BranchLengthPrior) float64
- func EBExponentialBranchLengthLogPrior(nodels []*Node, means []float64) (prob float64)
- func EBNormalBranchLengthLogPrior(nodels []*Node, means []float64) (prob float64)
- func ExponentialBranchLengthLogPrior(nodels []*Node, beta float64) (prob float64)
- func GIWStartingSampleMean(traits map[string][]float64) (mu0 *mat.Dense)
- func GammaTreeLengthPrior(nodels []*Node, alpha, beta float64) float64
- func GreedyIterateLengthsMissing(tree *Node, sites []int, niter int)
- func InitMissingValues(tree []*Node)
- func InitParallelPRNLEN(nodes []*Node)
- func IterateBMLengths(tree *Node, niter int)
- func IterateLengthsWeighted(tree *Node, cluster *Cluster, niter int)
- func LogGammaFn(x float64) float64
- func MakeMissingDataSlice(t *Node)
- func MakeMissingMeansTip(n *Node, means []float64)
- func MakeRandomStartingBranchLengths(tree *Node)
- func MapContinuous(t *Node, traits map[string][]float64, ntraits int)
- func MarkAll(nodes []*Node)
- func Max(l map[int][]int) (biggest int)
- func MaxClustLab(l map[int]*Cluster) (biggest int)
- func MaxClustLabBig(l map[int]*big.Float) (biggest int)
- func MaxClustLabF64(l map[int]float64) (biggest int)
- func Mean(v []float64) float64
- func MeanInt(v []int) int
- func MissingRootedLogLike(n *Node, startFresh bool) (sitelikes float64)
- func MissingTraitsEM(tree *Node, niter int)
- func MissingUnrootedLogLike(tree *Node, startFresh bool) (sitelikes float64)
- func PhyloVCV(nodes []*Node) *mat.Dense
- func PruneToStar(tree *Node)
- func ReadContinuous(traitfl string) (map[string][]float64, int, int)
- func ReadFossils(path string) (fos []string)
- func ReadLine(path string) (ln []string)
- func ReadMCLoutput(clfl string) (clusters map[int]*Cluster)
- func Rexp(lambda float64) (e float64)
- func SetIdentityMatrix(dim int) *mat.Dense
- func SingleSiteLL(tree *Node, site int) (sitelike float64)
- func SitewiseLogLike(tree *Node) (sitelikes []float64)
- func SubDM(nodes []*Node, clus *Cluster) map[string][]float64
- func SubUnrootedLogLikeParallel(tree *Node, sites []int, workers int) (sitelikes float64)
- func SymDenseConvert(m *mat.Dense) *mat.SymDense
- func TreeLength(nodes []*Node) float64
- func TritomyML(tree *Node)
- func TritomySubML(tree *Node, sites []int)
- func TritomyWeightedML(tree *Node, weights map[int]float64)
- func WeightedUnrootedLogLike(tree *Node, startFresh bool, weights []float64) (sitelikes float64)
- func WeightedUnrootedLogLikeParallel(tree *Node, startFresh bool, weights []float64, workers int) (sitelikes float64)
- type BranchLengthPrior
- type CharAlignment
- type Cluster
- type DPPGibbs
- type DistanceMatrix
- type GIWPost
- type GIWPrior
- type HCSearch
- func (s *HCSearch) CalcRelLikes() (denom float64)
- func (s *HCSearch) CheckCluster(checkConfig *SiteConfiguration) (keep bool)
- func (s *HCSearch) ClusterString() string
- func (s *HCSearch) NewSiteConfig() *SiteConfiguration
- func (s *HCSearch) PerturbedRun()
- func (s *HCSearch) RefineSavedClusterings()
- func (s *HCSearch) RunEM()
- func (s *HCSearch) RunSingleHC()
- func (s *HCSearch) SplitEM()
- func (s *HCSearch) WriteBestClusters()
- func (s *HCSearch) WriteClusterTrees()
- type MVNLike
- type NGPost
- type Node
- func (n *Node) AddChild(c *Node) error
- func (n *Node) MarkAll()
- func (n *Node) NNodes(count *int)
- func (n Node) Newick(bl bool) (ret string)
- func (n *Node) PostorderArray() (ret []*Node)
- func (n *Node) PreorderArray() (ret []*Node)
- func (n *Node) RemoveChild(c *Node)
- func (n *Node) Reroot(oldroot *Node) *Node
- func (n *Node) UnmarkAll()
- func (n *Node) UnmarkToRoot(oldroot *Node)
- type NormalGammaPrior
- type SiteConfiguration
- type UVNDPPGibbs
- type UVNLike
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNumChars ¶
func AssertNumChars(chars1, chars2 []float64)
AssertNumChars will check to make sure that two character vectors are the same lengths (as they always should be)
func AssertNumMis ¶
AssertNumMis will make sure that the boolian slices are the same length
func AssertUnrootedTree ¶
func AssertUnrootedTree(tree *Node)
AssertUnrootedTree is a quick check to make sure the tree passed is unrooted
func BMParallelPruneRooted ¶
BMParallelPruneRooted will prune BM branch lens and PICs down to a rooted node root node should be a real (ie. bifurcating) root added Aug 2018. will need later.
func BMPruneRooted ¶
func BMPruneRooted(n *Node)
BMPruneRooted will prune BM branch lens and PICs down to a rooted node root node should be a real (ie. bifurcating) root
func BMPruneRootedSingle ¶
BMPruneRootedSingle will prune BM branch lens and calculate PIC of a single trait down to a rooted node root node should be a real (ie. bifurcating) root
func BMPruneRootedSub ¶
BMPruneRootedSub will prune BM branch lens and PICs down to a rooted node root node should be a real (ie. bifurcating) root
func CalcExpectedTraits ¶
func CalcExpectedTraits(tree *Node)
CalcExpectedTraits will plug in the expected values for missing traits under BM using the pruning/PIC ancestral state estimation approach
func CalcExpectedTraitsSub ¶
CalcExpectedTraitsSub will plug in the expected values for missing traits under BM using the pruning/PIC ancestral state estimation approach
func CalcRootedLogLike ¶
CalcRootedLogLike will return the BM likelihood of a tree assuming that no data are missing from the tips.
func CalcSiteMeans ¶
CalcSiteMeans will calculate the mean value for all the sites in the matrix for which the site is not missing
func CalcTreeAIC ¶
func CalcUnrootedLogLike ¶
CalcUnrootedLogLike will calculate the log-likelihood of an unrooted tree, while assuming that no sites have missing data.
func ClusterMissingTraitsEM ¶
ClusterMissingTraitsEM will iteratively calculate the ML branch lengths for a particular topology and cluster when doing the greedy site clustering procedure.
func ColumnMatrixToSlice ¶
ColumnMatrixToSlice will convert a Dx1 matrix to a slice
func DirichletBranchLengthLogPrior ¶
func DirichletBranchLengthLogPrior(nodes []*Node, pr *BranchLengthPrior) float64
DirichletBranchLengthLogPrior will return the log prior probability of all branch lengths in a trejke
func EBExponentialBranchLengthLogPrior ¶
EBExponentialBranchLengthLogPrior will give the exponential probability of each branch length when exponential mean == ML branch length
func EBNormalBranchLengthLogPrior ¶
EBNormalBranchLengthLogPrior will calculate the prior probability of a branch length from a normal distribution centered on the ML branch length estimate
func ExponentialBranchLengthLogPrior ¶
ExponentialBranchLengthLogPrior will give the exponential prior probability of observing a particular set of branch lengths on a tree, given shape lambda
func GIWStartingSampleMean ¶
GIWStartingSampleMean will calculate the starting mean value as just the raw sample mean from all traits
func GammaTreeLengthPrior ¶
GammaTreeLengthPrior will calculate the prior probability of the current tree length
func GreedyIterateLengthsMissing ¶
GreedyIterateLengthsMissing will iteratively calculate the ML branch lengths for a particular topology and cluster when doing the greedy site clustering procedure.
func InitMissingValues ¶
func InitMissingValues(tree []*Node)
InitMissingValues will find the missing sites in a data matrix and plug in values corresponding to the mean of the remaining sites
func InitParallelPRNLEN ¶
func InitParallelPRNLEN(nodes []*Node)
InitParallelPRNLEN will set up empty slices for the prnlens
func IterateBMLengths ¶
IterateBMLengths will iteratively calculate the ML branch lengths for a particular topology, assuming that traits are fully sampled at the tips. should use MissingTraitsEM if there are missing sites.
func IterateLengthsWeighted ¶
IterateLengthsWeighted will iteratively calculate the ML branch lengths for a particular topology and cluster when doing the greedy site clustering procedure.
func LogGammaFn ¶
LogGammaFn will return the log of the gamma function of x. X should be provided as a float64, but be a whole number
func MakeMissingDataSlice ¶
func MakeMissingDataSlice(t *Node)
MakeMissingDataSlice will intialize the MIS attribute of node t by identifying traits with LARGE (ie. missing) values and updating MIS accordingly.
func MakeMissingMeansTip ¶
MakeMissingMeansTip will replace missing values with the mean across all tips for a single tip
func MakeRandomStartingBranchLengths ¶
func MakeRandomStartingBranchLengths(tree *Node)
MakeRandomStartingBranchLengths will initialize a tree with a set of random branch lengths
func MapContinuous ¶
MapContinuous maps the traits contained with in a (golang) map to the tips of a tree and initializes slices of the same length for the internal nodes
func MaxClustLab ¶
MaxClustLabF64 returns the maximum value in a map of ints used like a set
func MaxClustLabBig ¶
MaxClustLab returns the maximum value in a map of ints used like a set
func MaxClustLabF64 ¶
MaxClustLabF64 returns the maximum value in a map of ints used like a set
func MissingRootedLogLike ¶
MissingRootedLogLike will return the BM log-likelihood of a tree for a single site, pruning tips that have missing data
func MissingTraitsEM ¶
MissingTraitsEM will iteratively calculate the ML branch lengths for a particular topology
func MissingUnrootedLogLike ¶
MissingUnrootedLogLike will calculate the log-likelihood of an unrooted tree. It is deprecated and is only a convienience for testing LL calculation.
func PhyloVCV ¶
PhyloVCV will return the variance-covariance matrix calculated from a tree with branch lengths
func ReadContinuous ¶
ReadContinuous will read in a PHYLIP-formatted trait file and return a map
func ReadFossils ¶
ReadFossils will read in a list of fossil tips one line at a time into a slice TODO: get this working
func ReadMCLoutput ¶
func SetIdentityMatrix ¶
SetIdentityMatrix will return an identiy matrix with dimensions ntax,ntax
func SingleSiteLL ¶
SingleSiteLL will return the likelihood of a single site
func SitewiseLogLike ¶
SitewiseLogLike will calculate the log-likelihood of an unrooted tree, while assuming that some sites have missing data. This can be used to calculate the likelihoods of trees that have complete trait sampling, but it will be slower than CalcRootedLogLike.
func SubDM ¶
SubDM will return the variance-covariance matrix calculated from a tree with branch lengths
func SubUnrootedLogLikeParallel ¶
SubUnrootedLogLikeParallel will calculate the log-likelihood of an unrooted tree, while assuming that some sites have missing data. This can be used to calculate the likelihoods of trees that have complete trait sampling, but it will be slower than CalcRootedLogLike.
func SymDenseConvert ¶
SymDenseConvert will convert a matrix of type *Dense to *SymDense
func TreeLength ¶
TreeLength will return the total length of a slice of nodes
func TritomyML ¶
func TritomyML(tree *Node)
TritomyML will calculate the MLEs for the branch lengths of a tifurcating 3-taxon tree
func TritomySubML ¶
TritomySubML will calculate the MLEs for the branch lengths of a tifurcating 3-taxon tree using only the sites indicated in sites
func TritomyWeightedML ¶
TritomyWeightedML will calculate the MLEs for the branch lengths of a tifurcating 3-taxon tree
func WeightedUnrootedLogLike ¶
WeightedUnrootedLogLike will calculate the log-likelihood of an unrooted tree, while assuming that some sites have missing data. This can be used to calculate the likelihoods of trees that have complete trait sampling, but it will be slower than CalcRootedLogLike.
func WeightedUnrootedLogLikeParallel ¶
func WeightedUnrootedLogLikeParallel(tree *Node, startFresh bool, weights []float64, workers int) (sitelikes float64)
WeightedUnrootedLogLikeParallel will calculate the log-likelihood of an unrooted tree, while assuming that some sites have missing data. This can be used to calculate the likelihoods of trees that have complete trait sampling, but it will be slower than CalcRootedLogLike.
Types ¶
type BranchLengthPrior ¶
type BranchLengthPrior struct { TYPE string ALPHA float64 BETA float64 NTIPS int SGAMMA float64 SFACT float64 CUR float64 LAST float64 CLUSTCUR map[int]float64 CLUSTLAST map[int]float64 TREELEN float64 GAMMADIST distuv.Gamma }
BranchLengthPrior is a struct for specifying and calculating different priors
func InitializePrior ¶
func InitializePrior(priorType string, nodes []*Node) *BranchLengthPrior
InitializePrior will set up a new instance of a prior
func (*BranchLengthPrior) Calc ¶
func (pr *BranchLengthPrior) Calc(nodes []*Node) float64
Calc will return the log prior probability of the branch length prior
func (*BranchLengthPrior) DrawDirichletBranchLengths ¶
func (pr *BranchLengthPrior) DrawDirichletBranchLengths(nodes []*Node) (lengths []float64)
DrawDirichletBranchLengths will randomly assign branchlengths from the compound dirichlet distribution
type CharAlignment ¶
type CharAlignment struct { MatSites map[int]*mat.Dense // site index is the key, traits for each taxon are the values MatSitesT map[int]mat.Matrix // same as above, but the site trait vectors are transposed MatSitesProd map[int]*mat.Dense // stores A*A^T for each site A SiteOrder []string // stores the order that traits are stored in for the untransposed trait vectors Dim int NSites int }
CharAlignment will store all characters for a collapsed Gibbs clustering analysis, along with their transposed vectors
func InitTraitMatrices ¶
func InitTraitMatrices(traits map[string][]float64) *CharAlignment
InitTraitMatrices will initialize the CharAlignment struct
type Cluster ¶
type Cluster struct { Sites []int // this stores all of the sites with a preference for this cluster BranchLengths []float64 LogLike float64 SiteWeights map[int]float64 // this will store the probability that each site in the MATRIX belongs here. }
func (*Cluster) WriteClusterPhylip ¶
type DPPGibbs ¶
type DPPGibbs struct { Aln *CharAlignment Clusters map[int]*MVNLike SiteAssignments map[int]int Prior *GIWPrior Gen int PrintFreq int WriteFreq int Threads int Workers int Alpha float64 }
DPPGibbs is a struct to store the attributes of a collapsed DPP gibbs sampler for the BM phylo gene expression data
func InitGibbs ¶
func InitGibbs(traits map[string][]float64, prior *GIWPrior, gen, print, write, threads, workers int, alpha float64) *DPPGibbs
InitGibbs will initialize the parameters for the collapsed gibbs sampler.
func (*DPPGibbs) CalcMn ¶
CalcMn will calculate the mean vector of the posterior for a single cluster after a new site has been added
type DistanceMatrix ¶
type DistanceMatrix struct { MatSites map[int][]float64 // pairwise comparison is the key, value is a slice containing the comparison between taxa across all sites //MatSitesT map[int]mat.Matrix // same as above, but the site trait vectors are transposed //MatSitesProd map[int]*mat.Dense // stores A*A^T for each site A PWDistLabs []int // stores the order that traits are stored in for the untransposed trait vectors //Dim int NSites float64 IntNSites int }
DistanceMatrix will store a continuous character matrix converted into a pairwise distance matrix for each site
func DM ¶
func DM(nodes []*Node) *DistanceMatrix
DM will return the variance-covariance matrix calculated from a tree with branch lengths
type GIWPost ¶
type GIWPost struct { MuN *mat.Dense // parameters are same as prior KN float64 S *mat.Dense VN float64 }
GIWPost stores values for the posterior distribution calculated analytically from GIWPrior and the phylo BM likelihood
type GIWPrior ¶
type GIWPrior struct { Mu0 *mat.Dense // prior on multivariate normal mean (ancestral state at root of tree) K0 float64 // belief in Mu0 S0 *mat.Dense // prior on multivariate normal VCV V0 float64 // belief in S0 PostPredProd *mat.Dense // this will store Mu0*Mu0^T*K0 (for use in calculating the posterior parameters) Mu0K0 *mat.Dense PPDensity float64 }
GIWPrior is an object for the Gausian inverse Wishart prior used as conjugate prior for brownain phylogenetic VCV likelihood
type HCSearch ¶
type HCSearch struct { Tree *Node PreorderNodes []*Node Clusters map[int]*Cluster SiteAssignments map[int]int Gen int Threads int Workers int RunName string LogOutFile string K int PrintFreq int CurrentAIC float64 NumTraits float64 Criterion int SavedConfig []*SiteConfiguration CurBestAIC float64 JoinLikes map[int]map[int]float64 SplitGen int Alpha float64 NumPoints float64 ExpandPenalty float64 MinK int }
func InitGreedyHC ¶
func TransferGreedyHC ¶
func (*HCSearch) CalcRelLikes ¶
func (*HCSearch) CheckCluster ¶
func (s *HCSearch) CheckCluster(checkConfig *SiteConfiguration) (keep bool)
func (*HCSearch) ClusterString ¶
ClusterString will return a string of the current set of clusters
func (*HCSearch) NewSiteConfig ¶
func (s *HCSearch) NewSiteConfig() *SiteConfiguration
func (*HCSearch) PerturbedRun ¶
func (s *HCSearch) PerturbedRun()
func (*HCSearch) RefineSavedClusterings ¶
func (s *HCSearch) RefineSavedClusterings()
func (*HCSearch) RunEM ¶
func (s *HCSearch) RunEM()
type HCSearch struct { Tree *Node PreorderNodes []*Node Clusters map[int]*Cluster SiteAssignments map[int]int Gen int Threads int Workers int ClustOutFile string LogOutFile string K int PrintFreq int }
func (*HCSearch) RunSingleHC ¶
func (s *HCSearch) RunSingleHC()
func (*HCSearch) WriteBestClusters ¶
func (s *HCSearch) WriteBestClusters()
func (*HCSearch) WriteClusterTrees ¶
func (s *HCSearch) WriteClusterTrees()
type MVNLike ¶
type MVNLike struct { Sites []int //MeanData *mat.Dense DataSum *mat.Dense ProdSum *mat.Dense // gives the sum of A*A^T across all sites A in the cluster // contains filtered or unexported fields }
MVNLike will store all data and params for each cluster
func (*MVNLike) ClusterSampleMean ¶
func (mvn *MVNLike) ClusterSampleMean(aln *CharAlignment) *mat.Dense
ClusterSampleMean will calculate the sample mean of all the sites in a particular cluster
type NGPost ¶
type NGPost struct { MuN float64 // parameters are same as prior KN float64 AlphaN float64 BetaN float64 }
NGPost stores values for the posterior distribution calculated analytically from GIWPrior and the phylo BM likelihood
type Node ¶
type Node struct { PAR *Node CHLD []*Node NAME string LEN float64 PRNLEN float64 CONTRT []float64 //VISITED bool MRK bool MIS []bool //this is a slice of bools that indicates whether the index is missing from CONTRT LL []float64 CONPRNLEN []float64 CLUSTLEN map[int]float64 PARTPRNLEN map[int]float64 // [][]float64 }
Node is a node struct to represent rooted and unrooted phylogenetic trees
func InternalNodeSlice ¶
InternalNodeSlice will return a slice containing only internal nodes
func (*Node) NNodes ¶
NNodes is a helper method that will return the number of internal nodes descending from n (including n)
func (*Node) PostorderArray ¶
PostorderArray will return an array of all the nodes in the tree in Postorder
func (*Node) PreorderArray ¶
PreorderArray will return a preordered array of all the nodes in a tree
func (*Node) RemoveChild ¶
RemoveChild will remove a chidl from the slice of children associated with a node
func (*Node) UnmarkAll ¶
func (n *Node) UnmarkAll()
UnmarkAll will unmark all of the nodes on a tree
func (*Node) UnmarkToRoot ¶
UnmarkToRoot will mark all of the nodes betwen the current node and the root to be recalculated
type NormalGammaPrior ¶
type NormalGammaPrior struct { Mu0 float64 // hyperparameter for expected mean pairwise distance K0 float64 // hyperparameter on the precision (1/variance) of the prior mean Alpha0 float64 // shape hyperpameter on the variance of the distance estimates Beta0 float64 // scale hyperparemeter on the variance of the distance estimates //PostPredProd float64 // this will store Mu0*Mu0^T*K0 (for use in calculating the posterior parameters) //Mu0K0 *mat.Dense PPDensity *distuv.StudentsT }
NormalGammaPrior is an object for the Gausian inverse Wishart prior used as conjugate prior for brownain phylogenetic VCV likelihood
func InitNGPrior ¶
func InitNGPrior(mu0, k0, alpha0, beta0 float64) *NormalGammaPrior
InitNGPrior will initialize the prior on the matrix and BM mean
type SiteConfiguration ¶
type SiteConfiguration struct { Sites map[int]map[int]bool AIC float64 ClusterTrees map[int]string ClusterSizes map[int]int ClusterString string }
func (*SiteConfiguration) CalcClusterSizes ¶
func (c *SiteConfiguration) CalcClusterSizes()
func (*SiteConfiguration) Equals ¶
func (c *SiteConfiguration) Equals(check *SiteConfiguration) (equal bool)
type UVNDPPGibbs ¶
type UVNDPPGibbs struct { Dist *DistanceMatrix Clusters map[int]*UVNLike SiteAssignments map[int]int Prior *NormalGammaPrior Gen int PrintFreq int WriteFreq int Threads int Workers int Alpha float64 ClustOutFile string LogOutFile string }
UVNDPPGibbs is a struct to store the attributes of a collapsed DPP gibbs sampler for the BM phylo gene expression data
func InitUVNGibbs ¶
func InitUVNGibbs(nodes []*Node, prior *NormalGammaPrior, gen, print, write, threads, workers int, alpha float64, treeOut, logOut string) *UVNDPPGibbs
InitUVNGibbs will initialize the parameters for the collapsed gibbs sampler.
func (*UVNDPPGibbs) ClusterString ¶
func (chain *UVNDPPGibbs) ClusterString() string
ClusterString will return a string of the current set of clusters
Source Files
¶
- assertions.go
- bm_prune.go
- char_alignment.go
- cluster.go
- dist_matrix.go
- expectMaxClust.go
- greedyHC.go
- map_continuous.go
- missing_data.go
- mvnCollapsedGibbs.go
- mvn_likelihood.go
- mvn_priors.go
- node.go
- priors.go
- read_cluster_file.go
- site_configuration.go
- tree_reader.go
- utils.go
- uvnCollapsedGibbs.go
- uvn_likelihood.go
- uvn_priors.go
- vcv.go