Skip to main content
Texas Tech University

Mr.Bayes

Introduction

MrBayes is a program for Bayesian inference and model choice across a wide range of phylogenetic and evolutionary models. MrBayes uses Markov chain Monte Carlo (MCMC) methods to estimate the posterior distribution of model parameters.

Running MrBayes in HPCC

Prepare MrBayes to run as a batch job on CPU nodes

By default, MrBayes runs in interactive mode, which doesn’t work in batch job submission mode. However, it accepts a text file with all the commands that need to be passed as standard input. For that, please create and open a text file and add the sequence of commands that you need to pass to MrBayes in your batch job, and make sure to add quit as the very last command:

vi mb_batch.txt:

set autoclose=yes nowarnings=yes
execute primates.nex
quit
Prepare MrBayes to run as a batch job on CPU nodes

MrBayes can also run on GPU nodes when compiled with Beagle. To prepare a MrBayes job on a GPU node, open a text file and add the following sequence of commands. Please note that the following Beagle parameters are important to set, as explained below:

vi mb_gpu_batch.txt:

set usebeagle=yes beagledevice=gpu
set beagleprecision=single beaglescaling=dynamic
execute input.nex
quit
Submitting a MrBayes batch job

Create a job submission script with the following content as a reference:

#!/bin/bash 
#SBATCH --job-name=mrbayes_nocona 
#SBATCH --output=%x.o%j 
#SBATCB --error=%x.e%j 
#SBATCH --partition=nocona 
#SBATCH --nodes=1 
#SBATCH --ntasks-per-node=4 
#SBATCH --time=10:00:00 

module load gcc/14.2.0 openmpi/5.0.5 mrbayes/3.2.7a-mpi

MRBAYES_CHAINS=4

mpirun -np $MRBAYES_CHAINS mb input.nex
#!/bin/bash 
#SBATCH --job-name=mrbayes_nocona 
#SBATCH --output=%x.o%j 
#SBATCB --error=%x.e%j 
#SBATCH --partition=nocona 
#SBATCH --nodes=1 
#SBATCH --ntasks-per-node=4 
#SBATCH --time=10:00:00

module load gcc/14.2.0 openmpi/4.1.6 mrbayes/3.2.7a-mpi

MRBAYES_CHAINS=4

mpirun -np $MRBAYES_CHAINS mb input.nex

Important Note: The MPI version of MrBayes requires that the number of MPI ranks (--ntasks-per-node and-np) be equal to the number of chains. Otherwise, the MPI job will fail.

Then submit this job using the sbatch command. Please make sure to edit the following Slurm parameters as needed:

Number of nodes (--nodes): If you want to scale out your job across multiple worker nodes, please note that MrBayes can only scale across multiple nodes when the number of chains exceeds the number of available cores on the node where the job runs.

Number of MPI tasks (--ntasks-per-node): the parameter should always set to the number of chain defined in the input.

Wall time (--time): If your job won’t take longer than 10 hours, leave it as it is. Adjust the wall time based on how long you estimate your job will take.


Please contact HPCC support at hpccsupport@ttu.edu if you have any questions.