Skip to main content
v2026.11,986 entries · CC-BY 4.0

bcftools: What It Does, Core Commands and a Variant-Calling Pipeline

bcftools explained: VCF/BCF utilities, the mpileup | call pipeline, filtering, norm, merge vs concat vs isec, and common mistakes.

Written and maintained by CASRAI Editorial Board

Published

On this page

bcftools is a set of command-line utilities for manipulating variant calls stored in the Variant Call Format (VCF) and its binary counterpart BCF. It can call SNPs and indels from aligned reads, then filter, normalize, merge, intersect, annotate, query and summarize the resulting files. Every command accepts VCF or BCF, compressed or not, and is designed to be chained with Unix pipes.

Short answer

Use bcftools when you already have variant data (or aligned BAM/CRAM reads) and need to turn it into a clean, queryable VCF/BCF. The standard calling pipeline is bcftools mpileup -f reference.fa alignments.bam | bcftools call -mv -Ob -o calls.bcf, followed by quality filtering with bcftools view -i 'QUAL>=20'. The rest of the toolkit handles everything that happens to a VCF before and after calling.

What bcftools is

The bcftools manual describes the program as “a set of utilities that manipulate variant calls in the Variant Call Format (VCF) and its binary counterpart BCF”, and states that all commands work transparently with both formats, uncompressed or BGZF-compressed. It belongs to the same family as SAMtools and HTSlib, the library underneath both. A 2021 paper in GigaScience (“Twelve years of SAMtools and BCFtools”, Danecek et al.) reports that the software is freely available on GitHub under the permissive MIT licence, that the first version appeared twelve years before the paper, and that it has been installed more than one million times via Bioconda.

Two design points explain most of how people use it. First, commands are built to work on a stream: a hyphen (-) means standard input or output, so subcommands can be piped into each other. Second, operations that read several VCFs at once need them indexed, and an index requires the file to be compressed (BGZF). That is why multi-file workflows almost always start by compressing and indexing each file.

The data table below this article summarizes the the subcommands covered here, their purpose and their input requirements, as stated in the manual. If you are new to the formats involved, the CASRAI guide to the BAM index (.bai) file explains the alignment-side index that mpileup relies on for region queries.

How the mpileup and call pipeline works

Variant calling in bcftools is a two-step pipeline. The manual’s variant-calling how-to gives the basic form as bcftools mpileup -f reference.fa alignments.bam | bcftools call -mv -Ob -o calls.bcf.

Step 1: mpileup

bcftools mpileup generates a VCF or BCF containing genotype likelihoods for one or several alignment files (BAM or CRAM). It lives in bcftools rather than in samtools; the manual says it was moved “to avoid errors resulting from use of incompatible versions of samtools and bcftools”. Individuals are identified from the SM tags in the @RG read-group headers, so correct read-group metadata matters for multi-sample runs.

  • Regions: -r restricts the run to a region and needs an index; -t streams through targets without an index. The manual notes that -r can be slower than -t when there are many regions.
  • Depth cap: -d/--max-depth defaults to 250 reads per input file per position. The how-to advises raising it for deeper data.
  • Annotations: -a/--annotate adds optional tags such as FORMAT/AD, ADF, ADR, DP, SP and SCR. The manual marks DV and DP4 as deprecated.

Step 2: call

bcftools call turns likelihoods into variant calls. You must choose a calling model: the older -c/--consensus-caller or the newer -m/--multiallelic-caller. The manual states that the multiallelic model is recommended for most tasks. Other options used in the standard recipe:

  • -v outputs variant sites only.
  • -P sets the prior and works only with -m. The how-to gives the default as 1.1e-3; a smaller value is stricter and a larger one more permissive.
  • -O selects the output type: b compressed BCF, u uncompressed BCF, z compressed VCF, v uncompressed VCF.
  • --ploidy and --ploidy-file override ploidy; regions not listed default to ploidy 2.

When piping between bcftools subcommands, the manual recommends -Ou (uncompressed BCF), which avoids spending time compressing data that the next command immediately decompresses. Use a compressed type only for the file you intend to keep.

Filtering and normalizing variants

Quality filtering

The how-to uses expression-based filtering, for example bcftools view -i 'QUAL>=20' calls.bcf. To sanity-check a threshold it suggests looking at the transition/transversion ratio: bcftools filter -i'QUAL>20' calls.vcf.gz | bcftools stats | grep TSTV. Other metrics it lists as useful include read depth, the minimum number of high-quality non-reference reads and proximity to indels (bcftools filter -g).

The same page is explicit about limits. The QUAL value does not account for systematic biases such as collapsed paralogous copies, a filter tuned on one dataset may not transfer to another, and fixed-threshold filtering is described as the minimum approach. Machine-learning filters (an SVM is mentioned) are noted but not implemented in bcftools.

Normalization with norm

bcftools norm left-aligns and normalizes indels, checks whether REF alleles match the reference, splits multiallelic sites into multiple rows, and can recover multiallelic records from multiple rows. Four details are easy to miss:

  • Left-alignment and normalization are applied only when --fasta-ref is supplied.
  • -m - splits and -m + joins multiallelic sites; the argument can restrict this to snps, indels, both or any.
  • -a/--atomize decomposes multi-nucleotide variants into SNVs.
  • -c controls reference checking with four modes: exit, warn, exclude or set. The manual warns that s (set) will not fix strand issues.

Combining and comparing files: merge, concat, isec and norm

