Modelling traits on trees
Phylo.BrownianTrait
— TypeBrownianTrait{T <: AbstractTree, N <: Number}
A continuous trait evolved on a phylogenetic tree. This is a Sampleable
type, so a random trait can be created using rand()
. The trait to be evolved can be any continuous numeric type, including Unitful
types for instance, and in the simplest case is determined by the third argument to the constructor start
:
function BrownianTrait(tree::AbstractTree, trait::String, start::Number = 0.0; σ² = missing, σ = missing, f::Function = identity)
Note that when Unitful
is being used, either here or in branch lengths, σ
/σ²
keyword argument units must be appropriate. The final keyword argument, f
, is a function to transform the evolved gaussian trait into its true value. By default this is the identity function, but can, for instance, be abs
to force a positive value on the trait, or more complex functions as required, such as a transformation to turn a continuous variable into a discrete trait
Phylo.DiscreteTrait
— TypeDiscreteTrait{T <: AbstractTree, E <: Enum}
A discrete trait evolved on a phylogenetic tree. This is a Sampleable
type, so a random trait can be created using rand(dt)
. The trait to be evolved must be an Enum (generally created using @enum
), and is the second argument to the constructor:
function DiscreteTrait(tree::AbstractTree, ttype::Type{<:Enum}, transition_matrix::AbstractMatrix{Float64}, trait::String)
The transition matrix holds transition rates from row to column (so row sums must be zero), and the transition probabilities in a branch are calculated as exp(transition_matrix .* branch_length)
.
Phylo.SymmetricDiscreteTrait
— TypeSymmetricDiscreteTrait{T <: AbstractTree, E <: Enum}
The simplest possible discrete trait evolved on a phylogenetic tree. This is a Sampleable
type, so a random trait can be created using rand(sdt)
. The trait to be evolved must be an Enum (generally created using @enum
), and is the second argument to the constructor:
function DiscreteTrait(tree::AbstractTree, ttype::Type{<:Enum}, transition_rate::Number, trait::String)
The transition matrix holds transition rates from row to column (so row sums must be zero), and the transition probabilities in a branch are calculated as exp(transition_matrix .* branch_length)
.