Here we work through a example use of GeLL code explaining the various
components. This is based on example.java
included in the
distributed packages. Comments have been removed, file names shortened
and the taxa names in the Newick tree shortened to allow for a smaller
code snippet. In the descriptions the input to functions are not included
again for the sake of brevity. Please follow the links for a full description
of each function.
Tree.fromNewickString()
or be read from a file using
Tree.fromFile()
._1
.
PhylipAlignment
, but FastaAlignment
or DuplicationAlignment
could also
have been used in the same way.
getParameters()
or
getParametersForEstimation()
- the first sets the parameter value for any branch lengths
given in the tree where as the second returns parameters that will be estimated even if a branch length
was provided.DNAModelFactory
or DuplicationModelFactory
.
Passing a parameters object to the function, as here, will populate the parameters objects with the parameters
that model needs and is the easiest way to do simple calculations.m
), alignment (a
) and tree (t
) at
creation
and then it can be used to perform likelihood calculations used different parameters.
GoldenSection
,
NelderMead
and ConjugateGradient
.
Golden Section is the most mature of these and so most likely to produce the expected result but it may not
be the fastest. All methods can sometimes not optimise properly for specific datasets so it sometimes
necessary to use different methods.maximize
function the optimiser will attempt to optimise the parameters to find the maximum likelihood. It then
returns a likelihood object which contains information on the likelihood obtained and the parameters
values used to calculate that likelihood (which is this case will be optimised parameters. Here
we replace the unoptimised parameters with the optimised parameters for use in the following calculations
by using getParameters()
to get the optimised parameters from the likelihood
object.
getLikelihood()
function of the likelihood returns the likelihood as a double
which is then printed. Parameters
has a toString()
function that prints each parameter value, one per line, so the line here outputs all the parameters to the
screen.
AncestralJoint
) and marginal (AncestralMarginal
).
Both can be created by calls to there newInstance()
static method and
this takes as input a model, alignment and treecalculate
method calculates the ancestral sequences. It returns
an alignment that contains both the original sequences and sequences for each internal node of the tree.
Simulate
class can be used to simulate alignments based on a model
(m
), tree (t
) and a set of parameters (p
). Once created the object
can be used to create alignments using its getAlignment()
method. This method
is passed the length of alignment to simulate.