Code Monkey home page Code Monkey logo

Comments (1)

virgile-baudrot avatar virgile-baudrot commented on September 10, 2024

and the second part on Phenotypes...

Phenotype

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

from dispersal.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.