Skip to content

Loggers

Igor Siveroni edited this page May 28, 2020 · 21 revisions

Loggers

PhyDyn is equipped with two types of loggers, TrajectoryLogger and STreeRootLogger.

TrajectoryLogger

The TrajectoryLogger records the population sizes of deme and non-demes along the population trajectories generated during an MCMC run, as well as birth and migration rates (optional). In addition to the fileName and logEvery standard Logger arguments, the TrajectoryLogger uses the following:

  • popModelODE(BEAST object): reference to the PhyDyn population model BEAST object to log.
  • pointFrequency (integer, default=1): frequency between points in time series to be logged.
    Given a trajectory with n points [0,..,n-1], where point 0 corresponds to inital time t0 and point (n-1) to end time t1, the logger will log population (and rate) values for points [1,f,2f,....,n-1], where f denotes pointFrequency.
  • logrates (string, default=''): Indicates birth and migration rates (matrix equation entries) to log.
    Syntax:
    <logrates> ::= <matrix-rate>* | all
    <matrix-rate> ::= F(<deme> , <deme>) | G(<deme>, <deme>) | F | G

The number of points recorded per trajectory depends on the value of the pointFrequency parameter, and the number of points used to approximate the trajectory the PopModelODE solver; the latter is specified by the integrationSteps argument in TrajectoryParameters. For example, the logger defined by:

<logger id = "popModelLogger" fileName="model.traj" logEvery="100">
  <log id="trajectoryLogger" spec="TrajectoryLogger" popModel="@sirmodel" pointFrequency="1"></log>
</logger>

will log every point of the trajectory - since the point frequency is one - into file model.traj. A pointFrequency of 10 combined with a popModel trajectory computed with 200 integration steps will log points 0,10,20,30,...,200. The logger produces a tab-separated table where each row corresponds to a time-point, which can be plotted by running the plot_trajectory.R script.

Logging birth and migration rates

We use the logrates argument to specify the birth and migration rates we want to log. We write:

  • logrates = 'all' to log all birth and migration rates.
  • logrates = 'F' to log all birth rates.
  • logrates = 'G' to log all migration rates.
    we can also use
  • a combination of specific birth or migration matrix equation entries e.g. logrates = 'F(d1,d2) G(d3,d4)'.
  • a combination of F or G with individual matrix equation entries e.g. logrates = 'F G(d3,d4)'.

For example, the logger defined by:

<logger id = "popModelLogger" fileName="model.traj" logEvery="100">
  <log id="trajectoryLogger" spec="TrajectoryLogger" popModel="@sirmodel"
       pointFrequency="1" logrates = "G(I1,I2)"></log>
</logger>

will log all deme and non-deme population sizes, and the migration rate from I1 to I2, as specified by the corresponding migration equation in PopModelODE object seirmodel. Other combinations include:

STreeRootLogger

The STreeRootLogger logs the state probabilities at the root of the trees sampled during an MCMC run. It is defined as follows:

<logger id="probtreelog" fileName="rootStateProbabilities.log" logEvery="1" mode="tree">
	<log id="logTrees" spec="STreeRootLogger" tree="@tree" density="@stlikelihood"/>
</logger>

Clone this wiki locally