Compare
BAM vs CRAM
BAM is a BGZF-compressed alignment representation. CRAM uses reference differences and other encodings; preservation depends on writer settings.
Which format should you choose?
Consider BAM for broad tool compatibility, or CRAM to reduce storage when reference resolution and preservation settings can be managed.
Good fit for BAM
Storing and exchanging large read-alignment datasets in binary form · Querying coordinate-sorted data by region with an index
- Compressing SAM-compatible headers, records, and tags
- Using BGZF and BAI/CSI indexes with compatible tools
Good fit for CRAM
Store and exchange alignment data using reference-aware compression · Choose a preservation profile for qualities and other alignment fields
- Workflows that can identify and retrieve the exact reference
- Archives that document compression and preservation settings
Basic information
| Field | BAM | CRAM |
|---|---|---|
| Extension | .bam | .cram |
| MIME type | application/octet-stream | |
| Common uses | Storing and exchanging large read-alignment datasets in binary form · Querying coordinate-sorted data by region with an index | Store and exchange alignment data using reference-aware compression · Choose a preservation profile for qualities and other alignment fields |
| How to open | Use SAM/BAM-aware software. Check header reference names, lengths and identifiers, sort order, read and unmapped counts, FLAG/CIGAR, qualities, and tags. For regional access, use a BAI/CSI index made for that exact BAM and its sorting state. | Use CRAM-aware software. Inspect reference names, lengths, checksums or versions, the creating tool, and any documented preservation settings. Retrieve the matching reference locally or from a trusted registry if required. Use a CRAI index that matches the file for regional queries. |
| Export or convert | Converting BAM to SAM makes records readable but may greatly increase size. When converting SAM back to BAM, validate fields, tags, and order. CRAM conversion can depend on reference sequences and quality-preservation settings; retain the needed references. | When converting CRAM to BAM or SAM, resolve references correctly and verify whether qualities, tags, and read names are retained. Keep the source CRAM and compare record counts, statistics, and representative records. For BAM/SAM to CRAM, explicitly choose the reference version and whether lossy quality compression is acceptable. |
Choose by use case
Compressing SAM-compatible headers, records, and tags
Storing and exchanging large read-alignment datasets in binary form · Querying coordinate-sorted data by region with an index
BAMUsing BGZF and BAI/CSI indexes with compatible tools
Storing and exchanging large read-alignment datasets in binary form · Querying coordinate-sorted data by region with an index
BAMWorkflows that can identify and retrieve the exact reference
Store and exchange alignment data using reference-aware compression · Choose a preservation profile for qualities and other alignment fields
CRAMArchives that document compression and preservation settings
Store and exchange alignment data using reference-aware compression · Choose a preservation profile for qualities and other alignment fields
CRAMKey point 1
BAM decoding normally needs no external reference bases.
More on the differencesKey point 2
CRAM supports reference-dependent encoding and embedded references.
More on the differencesMore on the differences
Define which qualities and tags must survive, then test round trips and analysis results on real data. CRAM is not always smaller or faster.
- Reference-dependent CRAM decoding requires the correct reference. Distinguish external reference management, embedding and reference-free settings; handing over the file alone may not suffice.
- CRAM permits lossless and lossy preservation strategies. Region access requires suitable sorting and the index expected by the tool, such as CRAI.
Frequently asked questions
Does CRAM always preserve every detail?
No. Writer settings and tools matter. Verify quality values, optional tags, reference information and record counts; retain originals until validation is complete.