clustering

package
v0.0.0-...-8d061e5 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ADPoissonTreeLoglike

func ADPoissonTreeLoglike(nodels []*gophy.Node, lam float64) float64

ADPoissonTreeLoglike calculates the ancestor - descendent

for a set of stratigraphic ranges

func AncTritomyML

func AncTritomyML(tree *gophy.Node, sites []int)

AncTritomyML will calculate the MLEs for the branch lengths of a tifurcating 3-taxon tree assuming that direct ancestors may be in the tree

func AssertUnrootedTree

func AssertUnrootedTree(tree *gophy.Node)

AssertUnrootedTree is a quick check to make sure the tree passed is unrooted

func BMCalcLensBackFront

func BMCalcLensBackFront(t *gophy.Tree, sites []int)

BMCalcLensBackFront will do one pass of the EM branch length estimation

func BMOptimBLEM

func BMOptimBLEM(t *gophy.Tree, niter int)

BMOptimBLEM will calculate the BM branch lengths using an iterative EM calculation that imputes missing data using PICs

func BMPruneRooted

func BMPruneRooted(n *gophy.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

func BMPruneRootedSingle(n *gophy.Node, i int)

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 CalcExpectedTraits

func CalcExpectedTraits(tree *gophy.Node)

CalcExpectedTraits will plug in the expected values for missing traits under BM using the pruning/PIC ancestral state estimation approach

func CalcRootedLogLike

func CalcRootedLogLike(n *gophy.Node, nlikes *float64, startFresh bool)

CalcRootedLogLike will return the BM likelihood of a tree assuming that no data are missing from the tips.

func CalcSiteMeans

func CalcSiteMeans(nodes []*gophy.Node) (siteSum []float64)

CalcSiteMeans will calculate the mean value for all the sites in the matrix for which the site is not missing

func CalcUnrootedLogLike

func CalcUnrootedLogLike(tree *gophy.Node, startFresh bool) (chll float64)

CalcUnrootedLogLike will calculate the log-likelihood of an unrooted tree, while assuming that no sites have missing data.

func ClusterCalcExpectedTraits

func ClusterCalcExpectedTraits(tree *gophy.Node, sites []int)

ClusterCalcExpectedTraits will plug in the expected values for missing traits under BM using the pruning/PIC ancestral state estimation approach

func ClusterMissingTraitsEM

func ClusterMissingTraitsEM(t *gophy.Tree, cluster *Cluster, niter int)

ClusterMissingTraitsEM will calculate the BM branch lengths using an iterative EM calculation that imputes missing data using PICs using the traits in a single cluster

func GreedyIterateLengthsMissing

func GreedyIterateLengthsMissing(t *gophy.Tree, sites []int, niter int)

GreedyIterateLengthsMissing will calculate the BM branch lengths using an iterative EM calculation that imputes missing data using PICs using the traits in a single cluster

func InitMissingValues

func InitMissingValues(tree []*gophy.Node)

InitMissingValues will find the missing sites in a data matrix and plug in values corresponding to the mean of the remaining sites

func IterateLengthsWeighted

func IterateLengthsWeighted(tree *gophy.Tree, cluster *Cluster, niter int)

IterateLengthsWeighted will iteratively calculate the ML branch lengths for a particular topology and cluster when doing the greedy site clustering procedure.

func MakeMissingMeansTip

func MakeMissingMeansTip(n *gophy.Node, means []float64)

MakeMissingMeansTip will replace missing values with the mean across all tips for a single tip

func MakeStratHeights

func MakeStratHeights(tree *gophy.Tree)

MakeStratHeights assigns the strat heights

func MaxClustLab

func MaxClustLab(l map[int]*Cluster) (biggest int)

MaxClustLab returns the maximum value in a map of ints used like a set

func OldestChildAge

func OldestChildAge(node *gophy.Node) float64

OldestChildAge returns the oldest Child

func OptimizePreservationLam

func OptimizePreservationLam(tree *gophy.Tree) (float64, float64)

OptimizePreservationLam will optimize the poisson rate parameter in the preservation model

func PBMLogLikeRt

func PBMLogLikeRt(tree *gophy.Node, startFresh bool, workers int) (sitelikes float64)

PBMLogLikeRt will calculate the BM log like on a rooted tree

func PoissonTreeLoglike

func PoissonTreeLoglike(tree *gophy.Tree) float64

PoissonTreeLoglike calculates the Poisson LogLike based on

stratigraphic ranges

func ReadMCLoutput

func ReadMCLoutput(clfl string) (clusters map[int]*Cluster)

func ReadStrat

func ReadStrat(stratfl string, t *gophy.Tree)

ReadStrat reads stratigraphic ranges from a file and assigns those

data to a tree

func SingleSiteLL

func SingleSiteLL(tree *gophy.Node, site int) (sitelike float64)

SingleSiteLL will return the likelihood of a single site

func SubUnrootedLogLikeParallel

func SubUnrootedLogLikeParallel(tree *gophy.Node, sites []int, workers int) (sitelikes float64)

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 TimeTraverse

func TimeTraverse(preNodes []*gophy.Node, internalOnly bool) (ret []*gophy.Node)

TimeTraverse will visit all descendant nodes in order of their heights (earliest -> latest)

func TritomySubML

func TritomySubML(tree *gophy.Node, sites []int)

TritomySubML will calculate the MLEs for the branch lengths of a tifurcating 3-taxon tree using only the sites indicated in sites

func TritomyWeightedML

func TritomyWeightedML(tree *gophy.Node, weights map[int]float64)

TritomyWeightedML will calculate the MLEs for the branch lengths of a tifurcating 3-taxon tree

func WeightedUnrootedLogLikeParallel

func WeightedUnrootedLogLikeParallel(tree *gophy.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 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.
}

Cluster structure for sealiontomo stuff

func (*Cluster) CalcLL

func (c *Cluster) CalcLL(tree *gophy.Node)

CalcLL calculate the ll

func (*Cluster) WriteClusterPhylip

func (c *Cluster) WriteClusterPhylip(nodes []*gophy.Node) string

WriteClusterPhylip write the cluster file

type HCSearch

type HCSearch struct {
	Tree            *gophy.Tree
	PreorderNodes   []*gophy.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 InitEMSearch

func InitEMSearch(tree *gophy.Tree, gen int, k int, pr int, alpha float64) *HCSearch

func InitGreedyHC

func InitGreedyHC(tree *gophy.Tree, gen int, pr int, crit int, rstart bool, k int, runName string, splitgen int, alpha float64, minK int) *HCSearch

func TransferGreedyHC

func TransferGreedyHC(tree *gophy.Tree, gen int, pr int, crit int, clus map[int]*Cluster, siteAssign map[int]int, runName string, splitgen int, alpha float64) *HCSearch

func (*HCSearch) CalcRelLikes

func (s *HCSearch) CalcRelLikes() (denom float64)

func (*HCSearch) CheckCluster

func (s *HCSearch) CheckCluster(checkConfig *SiteConfiguration) (keep bool)

func (*HCSearch) ClusterString

func (s *HCSearch) ClusterString() string

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()

func (*HCSearch) RunSingleHC

func (s *HCSearch) RunSingleHC()

func (*HCSearch) SplitEM

func (s *HCSearch) SplitEM()

func (*HCSearch) WriteBestClusters

func (s *HCSearch) WriteBestClusters()

func (*HCSearch) WriteClusterTrees

func (s *HCSearch) WriteClusterTrees()

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)

Jump to

Keyboard shortcuts

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