The most frequent bcftools mistake is picking the wrong combining command. The manual draws the lines this way:

  • merge combines files from non-overlapping sample sets (it adds sample columns). Only records from different files can be merged, never from the same file. If sample names collide it raises an error unless --force-samples is given, which prepends the file index to the name (for example 2:S3).
  • concat joins files that contain the same samples (it adds rows). For a vertical merge of records the manual points to concat or norm -m.
  • isec computes intersections, unions and complements of VCFs; the complement option (-C) gives positions present only in the first file.
  • norm -m splits or joins multiallelic records within a file.

When several VCFs are read simultaneously, all of them must be indexed and therefore compressed. bcftools index creates a CSI index by default (supporting chromosomes up to 231 in length); the -t option writes a TBI index instead (limited to 229). On loading, CSI is tried first.

Other subcommands worth knowing

The manual lists a wider command set than calling and filtering. Selected entries, with the manual’s own one-line purpose:

  • annotate edits a VCF, adding or removing annotations.
  • csq is a haplotype-aware consequence caller; for a different approach to consequence prediction see the ANNOVAR guide.
  • gtcheck checks sample concordance, sample swaps and contamination.
  • query extracts fields in a custom format, e.g. bcftools query -f '%CHROMt%POSt%REFt%ALT[t%SAMPLE=%GT]n' file.vcf.gz.
  • stats writes text output suitable for machine processing, plottable with plot-vcfstats; given two files it reports concordance statistics.
  • consensus, cnv, roh, polysomy, convert, reheader, sort, head and plugin cover consensus sequences, copy-number and runs-of-homozygosity analyses, format conversion, header edits, sorting and user plugins.

The project site also hosts how-tos for CNV, consequence, consensus and ROH calling, converting formats, adding annotation, extracting information, filter expressions, performance and scaling, and plugins.

Where it matters for lab workflows

In a sequencing workflow bcftools sits after alignment and before interpretation: reads are aligned to a reference, bcftools produces and cleans a VCF, and downstream tools annotate it. Because reference naming differs between builds, check which assembly your reads and your reference FASTA use; the CASRAI comparison of GRCh38, hg38 and b37 covers the naming differences. Variants from public cohorts such as the 1000 Genomes Project or the genome Aggregation Database (gnomAD) are commonly distributed as VCF, which bcftools can read directly.

For data management, record the bcftools version string (the manual itself identifies the documented build as git version 1.22-8, last updated 2025-06-17) together with the exact command line, reference file and filter thresholds, since the how-to states that thresholds tuned on one dataset may not transfer.

Common misunderstandings

  • “mpileup is part of samtools.” It was moved into bcftools so that the pileup and the caller come from matching versions.
  • “norm left-aligns indels automatically.” Only if you pass --fasta-ref.
  • “merge stacks two files of the same samples.” It does not; merge is for different samples. Same-sample files go through concat.
  • “A QUAL cutoff makes the call set clean.” The how-to says QUAL ignores systematic biases and treats fixed thresholds as a minimum.
  • “Compressed output is always better.” For intermediate pipe steps the manual recommends uncompressed -Ou.
  • “Old BCF files will work.” The obsolete BCF1 format produced by samtools 0.1.19 and earlier is not compatible.

Installing bcftools

The project’s installation page describes building from source: clone HTSlib (with --recurse-submodules) and bcftools from GitHub, optionally run autoheader && autoconf && ./configure --enable-libgsl --enable-perl-filters, then make. Plugins are found through the BCFTOOLS_PLUGINS environment variable, which must point at the plugins directory. The 2021 paper also notes availability through Bioconda.

FAQ

What is bcftools used for?

Calling, filtering, normalizing, merging, intersecting, annotating, querying and summarizing variants in VCF and BCF files.

Does bcftools work on both VCF and BCF?

Yes. The manual says all commands work transparently with VCF and BCF, uncompressed or BGZF-compressed.

Which calling model should I use?

The manual recommends the multiallelic model (-m) for most tasks.

Why does merging two VCFs fail?

Typically the files are not indexed (so not compressed), or they share sample names. Duplicate names produce an error unless --force-samples is used.

Is bcftools free to use?

It is available on GitHub under the MIT licence, per the 2021 GigaScience paper.

Sources

Data: bcftools subcommands: purpose, input requirements and documented caveats

Compiled from the official bcftools manual (git version 1.22-8, updated 2025-06-17): nine subcommands with their stated purpose, input requirements and caveats the manual documents.

Period covered: 2025.

bcftools subcommands: purpose, input requirements and documented caveats
SubcommandPurposeInput requirementDocumented caveat
mpileupGenotype likelihoods from BAM/CRAM alignmentsAlignment files; region (-r) needs an index, -t streams without oneMoved from samtools; default max depth 250 per file per position
callSNP and indel calling from likelihoodsOutput of mpileup; choose -m (recommended for most tasks) or -cDefault ploidy 2 for regions not listed; -P prior only with -m
normLeft-align and normalize indels, check REF, split or join multiallelicsSingle file; left-alignment only with --fasta-ref-c check-ref modes e, w, x, s; s does not fix strand issues
mergeCombine files from non-overlapping sample setsMultiple indexed (compressed) filesRecords merge only across files; duplicate sample names error without --force-samples
concatJoin files with the same samplesSame samples in every fileNamed in the manual as the vertical alternative to merge
isecIntersections, unions and complements of VCFsMultiple indexed (compressed) files-C gives positions only in the first file
indexCreate an index for VCF/BCFCompressed (BGZF) fileCSI by default (chromosomes up to 2^31); TBI with -t (up to 2^29)
statsSummary statistics, plottable with plot-vcfstatsOne file, or two for concordanceText output suitable for machine processing
gtcheckSample concordance, swaps and contaminationVCF/BCFListed as a quality-control command in the manual

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about bcftools: What It Does, Core Commands and a Variant-Calling Pipeline

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →