Open virgile-baudrot opened 3 years ago
and the second part on Phenotypes...
Phenotype is easier. First with a Phenotype_unitt
giving the phenotype value for a single individual
struct Phenotype_unit
name::String
value::Float64 # value of the trait for 1 individual
end
name(pu::Phenotype_unit) = Phenotype_unit.name
value(pu::Phenotype_unit) = Phenotype_unit.value
Base.:*(p::Phenotype_unit, x::Number) = Phenotype_unit(x*p.phenotype)
Base.:*(x::Number, p::Phenotype_unit) = Phenotype_unit(x*p.phenotype)
Base.:+(p::Phenotype_unit, x::Number) = Phenotype_unit(p.phenotype + x)
Base.:+(x::Number, p::Phenotype_unit) = Phenotype_unit(p.phenotype + x)
# Base.:+(p1::Phenotype_unit, p2::Phenotype_unit) = ... sense ?
Base.:-(p::Phenotype_unit, x::Number) = Phenotype_unit(p.phenotype - x)
Base.:-(x::Number, p::Phenotype_unit) = Phenotype_unit(p.phenotype - x)
# Base.:-(p1::Phenotype_unit, p2::Phenotype_unit) = ... # sense ?
Base.zero(::Type{<:Phenotype_unit{T}}) where {T} = Phenotype_unit(zero(T))
Then there is several possibility
struct Phenotype <: AbstractIndividual
phenotype::Array{Phenotype_unit, 1} # set of values of trait for 1 individual
# TODO: 1. Each name of Phenotype_unit has to be unique within the phenotype vector
end
# Using genericity of Phenotype Unit
# Base.:*(p::Phenotype, x::Number) = ...
# Base.:*(x::Number, p::Phenotype) = ...
struct Population <: AbstractPopulation
size::Float64 # Size of the population. Again an Integer could be relevant
phenotypes::Array{Phenotype, 1} # set of values of trait for 1 individual
# TODO: size is the length of phenotypes vector
end
size(pp::Population) = pp.size
phenotypes(pp::Population) = pp.phenotypes
Then, converting a Population
to a StatsPopulation
allow to make some operation by assuming Normal distribution of phenotypes, we can develop:
X ~ N(\mu, \sigma^2 ) => a X + b ~ N(a \mu + b, a^2 \sigma^2)
X ~ N(\mu_x, \sigma_x^2 ) and Y ~ N(\mu_y, \sigma_y^2 ) => X + Y ~ N(\mu_x + \mu_y, \sigma_x^2 + \sigma_y^2)
struct StatsPopulation <: StatisticsPopulation
size::Int64
phenotypeNames::Array{String, 1} # retrieve from Phenotype_unit
phenotypeMean::Array{Float64, 1}
phenotypeVariance::Array{Float64, 1}
# TODO: INTERNAL CONSTRUCTOR based on
end
size(sp::StatsPopulation) = sp.size
names(sp::StatsPopulation) = sp.phenotypeNames
means(sp::StatsPopulation) = sp.phenotypeMean
variances(sp::StatsPopulation) = sp.phenotypeVariance
Following discussion on Population type in https://github.com/cesaraustralia/Dispersal.jl/issues/70#issuecomment-737756996_
I start reviewing the possibilities, given quite big "Comment". There are 2 parts: one about Genetics, a second about Phenotypes
Genetics
For the Genetics, we have to define
Locus
, aZygote_unit
and aZygote
(an individual) andDeme
(Population).I use
Locus
definition like https://en.wikipedia.org/wiki/Locus_(genetics). The argumentploidy
which is additional to the definition is to facilitate the handling of polysomy (like trisomy) but don't know if it's relevant for know.The
Zygote_unit
is used to define the zygosity for a singleLocus
Then, a
Zygote
is a pool ofZygote_unit
use to define an individualFinally, come the definition for Population. A
Deme
is a pool ofZygote
.Since some difficulties on the
Deme
object, I found usefull to define aStatisticsPopulation
. TheStatisticsPopulation
is then super easy to use for phenotypes.