#include "../config.h"
#include <assert.h>
#include "birthdeath.h"
#include <utils.h>
#include <stdlib.h>
#include <stdio.h>
#include <family.h>
#include <float.h>
#include <mathfunc.h>
#include "chooseln_cache.h"
Functions | |
double | birthdeath_rate_with_log_alpha_beta (int s, int c, double log_alpha, double log_beta, double log_coeff, struct chooseln_cache *cache) |
double | birthdeath_rate_with_log_alpha (int s, int c, double log_alpha, double coeff, struct chooseln_cache *cc) |
double | birthdeath_likelihood_with_s_c (int root_family_size, int family_size, double branchlength, double lambda, double mu, struct chooseln_cache *cache) |
Calculates the probability of transitioning from root_family_size to family_size. More... | |
void | square_matrix_init (struct square_matrix *matrix, int sz) |
void | square_matrix_set (struct square_matrix *matrix, int x, int y, double val) |
void | square_matrix_delete (struct square_matrix *matrix) |
void | square_matrix_resize (struct square_matrix *matrix, int new_size) |
void | square_matrix_print (struct square_matrix *matrix) |
void | square_matrix_multiply (struct square_matrix *matrix, double *vector, int row_start, int row_end, int col_start, int col_end, double *result) |
void | init_zero_matrix (struct square_matrix *matrix) |
void | init_identity_matrix (struct square_matrix *matrix) |
void | init_matrix (struct square_matrix *matrix, double coeff) |
struct square_matrix * | compute_birthdeath_rates (double branchlength, double lambda, double mu, int maxFamilysize) |
void | birthdeath_cache_matrix_resize (struct square_matrix *matrix, int remaxFamilysize, double branchlength, double lambda, double mu) |
void | birthdeath_cache_resize (pBirthDeathCacheArray pbdc_array, int remaxFamilysize) |
pBirthDeathCacheArray | birthdeath_cache_init (int size, struct chooseln_cache *ln_cache) |
void | birthdeath_cache_array_free (pBirthDeathCacheArray pbdc_array) |
struct square_matrix * | birthdeath_cache_get_matrix (pBirthDeathCacheArray pbdc_array, double branchlength, double lambda, double mu) |
Variables | |
struct chooseln_cache | cache = { 0,0 } |
A cache of values of chooseln. More... | |
void birthdeath_cache_array_free | ( | pBirthDeathCacheArray | pbdc_array | ) |
struct square_matrix* birthdeath_cache_get_matrix | ( | pBirthDeathCacheArray | pbdc_array, |
double | branchlength, | ||
double | lambda, | ||
double | mu | ||
) |
Returns square matrix of doubles, rows and columns representing the transition probability in birthdeath rate in a change of one family size to another, with the given values of branch length, lambda, and mu
pBirthDeathCacheArray birthdeath_cache_init | ( | int | size, |
struct chooseln_cache * | ln_cache | ||
) |
void birthdeath_cache_matrix_resize | ( | struct square_matrix * | matrix, |
int | remaxFamilysize, | ||
double | branchlength, | ||
double | lambda, | ||
double | mu | ||
) |
void birthdeath_cache_resize | ( | pBirthDeathCacheArray | pbdc_array, |
int | remaxFamilysize | ||
) |
double birthdeath_likelihood_with_s_c | ( | int | root_family_size, |
int | family_size, | ||
double | branchlength, | ||
double | lambda, | ||
double | mu, | ||
struct chooseln_cache * | cache | ||
) |
Calculates the probability of transitioning from root_family_size to family_size.
Given the branch length and the expected change rate lammbda
double birthdeath_rate_with_log_alpha | ( | int | s, |
int | c, | ||
double | log_alpha, | ||
double | coeff, | ||
struct chooseln_cache * | cc | ||
) |
double birthdeath_rate_with_log_alpha_beta | ( | int | s, |
int | c, | ||
double | log_alpha, | ||
double | log_beta, | ||
double | log_coeff, | ||
struct chooseln_cache * | cache | ||
) |
struct square_matrix* compute_birthdeath_rates | ( | double | branchlength, |
double | lambda, | ||
double | mu, | ||
int | maxFamilysize | ||
) |
returns a structure representing a matrix of precalculated transition probabilites from one family size to another, given the specified values of branch length, lambda, and mu. Values are calculated from 0 to the given maxFamilySize. All relevant values are stored in the structure.
lambda is the probability of both gene gain and loss per gene per unit time in the phylogeny [CAFE assumes that gene birth and death are equally probable, see Hahn et al. (2005)]. If mu is provided, lambda and mu represent the probability of gene birth and gene death, respectively.
void init_identity_matrix | ( | struct square_matrix * | matrix | ) |
void init_matrix | ( | struct square_matrix * | matrix, |
double | coeff | ||
) |
void init_zero_matrix | ( | struct square_matrix * | matrix | ) |
void square_matrix_delete | ( | struct square_matrix * | matrix | ) |
void square_matrix_init | ( | struct square_matrix * | matrix, |
int | sz | ||
) |
void square_matrix_multiply | ( | struct square_matrix * | matrix, |
double * | vector, | ||
int | row_start, | ||
int | row_end, | ||
int | col_start, | ||
int | col_end, | ||
double * | result | ||
) |
void square_matrix_print | ( | struct square_matrix * | matrix | ) |
void square_matrix_resize | ( | struct square_matrix * | matrix, |
int | new_size | ||
) |
void square_matrix_set | ( | struct square_matrix * | matrix, |
int | x, | ||
int | y, | ||
double | val | ||
) |
struct chooseln_cache cache = { 0,0 } |
A cache of values of chooseln.
Chooseln evaluates the natural logarithm of Gamma(n+1)/(Gamma(k+1)*Gamma(n-k+1)) The cache holds values for integer values of n and k. It does not appear to be threadsafe.
P(X(t) = c | X(0) = s) = {j=0}^{(s,c)} {s}{j}{s+c-j-1}{s-1} ^{s+c-2j}(1-2)^j