File: definitions3.bf

package info (click to toggle)
hyphy 2.5.28%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 24,780 kB
  • sloc: cpp: 76,872; xml: 467; lisp: 341; python: 156; javascript: 117; sh: 106; makefile: 86; ansic: 86
file content (60 lines) | stat: -rw-r--r-- 1,617 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* This is an example HY-PHY Batch File.

	In this file, we will illustrate how to define category
	variables sampled from continuous distribution to model rate heterogeneity
	and spatially correlated via a hidden markov chain
	
   Sergei L. Kosakovsky Pond and Spencer V. Muse 
   June 2001. 
*/

/* 1.
	Refer to definition1.bf and definition2.bf for 
	examples on how to define a distribution of rates.
	To introduce space correlation via a hidden markov model
	we need to specify an additional parameter in the call
	to "category": the transition matrix for the HMM.
	The following example defines a simple HMM model
	following the paper of Felsenstein and Churchill (1996 J Mol Evol).
*/

#include "displayFunction.bf";

global lambda = .5;
lambda :< 1;

hiddenMarkovM = {10,10};
hiddenMarkovF = {10,1};

for (k=0; k<10; k=k+1)
{
	hiddenMarkovM [k][k] := lambda+(1-lambda)/10;
	hiddenMarkovF [k][1] := 1/10;
	
	for (l=k+1;l<10;l=l+1)
	{
		hiddenMarkovM [k][l] := (1-lambda)/10;
		hiddenMarkovM [l][k] := (1-lambda)/10;
	}
}


Model HMM = (hiddenMarkovM,hiddenMarkovF,false);

global alpha = 1;
alpha:>0.01;alpha:<100;

category catVar =  (10,		/* number of rates */
					hiddenMarkovF,  /* probs. of rates */
					MEAN,	/* sampling method */
					GammaDist(_x_,alpha,alpha), /* density */
					CGammaDist(_x_,alpha,alpha), /*CDF*/
					0, 				   /*left bound*/
					1e25, 			   /*right bound*/
					CGammaDist(_x_,alpha+1,alpha),
						/* "antiderivative" of x f(x) */
					HMM /* transition matrix for the hidden Markov model */
				   );
				   
GetInformation (catInfo,catVar);
catInfo = echoCatVar (catInfo);