Data Management

Interpret SAM Flags Without Double-Counting Alignment Records

The decision

Use a flag audit before defining an alignment filter or interpreting a record count. Decide whether your intended unit is an alignment record, a read or a sequencing template. The same underlying read can have multiple records; bit decoding cannot establish deduplication or sample identity.

Build the audit

  1. Write the inclusion rule in words before selecting flags. For example, distinguish unmapped records from secondary mappings.
  2. Use decimal integer flags from synthetic examples. Retain the original value beside the decoded bits.
  3. Decode independent bits rather than treating the integer as a category code.
  4. Inspect the multiple-segment bit before interpreting pair-specific flags.
  5. Keep secondary and supplementary classifications separate. Counts of flag categories can overlap.
  6. Test the proposed filtering rule with records that have several bits set, then apply an established alignment tool to the actual file locally.

Worked hypothetical example

The invented value 99 decomposes into 64 + 32 + 2 + 1. Value 147 is 128 + 16 + 2 + 1. Value 260 is 256 + 4: it belongs to both the secondary and unmapped record counts. Across these three supplied records, there is one unmapped record and one secondary record, but adding these counts would not give two distinct records.

Avoid the wrong conclusion

A proper-pair bit reflects the aligner’s decision, not proof of biological truth. The absence of an unmapped bit does not prove a high-quality alignment. Reserved bits are shown for inspection rather than discarded. For multi-segment technologies, “first” and “last” are safer labels than assuming every template has exactly two reads.

Reporting example: “We decoded three synthetic alignment records; overlapping flag counts were not interpreted as unique-template counts.” Document the actual filter expression separately from this demonstration.

Sources and checking

Primary documentation, checked 2 December 2026. Examples are hypothetical. This page does not claim human expert review.

Open the sam flag interpretation audit.

Download the editable review worksheet.

Related reading

Reading path: Analyze data. Guide 244 of 252. Choose any guide to suit your project.

Statistical Methods

Audit Coordinate Alignment Without Hiding Scale Differences

Practical steps and a hypothetical example: Align matched coordinate configurations without changing scale.

Statistical Methods

Specify local-peak and plateau rules before counting events

A practical guide with worked examples: Identify local maxima and flat-peak positions before interpreting events.

Browse this reading pathTools for this stageGuides and downloads for this stage