Skip to content

Freebayes

FreeBayes is a genetic variant detector designed to find small polymorphisms (SNPs, indels, MNPs and complex events).

FreeBayes is haplotype-based, in the sense that it calls variants based on the literal sequences of reads aligned to a particular target, not their precise alignment. This model is a straightforward generalization of previous ones (e.g. PolyBayes, samtools, GATK) which detect or report variants based on alignments. This method avoids one of the core problems with alignment-based variant detection, that identical sequences may have multiple possible alignments.

FreeBayes uses short-read alignments (BAM files) for any number of individuals from a population and a reference genome to determine the most-likely combination of genotypes for the population at each position in the reference. It reports positions which it finds putatively polymorphic in variant call file (VCF) format. It can also use an input set of variants (VCF) as a source of prior information, and a copy number variant map (BED) to define non-uniform ploidy variation across the samples under analysis.

License

Free to use and open source under MIT License.

Available

  • Roihu-CPU: 1.3.6, via the bio-apps module.

Usage

FreeBayes is part of the bio-apps collection on Roihu. Load the bio-apps module tree and then the FreeBayes module:

module load bio-apps/v202603
module load freebayes/1.3.6

After this you can launch FreeBayes. For example:

freebayes -f reference.fa input.bam > results.vcf

Note that FreeBayes requires a BAM file that is indexed. A BAM file can be indexed with the samtools index command (load the samtools module first):

module load samtools/1.21
samtools index input.bam

Running FreeBayes in parallel

FreeBayes itself uses one core. freebayes-parallel splits the genome into regions, runs FreeBayes on several regions at a time and merges the results into one VCF file. Make a list of regions from the reference index (samtools faidx reference.fa makes the index), here in 100 kb pieces, and give the number of parallel runs after the regions file:

fasta_generate_regions.py reference.fa.fai 100000 > regions.txt
freebayes-parallel regions.txt 16 -f reference.fa input.bam > results.vcf

Example batch script

FreeBayes analysis jobs can be computationally heavy and should be run as batch jobs on Roihu. Below is a sample batch job script:

#!/bin/bash
#SBATCH --job-name=freebayes
#SBATCH --account=<project>
#SBATCH --output=output_%j.txt
#SBATCH --error=errors_%j.txt
#SBATCH --time=24:00:00
#SBATCH --partition=small
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16
#SBATCH --mem=64G

module load bio-apps/v202603
module load freebayes/1.3.6

fasta_generate_regions.py reference.fa.fai 100000 > regions.txt
freebayes-parallel regions.txt $SLURM_CPUS_PER_TASK -f reference.fa input.bam > results.vcf

Replace <project> with your CSC project (for example project_2001234).

You can submit the batch job file to the batch job system with the command:

sbatch batch_job_file.sh

See creating a batch job script for Roihu for more information about running batch jobs.

Support

CSC Service Desk

More information

Do you find this page useful?
Thank you for your feedback!
Thank you! Your feedback is appreciated.

Please let us know how we could improve this page by contacting us or by creating an issue in GitHub. You can also edit this page yourself and contribute your improvements by creating a pull request.

November 2, 2026