cmodel

package
v0.0.0-...-eeaf01f Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: GPL-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Package cmodel provides codon evolution models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggMode

type AggMode int

AggMode is a type specifying aggregation mode.

const (
	// No aggregation.
	AggNone AggMode = iota
	// Aggregation on all the positions. All non-observed states
	// are aggregated.
	AggObserved
	// Aggregation on absolutely conserved positions. All
	// non-observed states are aggregated.
	AggFixed
	// Aggregation on all the positions. All non-observed states
	// are aggregated. More general implementation.
	AggObservedNew
	// Aggregation on all the positions. Similar to observed, but
	// a set of non-aggregated states is shuffled between the
	// alignment positions.
	AggRandom
)

Aggregation modes.

type BaseModel

type BaseModel struct {
	// contains filtered or unexported fields
}

BaseModel stores tree and alignment. Matrices and site classes are stored and cached as well.

func NewBaseModel

func NewBaseModel(data *Data, model Model) (bm *BaseModel)

NewBaseModel creates a new base Model.

func (*BaseModel) Copy

func (m *BaseModel) Copy() (newM *BaseModel)

Copy creates a copy of BaseModel.

func (*BaseModel) ExpBranch

func (m *BaseModel) ExpBranch(br int)

ExpBranch exponentiates a signle branch. This uses eigen decomposed matrices.

func (*BaseModel) ExpBranches

func (m *BaseModel) ExpBranches()

ExpBranches sxponentiates all branches in the tree.

func (*BaseModel) Final

func (m *BaseModel) Final(neb, beb, codonRates, siteRates, codonOmega bool)

Final performs analysis after optimization is complete. This implementation does nothing. This method should be implemented.

func (*BaseModel) GetFloatParameters

func (m *BaseModel) GetFloatParameters() optimize.FloatParameters

GetFloatParameters returns all the optimization parameters.

func (*BaseModel) GetOptimizeBranchLengths

func (m *BaseModel) GetOptimizeBranchLengths() bool

GetOptimizeBranchLengths returns true if branch-length optimization is enabled.

func (*BaseModel) GetTreeString

func (m *BaseModel) GetTreeString() string

GetTreeString returns tree in a newick format.

func (*BaseModel) Likelihood

func (m *BaseModel) Likelihood() (lnL float64)

Likelihood calculates tree likelihood.

func (*BaseModel) NEBPosterior

func (m *BaseModel) NEBPosterior(classes []float64) (res []float64)

NEBPosterior returns array (slice) of posterior probabilities for a given classes.

func (*BaseModel) PrintPosterior

func (m *BaseModel) PrintPosterior(posterior []float64)

PrintPosterior prints results of posterior analysis.

func (*BaseModel) ReorderAlignment

func (m *BaseModel) ReorderAlignment()

ReorderAlignment reorders codon alignment so order of nodes and sequences are the same. This allows faster access to sequences by their index in the array.

func (*BaseModel) SetAdaptive

func (m *BaseModel) SetAdaptive(as *optimize.AdaptiveSettings)

SetAdaptive enables adaptive mode (for adaptive MCMC).

func (*BaseModel) SetAggregationMode

func (m *BaseModel) SetAggregationMode(mode AggMode)

SetAggregationMode changes the aggregation mode.

func (*BaseModel) SetMaxBranchLength

func (m *BaseModel) SetMaxBranchLength(maxBrLen float64)

SetMaxBranchLength changes the maximum branch length for the optimization.

func (*BaseModel) SetOptimizeBranchLengths

func (m *BaseModel) SetOptimizeBranchLengths()

SetOptimizeBranchLengths enables branch-length optimization.

func (*BaseModel) Summary

func (m *BaseModel) Summary() interface{}

Summary returns the run summary.

type BranchSite

type BranchSite struct {
	*BaseModel
	// contains filtered or unexported fields
}

BranchSite is an implementation of the branch-site model.

func NewBranchSite

func NewBranchSite(data *Data, fixw2 bool) (m *BranchSite)

NewBranchSite creates a new BranchSite model.

func (*BranchSite) BEBPosterior

func (m *BranchSite) BEBPosterior() (res []float64)

BEBPosterior returns BEB posterior values.

func (*BranchSite) Copy

func (m *BranchSite) Copy() optimize.Optimizable

Copy makes a copy of the model preserving the model parameter values.

func (*BranchSite) Final

func (m *BranchSite) Final(neb, beb, codonRates, siteRates, codonOmega bool)

Final prints NEB results (only if with positive selection).

func (*BranchSite) GetNClass

func (m *BranchSite) GetNClass() int

GetNClass returns number of site classes.

func (*BranchSite) GetParameters

func (m *BranchSite) GetParameters() (kappa float64, omega0, omega2 float64, p0, p1 float64)

GetParameters returns the model parameter values.

func (*BranchSite) SetDefaults

func (m *BranchSite) SetDefaults()

SetDefaults sets the default initial parameter values.

func (*BranchSite) SetParameters

func (m *BranchSite) SetParameters(kappa float64, omega0, omega2 float64, p0, p1 float64)

