Skip to content
Open

Sb #9

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added homework/.DS_Store
Binary file not shown.
Binary file added homework/BiernackiHomework/.DS_Store
Binary file not shown.
Binary file not shown.
99 changes: 99 additions & 0 deletions homework/BiernackiHomework/RevFiles/Biernacki_mcmcF81.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
################################################################################
#
# RevBayes Example: Bayesian inference of phylogeny using a Jukes-Cantor
# substitution model on a single gene.
#
# authors: Sebastian Hoehna, Michael Landis, and Tracy A. Heath
#
################################################################################


### Read in sequence data for both genes
data = readDiscreteCharacterData("data/primates_and_galeopterus_cytb.nex")

# Get some useful variables from the data. We need these later on.
num_taxa <- data.ntaxa()
num_branches <- 2 * num_taxa - 3
taxa <- data.taxa()

moves = VectorMoves()
monitors = VectorMonitors()


######################
# Substitution Model #
######################

pi_prior <- v(1,1,1,1)
pi ~ dnDirichlet(pi_prior)

moves.append( mvBetaSimplex(pi, weight=2) )
moves.append( mvDirichletSimplex(pi, weight=1) )

# create a constant variable for the rate matrix
Q <- fnF81(pi)


##############
# Tree model #
##############

out_group = clade("Galeopterus_variegatus")
# Prior distribution on the tree topology
topology ~ dnUniformTopology(taxa, outgroup=out_group)
moves.append( mvNNI(topology, weight=num_taxa/2.0) )
moves.append( mvSPR(topology, weight=num_taxa/10.0) )

# Branch length prior
for (i in 1:num_branches) {
bl[i] ~ dnExponential(10.0)
moves.append( mvScale(bl[i]) )
}

TL := sum(bl)

psi := treeAssembly(topology, bl)



###################
# PhyloCTMC Model #
###################

# the sequence evolution model
seq ~ dnPhyloCTMC(tree=psi, Q=Q, type="DNA")

# attach the data
seq.clamp(data)


############
# Analysis #
############

mymodel = model(psi)

# add monitors
monitors.append( mnScreen(TL, printgen=1000) )
monitors.append( mnFile(psi, filename="output/primates_cytb_F81.trees", printgen=10) )
monitors.append( mnModel(filename="output/primates_cytb_F81.log", printgen=10) )

# run the analysis
mymcmc = mcmc(mymodel, moves, monitors, nruns=2, combine="mixed")
mymcmc.run(generations=20000,tuningInterval=200)


###################
# Post processing #
###################

# Now, we will analyze the tree output.
# Let us start by reading in the tree trace
treetrace = readTreeTrace("output/primates_cytb_F81.trees", treetype="non-clock", outgroup=out_group)
# and then get the MAP tree
map_tree = mapTree(treetrace,"output/primates_cytb_F81_MAP.tree")


# you may want to quit RevBayes now
q()

104 changes: 104 additions & 0 deletions homework/BiernackiHomework/RevFiles/Biernacki_mcmcGTR.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
################################################################################
#
# RevBayes Example: Bayesian inference of phylogeny using a Jukes-Cantor
# substitution model on a single gene.
#
# authors: Sebastian Hoehna, Michael Landis, and Tracy A. Heath
#
################################################################################


### Read in sequence data for both genes
data = readDiscreteCharacterData("data/primates_and_galeopterus_cytb.nex")

# Get some useful variables from the data. We need these later on.
num_taxa <- data.ntaxa()
num_branches <- 2 * num_taxa - 3
taxa <- data.taxa()

moves = VectorMoves()
monitors = VectorMonitors()


######################
# Substitution Model #
######################

er_prior <- v(1,1,1,1,1,1)
er ~ dnDirichlet(er_prior)
moves.append( mvBetaSimplex(er, weight=3) )
moves.append( mvDirichletSimplex(er, weight=1) )

pi_prior <- v(1,1,1,1)
pi ~ dnDirichlet(pi_prior)

moves.append( mvBetaSimplex(pi, weight=2) )
moves.append( mvDirichletSimplex(pi, weight=1) )

# create a constant variable for the rate matrix
Q <- fnGTR(er,pi)


##############
# Tree model #
##############

out_group = clade("Galeopterus_variegatus")
# Prior distribution on the tree topology
topology ~ dnUniformTopology(taxa, outgroup=out_group)
moves.append( mvNNI(topology, weight=num_taxa/2.0) )
moves.append( mvSPR(topology, weight=num_taxa/10.0) )

# Branch length prior
for (i in 1:num_branches) {
bl[i] ~ dnExponential(10.0)
moves.append( mvScale(bl[i]) )
}

TL := sum(bl)

psi := treeAssembly(topology, bl)



###################
# PhyloCTMC Model #
###################

# the sequence evolution model
seq ~ dnPhyloCTMC(tree=psi, Q=Q, type="DNA")

# attach the data
seq.clamp(data)


############
# Analysis #
############

mymodel = model(psi)

# add monitors
monitors.append( mnScreen(TL, printgen=1000) )
monitors.append( mnFile(psi, filename="output/primates_cytb_GTR.trees", printgen=10) )
monitors.append( mnModel(filename="output/primates_cytb_GTR.log", printgen=10) )

# run the analysis
mymcmc = mcmc(mymodel, moves, monitors, nruns=2, combine="mixed")
mymcmc.run(generations=20000,tuningInterval=200)


###################
# Post processing #
###################

# Now, we will analyze the tree output.
# Let us start by reading in the tree trace
treetrace = readTreeTrace("output/primates_cytb_GTR.trees", treetype="non-clock", outgroup=out_group)
# and then get the MAP tree
map_tree = mapTree(treetrace,"output/primates_cytb_GTR_MAP.tree")


# you may want to quit RevBayes now
q()

111 changes: 111 additions & 0 deletions homework/BiernackiHomework/RevFiles/Biernacki_mcmcGTRG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
################################################################################
#
# RevBayes Example: Bayesian inference of phylogeny using a Jukes-Cantor
# substitution model on a single gene.
#
# authors: Sebastian Hoehna, Michael Landis, and Tracy A. Heath
#
################################################################################


### Read in sequence data for both genes
data = readDiscreteCharacterData("data/primates_and_galeopterus_cytb.nex")

# Get some useful variables from the data. We need these later on.
num_taxa <- data.ntaxa()
num_branches <- 2 * num_taxa - 3
taxa <- data.taxa()

moves = VectorMoves()
monitors = VectorMonitors()


######################
# Substitution Model #
######################

er_prior <- v(1,1,1,1,1,1)
er ~ dnDirichlet(er_prior)
moves.append( mvBetaSimplex(er, weight=3) )
moves.append( mvDirichletSimplex(er, weight=1) )

pi_prior <- v(1,1,1,1)
pi ~ dnDirichlet(pi_prior)

moves.append( mvBetaSimplex(pi, weight=2) )
moves.append( mvDirichletSimplex(pi, weight=1) )

mu_a<-ln(5.0)
sigma_a<-0.587405

alpha ~ dnLognormal(mu_a, sigma_a)

sr := fnDiscretizeGamma(alpha, alpha, 4, false)

# create a constant variable for the rate matrix
Q <- fnGTR(er,pi)


##############
# Tree model #
##############

out_group = clade("Galeopterus_variegatus")
# Prior distribution on the tree topology
topology ~ dnUniformTopology(taxa, outgroup=out_group)
moves.append( mvNNI(topology, weight=num_taxa/2.0) )
moves.append( mvSPR(topology, weight=num_taxa/10.0) )

# Branch length prior
for (i in 1:num_branches) {
bl[i] ~ dnExponential(10.0)
moves.append( mvScale(bl[i]) )
}

TL := sum(bl)

psi := treeAssembly(topology, bl)



###################
# PhyloCTMC Model #
###################

# the sequence evolution model
seq ~ dnPhyloCTMC(tree=psi, Q=Q, siteRates=sr, type="DNA")

# attach the data
seq.clamp(data)


############
# Analysis #
############

mymodel = model(psi)

# add monitors
monitors.append( mnScreen(TL, printgen=1000) )
monitors.append( mnFile(psi, filename="output/primates_cytb_GTR.trees", printgen=10) )
monitors.append( mnModel(filename="output/primates_cytb_GTR.log", printgen=10) )

# run the analysis
mymcmc = mcmc(mymodel, moves, monitors, nruns=2, combine="mixed")
mymcmc.run(generations=20000,tuningInterval=200)


###################
# Post processing #
###################

# Now, we will analyze the tree output.
# Let us start by reading in the tree trace
treetrace = readTreeTrace("output/primates_cytb_GTR.trees", treetype="non-clock", outgroup=out_group)
# and then get the MAP tree
map_tree = mapTree(treetrace,"output/primates_cytb_GTR_MAP.tree")


# you may want to quit RevBayes now
q()

Loading