### RevBayes Startup Output Source: https://revbayes.github.io/workshops/woodshole2018 Example of the console output displayed upon successfully starting RevBayes. ```text Build from master (94149b) on Mon Jul 23 15:55:28 EDT 2018 Visit the website www.RevBayes.com for more information about RevBayes. RevBayes is free software released under the GPL license, version 3. Type 'license()' for details. To quit RevBayes type 'quit()' or 'q()'. > ``` -------------------------------- ### RevBayes Startup Output Source: https://revbayes.github.io/workshops/woodshole2019 Example output displayed upon successfully starting the RevBayes application. ```text Build from master (94149b) on Mon Jul 23 15:55:28 EDT 2019 Visit the website www.RevBayes.com for more information about RevBayes. RevBayes is free software released under the GPL license, version 3. Type 'license()' for details. To quit RevBayes type 'quit()' or 'q()'. > ``` -------------------------------- ### Install Prerequisites via Homebrew Source: https://revbayes.github.io/compile-osx Install CMake and Boost using the Homebrew package manager. ```bash brew install cmake boost ``` -------------------------------- ### Bernoulli Distribution MCMC Setup Source: https://revbayes.github.io/documentation/dnBernoulli.html Example of defining a Bernoulli distribution within a RevBayes model and running an MCMC analysis. ```Rev p ~ dnBeta(1.0,1.0) x ~ dnBernoulli(p) x.clamp(1) moves[1] = mvSlide(p, delta=0.1, weight=1.0) monitors[1] = screenmonitor(printgen=1000, separator = " ", x) mymodel = model(p) mymcmc = mcmc(mymodel, monitors, moves) mymcmc.burnin(generations=20000,tuningInterval=100) mymcmc.run(generations=200000) ``` -------------------------------- ### Install Boost via Homebrew Source: https://revbayes.github.io/developer/setup Use this command to install the necessary Boost libraries on macOS. ```bash brew install boost ``` -------------------------------- ### Configure and Install Boost Source: https://revbayes.github.io/compile-windows Commands to bootstrap and build the Boost library using the GCC toolset on Windows. ```bash ./bootstrap.bat gcc ``` ```bash b2 toolset=gcc-13 address-model=64 architecture=x86 --build-dir=build variant=release --build-type=complete --prefix=c:/boost/boost_1_82_0/gcc --with-regex --with-program_options --with-thread --with-system --with-filesystem --with-date_time --with-serialization cxxflags=-std=c++17 install ``` -------------------------------- ### Geometric Distribution MCMC Setup Source: https://revbayes.github.io/documentation/dnGeometric.html Example demonstrating the definition of a geometric distribution within a Bayesian model and the subsequent MCMC configuration. ```Rev p ~ dnBeta(1.0,1.0) x ~ dnGeom(p) x.clamp(10) moves[1] = mvSlide(p, delta=0.1, weight=1.0) monitors[1] = screenmonitor(printgen=1000, separator = " ", p) mymodel = model(p) mymcmc = mcmc(mymodel, monitors, moves) mymcmc.burnin(generations=20000,tuningInterval=100) mymcmc.run(generations=200000) ``` -------------------------------- ### Initialize Starting Tree Source: https://revbayes.github.io/tutorials/biogeo/biogeo_dating.html Read the initial tree from the specified file to ensure a non-zero starting probability. ```Rev tree_init = readTrees(tree_fn)[1] ``` -------------------------------- ### Setup Monitors Source: https://revbayes.github.io/tutorials/mcmc/poisson.html Configure file and screen monitors to track MCMC progress. ```RevBayes monitors[1] = mnModel(filename="output/airline_fatalities.log",printgen=10, separator = " ") monitors[2] = mnScreen(printgen=10, alpha, beta) ``` -------------------------------- ### Install build dependencies on Ubuntu Source: https://revbayes.github.io/compile-linux Use the apt package manager to install essential build tools, CMake, and Boost libraries. ```bash sudo apt update sudo apt install build-essential cmake libboost-all-dev ``` -------------------------------- ### Install Homebrew Source: https://revbayes.github.io/compile-osx Use this command to install the Homebrew package manager if it is not already present on your system. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Initialize Rate Starting Values Source: https://revbayes.github.io/tutorials/sse/bisse.html Manually sets starting values for speciation and extinction rates if the default initialization fails. ```Rev for (i in 1:NUM_STATES) { speciation[i].setValue( ln(367.0/2.0) / observed_phylogeny.rootAge() ) extinction[i].setValue( speciation[i]/10.0 ) } ``` -------------------------------- ### Start the container with bash entrypoint Source: https://revbayes.github.io/developer/docker Launches the container and overrides the entrypoint to provide a bash shell. ```bash docker run --entrypoint /bin/bash revbayesdockerfiles:ubuntu-latest ``` -------------------------------- ### Start RevBayes Source: https://revbayes.github.io/tutorials/fbd_range Launch the RevBayes executable from the terminal. ```bash rb ``` -------------------------------- ### simStartingTree(Taxon[] taxa, Clade[] constraints) Source: https://revbayes.github.io/documentation/simStartingTree.html Initializes a starting tree using a set of taxa and optional topological constraints. ```APIDOC ## simStartingTree ### Description Initializes a starting tree for phylogenetic analysis. ### Signature simStartingTree(Taxon[] taxa, Clade[] constraints) ### Arguments - **taxa** (Taxon[]) - Required - The taxa used for initialization. - **constraints** (Clade[]) - Optional - The topological constraints. Default: [ ] ### Return Type TimeTree ``` -------------------------------- ### Format bash console input Source: https://revbayes.github.io/developer/tutorial Use the {:.bash} class for bash command examples. ```bash ls tutorials grep phylogenetics tutorial.md ``` -------------------------------- ### Poisson Distribution MCMC Setup Source: https://revbayes.github.io/documentation/dnPoisson.html Demonstrates defining a Poisson distributed variable and configuring an MCMC analysis in Rev. ```Rev l ~ dnUniform(0.0,100.0) x ~ dnPoisson(l) x.clamp(10) moves[1] = mvSlide(l, delta=0.1, weight=1.0) monitors[1] = mnScreen(printgen=1000, separator = " ", l) mymodel = model(l) mymcmc = mcmc(mymodel, monitors, moves) mymcmc.burnin(generations=20000,tuningInterval=100) mymcmc.run(generations=200000) ``` -------------------------------- ### Set Starting Values Source: https://revbayes.github.io/tutorials/mcmc/poisson.html Initialize parameter values to avoid likelihood issues during MCMC startup. ```RevBayes # let us use reasonable starting value alpha.setValue(0.0) beta.setValue(0.0) ``` -------------------------------- ### Configure Tutorial Metadata Source: https://revbayes.github.io/developer/tutorial Example of populated YAML front matter including title, subtitle, authors, and complexity level. ```yaml --- title: How to science subtitle: A postmodern experience authors: - Alice - Bob level: 0 --- ``` -------------------------------- ### Load Required Libraries Source: https://revbayes.github.io/tutorials/intro/revgadgets.html Load the necessary R packages for the tutorial. Ensure these are installed in your R environment before execution. ```R library(RevGadgets) library(coda) library(ggplot2) library(ggtree) library(grid) library(gridExtra) ``` -------------------------------- ### Set-Up and Run MCMC Source: https://revbayes.github.io/tutorials/morph_ase/corr.html Initializes the MCMC object with the model and monitors, then executes the simulation. ```RevBayes # Initialize the MCMC object # mymcmc = mcmc(mymodel, monitors, moves, nruns=2, combine="mixed") # Run the MCMC # mymcmc.run(generations=5000, tuningInterval=200) ``` -------------------------------- ### Define a Lognormal Distribution in Rev Source: https://revbayes.github.io/documentation/dnLognormal.html Example showing how to set parameters and initialize a lognormal distribution variable. ```Rev # set an expected value for x expectation_of_x <- 1 # set a mean and sd parameter sd <- 0.5 mean <- ln(expectation_of_x) - 0.5 * sd^2 # create a lognormal distribution with expected value of 1 x ~ dnLognormal(mean=mean, sd=sd) ``` -------------------------------- ### Constructing the FMutSel0 model Source: https://revbayes.github.io/documentation/fnFMutSel0.html Example demonstrating the initialization of parameters and the construction of the FMutSel0 rate matrix compared to an alternative model construction. ```Rev er ~ dnDirichlet( v(1,1,1,1,1,1) ) nuc_pi ~ dnDirichlet( rep(2.0, 4) ) F ~ dnIID(20, dnNormal(0,1)) omega ~ dnUniform(0,1) # The FMutSel0 model from Yang and Nielsen (2008) Q1 := fnFMutSel0(fnGTR(er, nuc_pi), F, omega) # The same -- fMutSel0 = GTR(er,nuc_pi) + X3 + MutSel(F) + dNdS(omega) Q2 := fndNdS( fnMutSelAA( fnX3( fnGTR(er, nuc_pi)), F), omega) ``` -------------------------------- ### Configure MCMC Stationarity Stopping Rule Source: https://revbayes.github.io/documentation/srStationarity.html Example demonstrating the setup of a binomial model and the application of the srStationarity stopping rule within an MCMC run. ```Rev # Binomial example: estimate success probability given 7 successes out of 20 trials r ~ dnExp(10) p := Probability(ifelse(r < 1, r, 1)) n <- 20 k ~ dnBinomial(n, p) k.clamp(7) mymodel = model(k) moves = VectorMoves() moves.append( mvSlide(r, delta=0.1, weight=1) ) paramFile = "parameters.log" monitors = VectorMonitors() monitors.append( mnModel(filename=paramFile, printgen=100, p) ) # Stop when stationarity has been attained at confidence level gamma = 0.25 stopping_rules[1] = srStationarity(prob = 0.25, file = paramFile, freq = 1000) # Create the MCMC object # Set nruns = 2 to ensure the stationarity statistic is applicable mymcmc = mcmc(mymodel, monitors, moves, nruns = 2) # Begin the MCMC run mymcmc.run(rules = stopping_rules) ``` -------------------------------- ### Read MCMC log files Source: https://revbayes.github.io/documentation/readTrace.html Examples demonstrating how to load single or multiple log files into trace objects. ```Rev # read in a single log file as a vector of traces traces = readTrace("out.log", burnin=0.5) # read in two log files called 'out_run_1.log', 'out_run_2.log' traces = readTrace("out.log", burnin=0.5, nruns=2) ``` -------------------------------- ### Install RevGadgets and ggtree Dependencies Source: https://revbayes.github.io/tutorials/sse/bisse.html Installs necessary R packages for visualization. ```R install.packages("devtools") library(devtools) install_github("GuangchuangYu/ggtree") install_github("revbayes/RevGadgets") ``` -------------------------------- ### Install Revticulate package Source: https://revbayes.github.io/interfaces Use the remotes package to install Revticulate from GitHub. ```r remotes::install_github("revbayes/Revticulate") ``` -------------------------------- ### Install YCM dependencies Source: https://revbayes.github.io/developer/setup Install required system packages for YouCompleteMe on Ubuntu 16.04. ```bash sudo apt-get install build-essential cmake python-dev python3-dev clang ``` -------------------------------- ### Download Tutorial Data Source: https://revbayes.github.io/workshops/woodshole2019 Use wget to retrieve specific data files required for workshop tutorials. ```bash wget https://revbayes.github.io/tutorials/fbd/data/bears_cytb.nex ``` -------------------------------- ### Configure Output Paths Source: https://revbayes.github.io/tutorials/host_rep/host_rep.html Set up output directory and filename strings. ```Rev out_str = "out.time" out_fn = "output/" + out_str ``` -------------------------------- ### Install RevGadgets via devtools Source: https://revbayes.github.io/tutorials/intro/revgadgets.html Use devtools to install the package directly from the GitHub repository. ```R install.packages("devtools") devtools::install_github("cmt2/RevGadgets") ``` -------------------------------- ### Initialize and Run MCMC Analysis Source: https://revbayes.github.io/documentation/mcmc.html Demonstrates creating a model, setting up moves and monitors, running an MCMC analysis, and resuming from a checkpoint. ```Rev # Create a simple model (unclamped) a ~ dnExponential(1) mymodel = model(a) # Create a move vector and a monitor vector moves[1] = mvScale( a, lambda = 1.0, weight = 1.0 ) monitors[1] = mnFile( a, filename = "output/out.log" ) # Create an mcmc object mymcmcObject = mcmc( mymodel, monitors, moves ) # Run a short analysis mymcmcObject.burnin( generations = 400, tuningInterval = 100 ) mymcmcObject.run( generations = 400, checkpointFile = "output/out.ckp", checkpointInterval = 100 ) # print the summary of the operators (now tuned) mymcmcObject.operatorSummary() # Resume analysis from the checkpoint file mymcmcObject.initializeFromCheckpoint( "output/out.ckp" ) # Conduct an additional 400 generations mymcmcObject.run( generations = 400 ) # Stopping rules are defined on the total number of generations # This command will have no effect, as 400 generations have already been performed. mymcmcObject.run( rules = [ srMaxIteration(400) ] ) ``` -------------------------------- ### Constructing FMutSel and related models Source: https://revbayes.github.io/documentation/fnFMutSel.html Demonstrates the initialization of parameters and the construction of the FMutSel model compared to a standard dNdS approach. ```Rev er ~ dnDirichlet( v(1,1,1,1,1,1) ) nuc_pi ~ dnDirichlet( rep(2.0, 4) ) F ~ dnIID(61, dnNormal(0,1)) omega ~ dnUniform(0,1) # The FMutSel model from Yang and Nielsen (2008) Q1 := fnFMutSel(fnGTR(er, nuc_pi), F, omega) # The same -- fMutSel = GTR(er,nuc_pi) + X3 + MutSel(F) + dNdS(omega) Q2 := fndNdS(fnMutSel(F, fnX3(fnGTR(er, nuc_pi))), omega) ``` -------------------------------- ### Modularize Tutorial Content Source: https://revbayes.github.io/developer/tutorial Include external Markdown files into a main tutorial page using the include_relative Liquid tag. ```markdown This is an external *Markdown* file without [YAML](http://camel.readthedocs.io/en/latest/yamlref.html) front matter. This *file* will be __formatted__ ~~as plain text~~ like the rest of the main text. You can even include $\LaTeX$. ``` ```liquid {% include_relative external_file.md %} ``` -------------------------------- ### Install and run RevBayes development version Source: https://revbayes.github.io/compile-spack Install the development branch of RevBayes with or without MPI support. ```bash spack install revbayes@develop ~mpi spack load revbayes rb ``` ```bash spack install revbayes@develop +mpi spack load revbayes mpirun rb-mpi ``` -------------------------------- ### Link Between Tutorials Source: https://revbayes.github.io/developer/tutorial Reference other tutorials using Liquid tags or filters to maintain consistent navigation. ```liquid This is a reference to the {% page_ref intro %} tutorial. {% assign var = "ctmc" %} This how to link to the {% page_ref {{ var }} %} tutorial using a liquid variable, {% assign tut = "clocks/simple" | match_page %} This is how to retrieve the *{{ tut.title }}* tutorial page by name. The relative URL of the `{{ var }}` tutorial is `{% page_url {{ var }} %}`. ``` -------------------------------- ### Install Revticulate via CRAN Source: https://revbayes.github.io/tutorials/tutorial_structure Standard installation method for the Revticulate package using the R package manager. ```R install.packages("Revticulate") ``` -------------------------------- ### Install R packages for Revticulate Source: https://revbayes.github.io/interfaces Install the necessary R packages to enable RevBayes integration within RStudio. ```r install.packages("remotes") install.packages("usethis") ``` -------------------------------- ### Initialize Model and Data for Simulation Source: https://revbayes.github.io/tutorials/pps_morpho Sets up the input file, analysis name, and model parameters required for morphological data simulation. ```Rev inFile = "data/Agnolin_2007a_paleobiodb.nex" analysis_name = "pps_morpho_example" morpho <- readDiscreteCharacterData(inFile) model_name = "Mk" num_states ="4" source( model_file_name ) ``` -------------------------------- ### Create and run a Docker container Source: https://revbayes.github.io/tutorials/docker Initializes a new container with a mounted host directory for file persistence. ```bash ~ $ ### from terminal on my Mac laptop (host) ~ $ # create and run new Docker container ~ $ docker run --name phylodocker_demo \ --volume /Users/mlandis/projects/docker_test:/docker_test \ -it sswiston/phylo_docker:full_amd64 \ /bin/sh ``` -------------------------------- ### Clone and install RevBayes Jupyter Kernel Source: https://revbayes.github.io/interfaces Commands to clone the kernel repository and install it for use in Jupyter Notebooks. ```bash git clone https://github.com/revbayes/revbayes_kernel.git ``` ```bash sudo python3 setup.py install python3 -m revbayes_kernel.install pip3 install metakernel ``` -------------------------------- ### Simulate a tree with dnCBDSP Source: https://revbayes.github.io/documentation/dnCBDSP.html Demonstrates initializing process parameters and simulating a tree using the dnCBDSP distribution. ```Rev # draw basic process parameters taxa <- [taxon("A"), taxon("B"), taxon("C"), taxon("D"), taxon("E")] root_age ~ dnUniform(0, 2) root_lambda ~ dnUniform(0, 1) root_mu ~ dnUniform(0, 1) sampling_prob <- 1 # simulate tree tree ~ dnCBDSP(rootAge = root_age, rootLambda = root_lambda, rootMu = root_mu, delta = 0.2, rho = sampling_prob, condition = "survival", taxa = taxa) ``` -------------------------------- ### Install CMake via Homebrew Source: https://revbayes.github.io/developer/setup Use this command to install the CMake build tool on macOS via Homebrew. ```bash brew install cmake ``` -------------------------------- ### Install and run RevBayes stable version Source: https://revbayes.github.io/compile-spack Install the latest stable release of RevBayes with or without MPI support. ```bash spack install revbayes ~mpi spack load revbayes rb ``` ```bash spack install revbayes +mpi spack load revbayes mpirun rb-mpi ``` -------------------------------- ### Monitor and Run MCMC Source: https://revbayes.github.io/tutorials/coalescent/GMRF.html Sets up file and screen monitors, initializes the MCMC object, and executes the analysis. ```Rev monitors.append( mnModel(filename="output/horses_iso_GMRF.log",printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_iso_GMRF.trees",psi,printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_iso_GMRF_NEs.log",population_size,printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_iso_GMRF_times.log",interval_times,printgen=THINNING) ) monitors.append( mnScreen(population_size, root_age, printgen=100) ) mymcmc = mcmc(mymodel, monitors, moves) mymcmc.burnin(NUM_MCMC_ITERATIONS*0.1,100) mymcmc.run(NUM_MCMC_ITERATIONS, tuning = 100) ``` -------------------------------- ### Set Starting Tree Values Source: https://revbayes.github.io/tutorials/biogeo/biogeo_dating.html Initializes the tree and root age with a starting tree to ensure non-zero likelihood. ```Rev tree.setValue(tree_init) root_age.setValue(tree_init.rootAge()) ``` -------------------------------- ### Manage Tutorial Files Source: https://revbayes.github.io/developer/tutorial Include or exclude specific files from the Data files and scripts box using YAML front matter attributes. ```yaml include_files: - ctmc/data/primates_and_galeopterus_cytb.nex exclude_files: - data/useless_file.nex ``` -------------------------------- ### Install ImageMagick dependency Source: https://revbayes.github.io/tutorials/intro/revgadgets.html Install the external ImageMagick software required by the magick R package dependency on macOS or Linux. ```bash brew install imagemagick ``` -------------------------------- ### Geometric Random Walk MCMC Setup Source: https://revbayes.github.io/documentation/mvRandomGeometricWalk.html Demonstrates initializing a geometric distribution variable and configuring the move within an MCMC analysis. ```Rev p <- 0.8 x ~ dnGeom(p) moves[1] = mvRandomGeometricWalk(x, weight=1.0) monitors[1] = mvScreen(printgen=1000, x) mymodel = model(p) mymcmc = mcmc(mymodel, monitors, moves) mymcmc.burnin(generations=20000,tuningInterval=100) mymcmc.run(generations=200000) ``` -------------------------------- ### Define Modular Tutorial Structure Source: https://revbayes.github.io/developer/tutorial Organize tutorial components into a directory structure where only the main entry points contain YAML front matter. ```text new_tutorial ├── data/ ├── scripts/ ├── figures/ ├── modules/ <-- module files (no front matter) │ ├── intro.md │ ├── exercise1.md │ ├── exercise2.md │ └── exercise3.md ├── new_tutorial.md <-- tutorial page (with front matter) └── v2.md <-- tutorial page (with front matter) ``` -------------------------------- ### Setup and run MCMC simulation Source: https://revbayes.github.io/tutorials/pomos Initializes the MCMC object with the model, monitors, and moves, then executes the simulation for a specified number of generations. ```RevBayes pomo_mcmc = mcmc(pomo_model, monitors, moves, nruns=2, combine="mixed") ``` ```RevBayes pomo_mcmc.run( generations=100000 ) ``` -------------------------------- ### Install build dependencies on CentOS 8 Source: https://revbayes.github.io/compile-linux Use the yum package manager to install development tools, CMake, and Boost development headers. ```bash sudo yum group install "Development Tools" sudo yum install cmake boost-devel ``` -------------------------------- ### Configure MCMC Monitors and Run Source: https://revbayes.github.io/tutorials/coalescent/GMRF_treebased.html Set up model monitors and execute the MCMC analysis. ```Rev monitors.append( mnModel(filename="output/horses_iso_GMRF_treebased.log",printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_iso_GMRF_treebased_NEs.log",population_size,printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_iso_GMRF_treebased_times.log",interval_times,printgen=THINNING) ) monitors.append( mnScreen(population_size, printgen=100) ) mymcmc = mcmc(mymodel, monitors, moves) mymcmc.burnin(NUM_MCMC_ITERATIONS*0.1,100) mymcmc.run(NUM_MCMC_ITERATIONS, tuning = 100) ``` -------------------------------- ### Example distance matrix Source: https://revbayes.github.io/tutorials/biogeo/biogeo_epoch.html Sample content of a distance matrix file. ```Text 001 145 239 419 145 001 059 239 239 059 001 082 419 239 082 001 ``` -------------------------------- ### Example connectivity matrix Source: https://revbayes.github.io/tutorials/biogeo/biogeo_epoch.html Sample content of an area connectivity file. ```Text 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 ``` -------------------------------- ### Initialize MCMC loop Source: https://revbayes.github.io/tutorials/mcmc/binomial.html Define the number of repetitions and start the iteration loop. ```R # Write the MH algorithm reps = 10000 for(rep in 1:reps){ ``` -------------------------------- ### Create and run a model analysis Source: https://revbayes.github.io/documentation/model.html Demonstrates initializing a model, generating a graph visualization, setting up MCMC components, and running an analysis. Note that workspace variables remain unchanged after the analysis. ```Rev # Create a simple model (unclamped) a ~ dnExponential(1) b ~ dnExponential(a) mymodel = model(b) # equivalent to model(a) or model(a, b) # Save a DOT visualization of the model to file mymodel.graph("mymodel.dot") # Create a move vector and a monitor vector moves = [ mvScale( a, lambda = 1.0, weight = 1.0 ) ] monitors = [ mnScreen(printgen = 10, a) ] # Create an mcmc object mymcmcObject = mcmc( mymodel, monitors, moves ) # Print value of a print(a) # Run a short analysis mymcmcObject.run( generations = 100 ) print(a) # Value is unchanged in the workspace - only the copy is modified ``` -------------------------------- ### Start GDB debugging Source: https://revbayes.github.io/developer/setup Launch the RevBayes executable within the GDB debugger. ```bash gdb rb ``` -------------------------------- ### MCMC Burn-in Output Source: https://revbayes.github.io/tutorials/pps_morpho Example console output during the MCMC burn-in phase. ```text Running burn-in phase of Monte Carlo sampler for 200 iterations. This simulation runs 2 independent replicates. The simulator uses 4 different moves in a random move schedule with 30.7 moves per iteration Progress: 0---------------25---------------50---------------75--------------100 ******************************************************************** ``` -------------------------------- ### Initialize and Run HillClimber Analysis Source: https://revbayes.github.io/documentation/HillClimber.html Demonstrates setting up a model, defining moves and monitors, and executing a HillClimber analysis. ```Rev # Create a simple model (unclamped) a ~ exponential(1) mymodel = model(a) # Create a move vector and a monitor vector moves[1] = mvScale(a, lambda=1.0, weight=1.0) monitors[1] = mnFile(a,"output/out.log") # Create an HillClimber object myHillClimberObject = HillClimber( mymodel, monitors, moves) # Run a short analysis myHillClimberObject.burnin( generations = 400, tuningInterval = 100) myHillClimberObject.run( generations = 400) # print the summary of the operators (now tuned) myHillClimberObject.operatorSummary() ``` -------------------------------- ### Set Working Directory Source: https://revbayes.github.io/tutorials/fbd_simple Changes the current working directory to the location of the tutorial files. ```Rev setwd("/RB_FBD_Tutorial") ``` -------------------------------- ### Display Summary Output Source: https://revbayes.github.io/tutorials/intro/revgadgets.html Example of the console output generated by the summarizeTrace function. ```text $`pi[1]` $`pi[1]`$trace_1 mean median MAP 0.3280593 0.3282250 0.3265728 quantile_2.5 quantile_97.5 0.3080363 0.3481651 ... $`pi[4]` $`pi[4]`$trace_1 mean median MAP 0.2152190 0.2145595 0.2144797 quantile_2.5 quantile_97.5 0.2020019 0.2278689 ``` -------------------------------- ### Get Number of Taxa Source: https://revbayes.github.io/tutorials/sse/bisse.html Extracts the number of sampled species from the phylogeny object. ```Rev num_taxa <- observed_phylogeny.ntips() ``` -------------------------------- ### Create instruction box Source: https://revbayes.github.io/developer/tutorial Use the {:.instruction} class to create an instruction callout. ```markdown > Lorem ipsum dolor sit amet, consectetur adipiscing elit, > sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. {:.instruction} ``` -------------------------------- ### Run a RevBayes terminal Source: https://revbayes.github.io/developer/docker Starts a RevBayes terminal session within a temporary container. ```bash docker run –rm -it docker.pkg.github.com/wadedismukes/revbayes-dockerfiles/revbayesdockerfiles:ubuntu-latest ``` -------------------------------- ### Create Bash Profile Source: https://revbayes.github.io/compile-osx Initialize a .bash_profile file in your home directory if it does not exist. ```bash cd ~ touch .bash_profile nano .bash_profile ``` -------------------------------- ### Initialize Model and MCMC Source: https://revbayes.github.io/tutorials/biogeo/biogeo_simple.html Create the model object and execute the MCMC analysis. ```Rev mymodel = model(m_bg) ``` ```Rev mymcmc = mcmc(mymodel, moves, monitors) mymcmc.run(3000) ``` -------------------------------- ### Example Covarion Rate Matrix Output Source: https://revbayes.github.io/tutorials/morph/morph_more.html Displays the resulting rate matrix structure. ```text [ [ -1.1126, 0.8901, 0.2225, 0.0000 ] , 0.8901, -1.1126, 0.0000, 0.2225 ] , 0.4451, 0.0000, -1.0385, 0.5934 ] , 0.0000, 0.4451, 0.1978, -0.6429 ] ] ``` -------------------------------- ### View Ancestral States Output Source: https://revbayes.github.io/tutorials/morph_ase/ase.html Example format of the ancestral states output file. ```text Iteration end_1 end_2 end_3 end_4 end_5 ... 0 0 0 1 0 1 ... 1 0 0 1 0 1 ... 2 0 0 0 0 1 ... 3 0 0 1 0 1 ... 4 0 0 1 0 1 ... 5 0 0 0 1 1 ... 6 0 0 1 0 1 ... 7 0 1 1 0 1 ... 8 0 0 1 1 1 ... 9 0 0 0 0 1 ... 10 0 0 1 0 1 ... ... ``` -------------------------------- ### Example Output Log Source: https://revbayes.github.io/tutorials/fbd_simple Displays the console output generated during the execution of the MCMC simulation. ```text Processing file "FBD_tutorial.Rev" Successfully read one character matrix from file 'data/bears_morphology.nex' Running MCMC simulation This simulation runs 1 independent replicate. The simulator uses 11 different moves in a random move schedule with 84 moves per iteration ... ``` -------------------------------- ### Initialize and run an MCMCMC analysis Source: https://revbayes.github.io/documentation/mcmcmc.html Demonstrates creating a model, defining moves and monitors, initializing the mcmcmc object, and executing the analysis. ```Rev # Create a simple model (unclamped) a ~ dnExponential(1) mymodel = model(a) # Create a move vector and a monitor vector moves[1] = mvScale(a, lambda=1.0, weight=1.0) monitors[1] = mnFile(a,"output/out.log") # Create an mcmcmc object myMcmcmcObject = mcmcmc( mymodel, monitors, moves, nchains=4, deltaHeat=5) # Run a short analysis myMcmcmcObject.burnin( generations = 400, tuningInterval = 100) myMcmcmcObject.run( generations = 400) # print the summary of the operators (now tuned) myMcmcmcObject.operatorSummary() ``` -------------------------------- ### HSMRF Prior Initialization Source: https://revbayes.github.io/tutorials/stairwayplot Initial setup for Horseshoe Markov Random Field priors. ```Rev avmvn = mvAVMVN(weight=100) log_theta_at_present ~ dnUniform(-20,2) log_theta_at_present.setValue( ln( 0.001 ) ) moves.append( mvSlideBactrian(log_theta_at_present,weight=5) ) avmvn.addVariable(log_theta_at_present) ## Global shrinkage parameter global_scale_hyperprior <- 0.021 ``` -------------------------------- ### Setup dnAutocorrelatedEvent Distribution Source: https://revbayes.github.io/tutorials/coalescent/Skyfish Configure the distribution combining population sizes and interval change-points. ```Rev events ~ dnAutocorrelatedEvent(eventDistribution = dnPoisson(lambda=10), valueDistribution =[dnUniform(0.0,MAX_AGE), dnLognormal( ln(EXPECTED_POP_SIZE), sd=2*H )], names=["time","theta"], minNumberEvents=[0,1], autocorrelationTypes=["NONE","ACLN"], autocorrelationDependencies=["none","time"], autocorrelationSigmas=[0,ac_sigma], sort = "time") ``` -------------------------------- ### Read the tree and initialize variables Source: https://revbayes.github.io/tutorials/divrate/env.html Load the observed tree and initialize the containers for moves and monitors. ```Rev T <- readTrees("data/primates_tree.nex")[1] ``` ```Rev taxa <- T.taxa() ``` ```Rev moves = VectorMoves() monitors = VectorMonitors() ``` -------------------------------- ### Compile YCM plugin Source: https://revbayes.github.io/developer/setup Run the installation script to compile the YCM component with Clang support. ```bash cd YouCompleteMe/ ./install.py --clang-completer ``` -------------------------------- ### Initialize moves and monitors Source: https://revbayes.github.io/tutorials/biogeo/biogeo_epoch.html Create containers for tracking MCMC moves and monitors. ```Rev moves = VectorMoves() monitors = VectorMonitors() ``` -------------------------------- ### Manage specific RevBayes versions Source: https://revbayes.github.io/compile-spack Install a specific version of RevBayes or list all available versions. ```bash spack install revbayes@1.0.12 ~mpi. ``` ```bash spack info revbayes ``` -------------------------------- ### Initialize and Run MCMC Source: https://revbayes.github.io/tutorials/sse/fossils.html Create the MCMC object and execute the run with optional stopping rules and checkpointing. ```Rev mymcmc = mcmc(mymodel, monitors, moves) ``` ```Rev stopping_rules[1] = srMinESS(250, file = "output/canidae_diet_bisse.log", freq = 10000) ``` ```Rev mymcmc.run(rules = stopping_rules, checkpointInterval = 1000, checkpointFile = "output/canidae_diet_bisse.state") ``` ```Rev mymcmc.initializeFromCheckpoint("output/canidae_diet_bisse.state") ``` -------------------------------- ### Initialize MCMC Parameters Source: https://revbayes.github.io/tutorials/mcmc/poisson.html Set starting values for the chain, ensuring they result in a valid likelihood. ```Rev alpha[1] <- -0.01 # you can also use runif(-1.0,1.0) beta[1] <- -0.01 # you can also use runif(-1.0,1.0) ``` -------------------------------- ### Configure Monitors Source: https://revbayes.github.io/tutorials/coalescent/heterochronous Set up model, file, and screen monitors to track parameters and output. ```Rev monitors.append( mnModel(filename="output/horses_het_Constant.log",printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_het_Constant.trees",psi,printgen=THINNING) ) monitors.append( mnFile(filename="output/horses_het_Constant_NE.log",pop_size,printgen=THINNING) ) monitors.append( mnScreen(pop_size, root_age, printgen=100) ) ``` -------------------------------- ### Generate Rate Matrices with fnFreeK Source: https://revbayes.github.io/documentation/fnFreeK.html Examples demonstrating the creation of 2-by-2 and 3-by-3 rate matrices using vector and matrix inputs, with and without normalization. ```Rev # Define vector to pass, this will create a 2-by-2 matrix x <- v(0.5, 0,5) # Use fnFreeK to create rate matrix # Note the second argument is true in this case so rates will be normalized fnFreeK(x) [ [ -1.0000, 1.0000 ] , [ 1.0000, -1.0000 ] ] # Case where rates are not normalized x <- v(0.5, 0.5) fnFreeK(x, false) [ [ -0.5000, 0.5000 ] , [ 0.5000, -0.5000 ] ] # Define matrix for 3-by-3 rate matrix object x <- v([0, .6, .4], [.2, 0, .4], [.3, .3, 0]) # Create rate matrix object fnFreeK(x) [ [ -1.0000, 0.6000, 0.4000 ] , [ 0.2000, -0.6000, 0.4000 ] , [ 0.3000, 0.3000, -0.6000 ] ] ```