-
Notifications
You must be signed in to change notification settings - Fork 0
/
JC_Model.Rev
89 lines (57 loc) · 2.02 KB
/
JC_Model.Rev
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
################################################################################
#
# RevBayes Example: Bayesian inference of phylogeny using a Jukes-Cantor model
#
# This file: Runs the full MCMC on a single gene under the Jukes-Cantor
# subsitution model using an unconstrained (unrooted) tree model.
#
# authors: Sebastian Hoehna, Tracy A. Heath, Michael Landis and Brian R. Moore
#
################################################################################
#######################
# Reading in the Data #
#######################
# Get some useful variables from the data. We need these later on.
n_species <- data.ntaxa()
n_sites <- data.nchar()
names <- data.names()
n_branches <- 2 * n_species - 3
# set my move index
mi = 0
######################
# Substitution Model #
######################
#### specify the Jukes-Cantor substitution model applied uniformly to all sites ###
Q := fnJC(4)
##############
# Tree model #
##############
#### Specify a uniform prior on the tree topology ####
topology ~ dnUniformTopology(names)
# moves on the tree
moves[++mi] = mvNNI(topology)
moves[++mi] = mvSPR(topology)
#### Specify a prior and moves on the branch lengths ####
# create a random variable for each branch length using a for loop
for (i in 1:n_branches) {
# We use here the exponential distribution with rate 1.0 as the branch length prior
br_lens[i] ~ dnExponential(10.0)
# Add a move for the branch length. We just take a simple scaling move since the value is a positive real number.
moves[++mi] = mvScale(br_lens[i])
}
TL := sum(br_lens)
# Build the tree by combining the topology with the branch length.
phylogeny := treeAssembly(topology, br_lens)
###################
# PhyloCTMC Model #
###################
# the sequence evolution model
seq ~ dnPhyloCTMC(tree=phylogeny, Q=Q, type="DNA")
# attach the data
seq.clamp(data)
#############
# THE Model #
#############
# We define our model.
# We can use any node of our model as a handle, here we chose to use the rate matrix.
mymodel = model(Q)