multicell

package
v0.0.0-...-f60d257 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: GPL-3.0 Imports: 13 Imported by: 12

Documentation

Index

Constants

View Source
const (
	IAncEnv = iota // Previous env
	INovEnv        // Current env
	NBodies
)
View Source
const (
	CellE = iota
	CellF
	CellG
	CellH
	CellP
)

Variables

View Source
var DensityE float64 = defaultDensity
View Source
var DensityF float64 = defaultDensity
View Source
var DensityG float64 = defaultDensity
View Source
var DensityH float64 = defaultDensity
View Source
var DensityJ float64 = defaultDensity
View Source
var DensityP float64 = defaultDensity

Functions

func AddNoise2CueFlip

func AddNoise2CueFlip(cue_out, cue Cue, eta float64)

func AddNoise2CueNormal

func AddNoise2CueNormal(cue_out, cue Cue, eta float64)

func AddVecs

func AddVecs(vout, v0, v1 Vec)

func CheckCPD

func CheckCPD(ten Tensor3, cpd []ElemsCPD) (float64, float64)

func CopyDmat

func CopyDmat(mat1, mat0 Dmat)

func CrossoverSpmats

func CrossoverSpmats(mat0, mat1 Spmat)

func DOT_Genealogy

func DOT_Genealogy(genfilename, popfilename string, ngen, npop int)

Dumps genealogy of population for an epoch into a dot file, going backwards in time. Returns number of reproducing population

func DeepVec2Test

func DeepVec2Test(v1, v2 [][]float64) float64

func DeepVec3NovTest

func DeepVec3NovTest(v [][]float64, vv [][][]float64) error

func DiffGenomes

func DiffGenomes(Gout, G1, G0 *Genome)

func DiffVecs

func DiffVecs(vout, v0, v1 Vec)

func Dist2Vecs

func Dist2Vecs(v0, v1 Vec) float64

func DistVecs

func DistVecs(v0, v1 Vec) float64

func DistVecs1

func DistVecs1(v0, v1 Vec) float64

func DotSpmats

func DotSpmats(mat0, mat1 Spmat) float64

func DotVecs

func DotVecs(v0, v1 Vec) float64

func GetCrossCov

func GetCrossCov(vecs0, vecs1 []Vec, submean0, submean1 bool) (Vec, Vec, Dmat)

func GetCrossCov3

func GetCrossCov3(vecs0, vecs1, vecs2 []Vec, submean0, submean1, submean2 bool) (Vec, Vec, Vec, Tensor3)

func GetCueVar

func GetCueVar(cues Cues) float64

func GetMaxPop

func GetMaxPop() int

func GetNcells

func GetNcells() int

func GetNenv

func GetNenv() int

func GetNsel

func GetNsel() int

func GetSVD

func GetSVD(ccmat Dmat) (*mat.Dense, []float64, *mat.Dense)

func GetSVD_opt

func GetSVD_opt(ccmat Dmat, flag mat.SVDKind) (*mat.Dense, []float64, *mat.Dense)

expect flag = mat.SVDThin or mat.SVDThinU

func Hammingdist

func Hammingdist(v0, v1 Vec) float64

func Mate

func Mate(dad, mom *Indiv) (Indiv, Indiv)

func MinInt

func MinInt(x, y int) int

func MultMatVec

func MultMatVec(vout Vec, mat Spmat, vin Vec)

func MultMatVec_T

func MultMatVec_T(vout Vec, mat Spmat, vin Vec)

func Norm2

func Norm2(v Vec) float64

func Norm2Sq

func Norm2Sq(v Vec) float64

func NormalizeVec

func NormalizeVec(v Vec)

func ProjectSVD

func ProjectSVD(label string, dirE, dirP *mat.VecDense, data0, data1 Dmat, mean0, mean1 Vec, ccmat Dmat, vals Vec, U, V *mat.Dense)

func RandomInit

func RandomInit(a Dmat, maxcol int)

func ResetDmat

func ResetDmat(mat Dmat)

func ScaleVec

func ScaleVec(vout Vec, s float64, vin Vec)

func SetParams

func SetParams(s Settings)

func SetSeed

func SetSeed(seed int64)

func SetSeedCue

func SetSeedCue(seed int64)

func SumVec

func SumVec(v Vec) float64

func TestEqualGenomes

func TestEqualGenomes(G0, G1 Genome) float64

func TestEqualPopGenomes

func TestEqualPopGenomes(pop0, pop1 Population) float64

func WAddVecs

func WAddVecs(vout Vec, sca float64, v0, v1 Vec)

Types

type Body

type Body struct {
	Genome   Genome
	Cells    []Cell // Array of cells of different types
	PErr     float64
	NDevStep int
}

