CAFE
Computational Analysis of gene Family Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lambda.h
Go to the documentation of this file.
1 #ifndef LAMBDA_H_5CC2A46B_4881_4C8F_BDE7_BE29023F2D15
2 #define LAMBDA_H_5CC2A46B_4881_4C8F_BDE7_BE29023F2D15
3 
4 #include <vector>
5 #include <string>
6 
7 extern "C" {
8 #include "cafe.h"
9 #include "family.h"
10 #include "cafe_shell.h"
11 #include "gmatrix.h"
12 }
13 
14 class Globals;
15 struct Argument;
16 
18 
20 {
21  double start;
22  double step;
23  double end;
24 };
25 
27 {
28  bool search;
30  int bdone;
31  std::string name;
32  std::vector<double> lambdas;
33  std::vector<double> k_weights;
35  bool checkconv;
36  bool score;
39 
41  lambda_tree(NULL), checkconv(false), num_params(0), fixcluster0(0)
42  {
43  }
44 
45  virtual void load(std::vector<Argument> pargs);
46  virtual const char* command() = 0;
47  virtual const char* args() = 0;
48  void validate_parameter_count(int expected);
49 
50  virtual int get_num_params() const
51  {
52  return (lambdas.size()*(k_weights.size() - fixcluster0)) + (k_weights.size() - 1);
53  }
54 };
55 
57 {
58  lambda_args() : lambda_arg_base(), vlambda(0.0), each(false), write_files(false) {}
59  virtual void load(std::vector<Argument> pargs);
60  double vlambda;
61  std::string outfile;
62  bool each;
64  std::vector<lambda_range> range;
65 
66  virtual const char* command() { return "lambda"; }
67  virtual const char* args() { return "lambdas (-l)"; }
68 };
69 
70 int cafe_cmd_lambda(Globals& globals, std::vector<std::string> tokens);
71 void set_all_lambdas(pCafeParam param, double value);
72 pGMatrix cafe_lambda_distribution(pCafeParam param, const std::vector<lambda_range>& range);
73 void cafe_set_prior_rfsize_poisson_lambda(std::vector<double>& prior_rfsize, int shift, double* lambda);
74 double cafe_set_prior_rfsize_empirical(pCafeParam param, std::vector<double>& prior_rfsize);
75 double get_posterior(pCafeFamily pfamily, pCafeTree pcafe, family_size_range*range, std::vector<double>& ML, std::vector<double>& MAP, std::vector<double>& prior_rfsize, int quiet);
76 struct posterior
77 {
79  double max_posterior;
80 };
81 
82 posterior compute_posterior(pCafeFamilyItem pitem, pCafeTree pcafe, const std::vector<double>& prior_rfsize);
83 
85 {
86  double *parameters;
89  double score;
90 };
91 
93 
94 const int INIT_PARAMS = 1;
95 const int INIT_KWEIGHTS = 2;
96 void initialize_params_and_k_weights(pCafeParam param, int what);
97 void set_parameters(pCafeParam param, lambda_args& params);
98 void lambda_set(pCafeParam param, lambda_args& params);
99 std::vector<int> collect_leaf_sizes(pCafeFamily pfamily);
100 
101 #endif
102 
virtual const char * command()
Definition: lambda.h:66
bool write_files
Definition: lambda.h:63
std::vector< double > k_weights
Definition: lambda.h:33
lambda_arg_base()
Definition: lambda.h:40
std::vector< double > lambdas
Definition: lambda.h:32
void cafe_set_prior_rfsize_poisson_lambda(std::vector< double > &prior_rfsize, int shift, double *lambda)
Definition: lambda.cpp:824
pTree lambda_tree
Definition: lambda.h:34
Definition: lambda.h:17
void initialize_params_and_k_weights(pCafeParam param, int what)
Definition: lambda.cpp:255
Definition: gmatrix.h:4
double vlambda
Definition: lambda.h:60
std::vector< lambda_range > range
Definition: lambda.h:64
lambda_args()
Definition: lambda.h:58
const int INIT_PARAMS
Definition: lambda.h:94
Definition: lambda.h:76
double step
Definition: lambda.h:22
const int INIT_KWEIGHTS
Definition: lambda.h:95
virtual const char * command()=0
Definition: Globals.h:13
int num_params
Definition: lambda.h:87
void lambda_set(pCafeParam param, lambda_args &params)
Definition: lambda.cpp:287
virtual const char * args()
Definition: lambda.h:67
Definition: family.h:10
double * parameters
Definition: lambda.h:86
LAMBDA_TYPE lambda_type
Definition: lambda.h:29
std::vector< int > collect_leaf_sizes(pCafeFamily pfamily)
Definition: lambda.cpp:772
Definition: cafe_commands.h:15
std::string outfile
Definition: lambda.h:61
double score
Definition: lambda.h:89
int bdone
Definition: lambda.h:30
LAMBDA_TYPE
Definition: lambda.h:17
virtual void load(std::vector< Argument > pargs)
Definition: lambda.cpp:145
poisson_lambda find_poisson_lambda(pCafeFamily pfamily)
Definition: lambda.cpp:791
int num_iterations
Definition: lambda.h:88
double start
Definition: lambda.h:21
virtual const char * args()=0
Definition: lambda.h:26
std::string name
Definition: lambda.h:31
double max_posterior
Definition: lambda.h:79
virtual void load(std::vector< Argument > pargs)
Definition: lambda.cpp:88
Definition: lambda.h:84
Definition: lambda.h:17
Represents a single gene family and the number of members of that family that exist in each species...
Definition: cafe.h:11
int cafe_cmd_lambda(Globals &globals, std::vector< std::string > tokens)
posterior compute_posterior(pCafeFamilyItem pitem, pCafeTree pcafe, const std::vector< double > &prior_rfsize)
Definition: lambda.cpp:648
double max_likelihood
Definition: lambda.h:78
Singleton structure that holds all of the global data that Cafe acts on.
Definition: family.h:115
pGMatrix cafe_lambda_distribution(pCafeParam param, const std::vector< lambda_range > &range)
bool search
Definition: lambda.h:28
Definition: lambda.h:56
double cafe_set_prior_rfsize_empirical(pCafeParam param, std::vector< double > &prior_rfsize)
set empirical prior on rootsize based on the assumption that rootsize follows leaf size distribution ...
Definition: lambda.cpp:839
virtual int get_num_params() const
Definition: lambda.h:50
double end
Definition: lambda.h:23
int fixcluster0
Definition: lambda.h:38
Definition: tree.h:11
double get_posterior(pCafeFamily pfamily, pCafeTree pcafe, family_size_range *range, std::vector< double > &ML, std::vector< double > &MAP, std::vector< double > &prior_rfsize, int quiet)
Definition: lambda.cpp:674
Definition: lambda.h:17
void set_parameters(pCafeParam param, lambda_args &params)
Definition: lambda.cpp:269
Structure representing a matrix of values of family sizes.
Definition: family.h:88
bool each
Definition: lambda.h:62
bool score
Definition: lambda.h:36
Definition: lambda.h:19
void set_all_lambdas(pCafeParam param, double value)
Definition: lambda.cpp:177
Definition: family.h:17
void validate_parameter_count(int expected)
Definition: lambdamu.cpp:105
bool checkconv
Definition: lambda.h:35
int num_params
Definition: lambda.h:37