SetParameters sets the model parameter values.

func (*BranchSite) Summary

func (m *BranchSite) Summary() interface{}

Summary returns the run summary (site posterior for NEB and BEB).

type BranchSiteGamma

type BranchSiteGamma struct {
	*BaseModel
	// contains filtered or unexported fields
}

BranchSiteGamma is an implementation of the branch-site model with gamma rates variation.

func NewBranchSiteGamma

func NewBranchSiteGamma(data *Data, fixw2 bool, ncatsg, ncatcg int, proportional bool) (m *BranchSiteGamma)

NewBranchSiteGamma creates a new BranchSiteGamma model.

func (*BranchSiteGamma) BEBPosterior

func (m *BranchSiteGamma) BEBPosterior() (res []float64)

BEBPosterior returns BEB posterior values.

func (*BranchSiteGamma) Copy

Copy makes a copy of the model preserving the model parameter values.

func (*BranchSiteGamma) Final

func (m *BranchSiteGamma) Final(neb, beb, codonRates, siteRates, codonOmega bool)

Final prints NEB results (only if with positive selection).

func (*BranchSiteGamma) GetNClass

func (m *BranchSiteGamma) GetNClass() int

GetNClass returns number of site classes.

func (*BranchSiteGamma) GetParameters

func (m *BranchSiteGamma) GetParameters() (kappa float64, omega0, omega2 float64, p0, p1 float64, alphas, alphac float64,
	rs1s, rs2s, ps1s, ps2s float64, rs1c, rs2c, ps1c, ps2c float64)

GetParameters returns the model parameter values.

func (*BranchSiteGamma) SetDefaults

func (m *BranchSiteGamma) SetDefaults()

SetDefaults sets the default initial parameter values.

func (*BranchSiteGamma) SetParameters

func (m *BranchSiteGamma) SetParameters(kappa float64, omega0, omega2 float64, p0, p1 float64, alphas, alphac float64,
	rs1s, rs2s, ps1s, ps2s float64, rs1c, rs2c, ps1c, ps2c float64)

SetParameters sets the model parameter values.

func (*BranchSiteGamma) Summary

func (m *BranchSiteGamma) Summary() interface{}

Summary returns the run summary (site posterior for NEB and BEB).

type Data

type Data struct {

	// tree is the tree
	Tree *tree.Tree
	// contains filtered or unexported fields
}

Data stores data for the codon model

func GetTreeAlignment

func GetTreeAlignment(dataset string, cfreq string) (*Data, error)

GetTreeAlignment returns a tree and alignment for testing purposes.

func NewData

func NewData(gCodeID int, alignmentFileName string, treeFileName string,
	cFreq string) (*Data, error)

NewData creates a new Data.

func (*Data) Copy

func (data *Data) Copy() *Data

Copy creates a copy (only new tree is created).

func (*Data) GetNClass1

func (data *Data) GetNClass1() (res int)

GetNClass1 returns number of nodes with class=1.

func (*Data) Root

func (data *Data) Root() error

Root roots the tree back in case it was unrooted.

func (*Data) SetCodonFreqFromFile

func (data *Data) SetCodonFreqFromFile(filename string) error

SetCodonFreqFromFile sets codon frequency from file.

func (*Data) SetForegroundBranch

func (data *Data) SetForegroundBranch(fgBranch int)

SetForegroundBranch sets the foreground branch in a tree.

func (*Data) Unroot

func (data *Data) Unroot() error

Unroot unroots the tree if needed.

type M0

type M0 struct {
	*BaseModel
	// contains filtered or unexported fields
}

M0 is an implementation of M0 model.

func NewM0

func NewM0(data *Data) (m *M0)

NewM0 creates a new M0 model.

func (*M0) Copy

func (m *M0) Copy() optimize.Optimizable

Copy makes a copy of the model preserving the model parameter values.

func (*M0) GetNClass

func (m *M0) GetNClass() int

GetNClass returns number of site classes.

func (*M0) GetParameters

func (m *M0) GetParameters() (kappa, omega float64)

GetParameters returns the model parameter values.

func (*M0) SetDefaults

func (m *M0) SetDefaults()

SetDefaults sets the default initial parameter values.

func (*M0) SetParameters

func (m *M0) SetParameters(kappa, omega float64)

SetParameters sets the model parameter values.

func (*M0) UpdateMatrix

func (m *M0) UpdateMatrix()

UpdateMatrix updates Q-matrix after change in the model parameter values.

type M0G

type M0G struct {
	*BaseModel
	// contains filtered or unexported fields
}

M0G is an implementation of M0G model.

func NewM0G

func NewM0G(data *Data, ncatsg, ncatcg int, proportional bool) (m *M0G)

NewM0G creates a new M0G model.

func (*M0G) Copy

func (m *M0G) Copy() optimize.Optimizable

Copy makes a copy of the model preserving the model parameter values.

func (*M0G) Final

func (m *M0G) Final(neb, beb, codonRates, siteRates, codonOmega bool)

Final prints codon and site rates for proportional mode.

func (*M0G) GetNClass