func NewBody

func NewBody(ncells int) Body

func (*Body) Copy

func (body *Body) Copy() Body

func (*Body) DevBody

func (body *Body) DevBody(envs Cues) Body

type CPDArray

type CPDArray []ElemsCPD

type Cell

type Cell struct {
	Id       int
	E        Vec     // Env + noise
	F        Vec     // Epigenetic markers
	G        Vec     // Gene expression
	H        Vec     // Higher order complexes
	P, Pvar  Vec     // moving average and variance of P (P is already EMA)
	PErr     float64 // ||e - p||_1
	NDevStep int     // Developmental path length

}

func NewCell

func NewCell(id int) Cell

func (*Cell) Copy

func (cell *Cell) Copy() Cell

func (*Cell) DevCell

func (cell *Cell) DevCell(G Genome, env Cue) Cell

func (*Cell) GetState

func (cell *Cell) GetState(ivec string, ibeg, iend int) Vec

type CoreTensor3

type CoreTensor3 []elem_tensor3

func GetFastHOSVD

func GetFastHOSVD(ten Tensor3) (CoreTensor3, *mat.Dense, *mat.Dense, *mat.Dense)

Interlaced Computation; supposed to be significantly faster. Should be len0 <= len1 <= len2

type Cue

type Cue = Vec //Environment cue is a special kind of vector

func ChangeEnv

func ChangeEnv(cue Cue, n int) Cue

Mutate precisely n bits of environment cue; ignore id part

func ChangeEnv2

func ChangeEnv2(cue Cue, n int) Cue

make sure to change env(1:nsel) if n < nsel/2

func RandomEnv

func RandomEnv(density float64) Cue

type Cues

type Cues = []Cue //Cue array object

func ChangeEnvs

func ChangeEnvs(cues Cues, n int) Cues

func CopyCues

func CopyCues(cues Cues) Cues

func GetSelEnvs

func GetSelEnvs(cues Cues) Cues

func NewCues

func NewCues(ncells, nenv int) Cues

func RandomEnvs

func RandomEnvs(ncells int, density float64) Cues

Randomly generate cue array

type Dmat

type Dmat = []Vec

func FlattenTensor3

func FlattenTensor3(ten Tensor3, ind int) Dmat

func KR_Product

func KR_Product(a, b Dmat) Dmat

The Khatri-Rao Product between KxN and KxN matrices

func MultDmats

func MultDmats(mat0, mat1 Dmat) Dmat

func NewDmat

func NewDmat(nrow, ncol int) Dmat

type ElemsCPD

type ElemsCPD struct {
	SVal float64
	Axes []Vec
}

func GetCPDO

func GetCPDO(ten Tensor3, dir1, dir2 Vec, maxiter, rank int) []ElemsCPD

Canonical Polyadic Decomposition X = S*(A1 x A2 x A3) where A3 is orthogonal.

type Genome

type Genome struct {
	E Spmat //Environment cue effect on epigenome
	F Spmat //Regulatory effect of epigenetic markers on gene expression
	G Spmat //Regulatory effect of gene expression on epigenetic markers
	H Spmat //Contribution of gene expression on higher order complexes
	J Spmat //Interaction between higher order complexes
	P Spmat //Resulting expressed phenotype
}

func NewGenome

func NewGenome() Genome

func (*Genome) Clear

func (G *Genome) Clear()

func (*Genome) Copy

func (parent *Genome) Copy() Genome

func (*Genome) FlatVec

func (genome *Genome) FlatVec() Vec

func (*Genome) Mutate

func (genome *Genome) Mutate()

func (*Genome) NormalizeGenome

func (G *Genome) NormalizeGenome() Genome

func (*Genome) Randomize

func (G *Genome) Randomize()

type Indiv

type Indiv struct {
	Id         int
	DadId      int
	MomId      int
	Bodies     []Body  //IAncEnv, INovEnv (see above const.)
	Fit        float64 //Fitness with cues
	WagFit     float64 //Wagner relative fitness
	Plasticity float64 //Observed Plasticity
	Dp1e1      float64 // ||p(e1) - e1||
	Dp0e0      float64 // ||p(e0) - e0||
	Dp1e0      float64 // ||p(e1) - e0||
	Dp0e1      float64 // ||p(e0) - e1||
}

func NewIndiv

func NewIndiv(id int) Indiv

func (*Indiv) Copy

func (indiv *Indiv) Copy() Indiv

func (*Indiv) Develop

func (indiv *Indiv) Develop(ancenvs, novenvs Cues) Indiv

type PopStats

