Updating transition probability matrices - xflouris/libpll GitHub Wiki

Associated API reference: pll_update_prob_matrices()

Transition probability matrices can be updated using the function

PLL_EXPORT void pll_update_prob_matrices(pll_partition_t * partition,
                                         const unsigned int * params_indices,
                                         const unsigned int * matrix_indices,
                                         const double * branch_lengths,
                                         unsigned int count);

It takes as input the partition instance partition, and three arrays. Array params_indices holds the indices of rate matrices that will be used for each rate category. This array must be of size rate_cats as specified in the pll_partition_create function. The next two arrays specify the p-matrix entry to be used (matrix_indices) for each branch length entry (branch_lengths). The size of these two arrays must be specified using the count parameter.

Example

In this example we assume 4 rate categories were specified.

/* probability matrices to be updated */
unsigned int matrix_indices[5] = { 0, 1, 2, 3, 4};

/* branch lengths to be used */
double branch_lengths[5] = { 0.2, 0.4, 0.3, 0.5, 0.6};

/* rate matrix indices to be used for each p-matrix block */
unsigned int params_indices[4] = {0,0,0,0};

/* update transition probability matrices */
pll_update_prob_matrices(partition,
                         params_indices,
                         matrix_indices,
                         branch_lengths,
                         5);

The above examples will update the blocks of matrices residing at indices 0,1,2,3,4. Note that each index is a placeholder for 4 different p-matrices, each using one of the four different rate categories. The parameter params_indices dictates which rate matrix should be used for each of the four p-matrices. In this case, the same rate matrix will be used for all four p-matrices of each matrix_indices entry. Finally, array branch_lengths specifies that p-matrices at entry 0 will use branch length 0.2, p-matrices at entry 1 will use branch length 0.4 and so on.