func (m *M0G) GetNClass() int

GetNClass returns number of site classes.

func (*M0G) GetParameters

func (m *M0G) GetParameters() (kappa, omega, alphas, alphac float64,
	rs1s, rs2s, ps1s, ps2s float64, rs1c, rs2c, ps1c, ps2c float64)

GetParameters returns the model parameter values.

func (*M0G) SetDefaults

func (m *M0G) SetDefaults()

SetDefaults sets the default initial parameter values.

func (*M0G) SetParameters

func (m *M0G) SetParameters(kappa, omega, alphas, alphac float64, rs1s, rs2s, ps1s, ps2s float64, rs1c, rs2c, ps1c, ps2c float64)

SetParameters sets the model parameter values.

type M2

type M2 struct {
	*BaseModel
	// contains filtered or unexported fields
}

M2 is an implementation of M1a & M2a models.

func NewM2

func NewM2(data *Data, addw bool, ncatsg, ncatcg int) (m *M2)

NewM2 creates a new M1a or M2a model. If addw is true, M2a is created, otherwise M1a.

func (*M2) Copy

func (m *M2) Copy() optimize.Optimizable

Copy makes a copy of the model preserving the model parameter values.

func (*M2) Final

func (m *M2) Final(neb, beb, codonRates, siteRates, codonOmega bool)

Final prints NEB results (only if with positive selection).

func (*M2) GetNClass

func (m *M2) GetNClass() int

GetNClass returns number of site classes.

func (*M2) GetParameters

func (m *M2) GetParameters() (p0, p1prop, omega0, omega2, kappa, alphas, alphac float64)

GetParameters returns the model parameter values.

func (*M2) SetDefaults

func (m *M2) SetDefaults()

SetDefaults sets the default initial parameter values.

func (*M2) SetParameters

func (m *M2) SetParameters(p0, p1prop, omega0, omega2, kappa, alphas, alphac float64)

SetParameters sets the model parameter values.

func (*M2) Summary

func (m *M2) Summary() interface{}

Summary returns the run summary (site posterior for NEB).

type M8

type M8 struct {
	*BaseModel
	// contains filtered or unexported fields
}

M8 is an implementation of M8 model.

func NewM8

func NewM8(data *Data, addw, fixw bool, ncatb, ncatsg, ncatcg int, proportional bool) (m *M8)

NewM8 creates a new M8 model.

func (*M8) Copy

func (m *M8) Copy() optimize.Optimizable

Copy makes a copy of the model preserving the model parameter values.

func (*M8) Final

func (m *M8) Final(neb, beb, codonRates, siteRates, codonOmega bool)

Final prints NEB results (only if with positive selection).

func (*M8) GetNClass

func (m *M8) GetNClass() int

GetNClass returns number of site classes.

func (*M8) GetParameters

func (m *M8) GetParameters() (p0, p, q, kappa, omega, alphas, alphac float64,
	rs1s, rs2s, ps1s, ps2s float64, rs1c, rs2c, ps1c, ps2c float64)

GetParameters returns the model parameter values.

func (*M8) SetDefaults

func (m *M8) SetDefaults()

SetDefaults sets the default initial parameter values.

func (*M8) SetParameters

func (m *M8) SetParameters(p0, p, q, kappa, omega, alphas, alphac float64,
	rs1s, rs2s, ps1s, ps2s float64, rs1c, rs2c, ps1c, ps2c float64)

SetParameters sets the model parameter values.

func (*M8) Summary

func (m *M8) Summary() interface{}

Summary returns the run summary (site posterior for NEB and BEB).

type Model

type Model interface {
	// GetNClass returns number of site classes.
	GetNClass() int
	// contains filtered or unexported methods
}

Model is an interface for the model. It provides information about number of classes and allows adding parametes.

type TreeOptimizable

type TreeOptimizable interface {
	optimize.Optimizable
	// SetOptimizeBranchLengths enables branch-length optimization.
	SetOptimizeBranchLengths()
	// GetOptimizeBranchLengths returns true if branch-length
	// optimization is enabled.
	GetOptimizeBranchLengths() bool
	// SetAdaptive enables adaptive MCMC for the TreeOptimizable.
	SetAdaptive(*optimize.AdaptiveSettings)
	// SetMaxBranchLength changes the maximum branch length for
	// the optimization.
	SetMaxBranchLength(float64)
	// SetAggregationMode changes the aggregation mode.
	SetAggregationMode(AggMode)
	// GetTreeString returns tree in a newick format.
	GetTreeString() string
	// Final performs analysis after optimization is complete.
	Final(neb, beb, codonRates, siteRates, codonOmega bool)
	// Summary returns summary of the object for JSON export.
	Summary() interface{}
}

TreeOptimizable is an extension of optimize.Optimizable which includes tree-related methods.

type TreeOptimizableSiteClass

type TreeOptimizableSiteClass interface {
	TreeOptimizable
	// GetNClass returns number of site classes.
	GetNClass() int
}

TreeOptimizableSiteClass is a special case of TreeOptimizable which has site-classes.

Jump to

Keyboard shortcuts

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