type PopStats struct {
	PEDot      float64 // (delta P, delta E) dot product
	PErr1      float64 // <|| p(e1) - e1 ||> (Nov)
	PErr0      float64 // <|| p(e0) - e0 ||> (Anc)
	PED10      float64 // <|| p(e1) - e0 ||> (Nov-Anc)
	PED01      float64 // <|| p(e0) - e1 ||> (Anc-Nov)
	WagFit     float64
	Fitness    float64
	Plasticity float64
	Div        float64
	NDevStep   float64
}

type Population

type Population struct {
	Params  Settings
	Gen     int
	NovEnvs Cues //Novel Environment
	AncEnvs Cues // Ancestral Environment
	Indivs  []Indiv
}

func NewPopulation

func NewPopulation(s Settings) Population

func (*Population) ChangeEnvs

func (pop *Population) ChangeEnvs(denv int)

func (*Population) ClearGenome

func (pop *Population) ClearGenome()

func (*Population) Copy

func (pop *Population) Copy() Population

func (*Population) DevPop

func (pop *Population) DevPop(gen int) Population

func (*Population) Evolve

func (pop0 *Population) Evolve(test bool, ftraj *os.File, jsonout string, nstep, epoch int) Population

Records population trajectory and writes files

func (*Population) ExportPopGz

func (pop *Population) ExportPopGz(filename string)

func (*Population) GetFlatGenome

func (pop *Population) GetFlatGenome(IEnv int) Dmat

func (*Population) GetFlatStateVec

func (pop *Population) GetFlatStateVec(istate string, ienv, ibeg, iend int) Dmat

func (*Population) GetMeanPhenotype

func (pop *Population) GetMeanPhenotype(gen int) Cues

func (*Population) GetStats

func (pop *Population) GetStats() PopStats

func (*Population) ImportPopGz

func (pop *Population) ImportPopGz(filename string)

func (*Population) PairReproduce

func (pop *Population) PairReproduce(nNewPop int) Population

func (*Population) RandomizeGenome

func (pop *Population) RandomizeGenome()

func (*Population) Reproduce

func (pop *Population) Reproduce(nNewPop int) Population

func (*Population) Selection

func (pop *Population) Selection(nNewPop int) []Indiv

func (*Population) SetRandomNovEnvs

func (pop *Population) SetRandomNovEnvs()

func (*Population) SetWagnerFitness

func (pop *Population) SetWagnerFitness()

func (*Population) SortPopIndivs

func (pop *Population) SortPopIndivs()

type Settings

type Settings struct {
	MaxPop     int // Maximum number of individuals in population
	MaxDevStep int // Maximum steps for development.
	NGenes     int
	NEnv       int
	NSel       int
	NCells     int     // Number of cell types
	WithCue    bool    // With cue?
	FLayer     bool    // f present?
	HLayer     bool    // h present?
	JLayer     bool    //  J present?
	Pfback     bool    // P feedback to E layer
	SDNoise    float64 // probability (or stdev) of environmental noise
	MutRate    float64 // mutation rate
	TauF       float64
	TauG       float64
	TauH       float64
	DensityE   float64
	DensityF   float64
	DensityG   float64
	DensityH   float64
	DensityJ   float64
	DensityP   float64
}

func CurrentSettings

func CurrentSettings() Settings

type Spmat

type Spmat struct {
	Ncol int                 // number of columns
	Mat  [](map[int]float64) // Sparse matrix is an array of maps.
}

func DiffSpmat

func DiffSpmat(m1, m2 *Spmat) Spmat

func NewSpmat

func NewSpmat(nrow, ncol int) Spmat

func (*Spmat) Copy

func (sp *Spmat) Copy() Spmat

func (*Spmat) Randomize

func (sp *Spmat) Randomize(density float64)

func (*Spmat) Scale

func (sp *Spmat) Scale(c float64)

type Tensor3

type Tensor3 []Dmat

func GetHOSVD

func GetHOSVD(ten Tensor3) (Tensor3, *mat.Dense, *mat.Dense, *mat.Dense)

Returns a compact core tensor and orthonormal basis.

func NewTensor3

func NewTensor3(n0, n1, n2 int) Tensor3

type Vec

type Vec = []float64 //Vector is a slice

func CopyVec

func CopyVec(v Vec) Vec

func FlattenEnvs

func FlattenEnvs(cues Cues) Vec

func GetMeanVec

func GetMeanVec(vecs []Vec) Vec

func GetVarVec

func GetVarVec(vecs []Vec) Vec

func NewVec

func NewVec(len int) Vec

func NormDiag2

func NormDiag2(a Dmat) Vec

func Ones

func Ones(len int) Vec

func UnitVec

func UnitVec(len, dir int) Vec

func Zeroes

func Zeroes(len int) Vec

Jump to

Keyboard shortcuts

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