tag-bam
Quick Start
- Command:
tagBam -i reads.bam -files annot1.bed annot2.bed -labels A1 A2 > tagged.bam - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/tagBam - Full reference: See
references/help.md
When To Use This Tool
- Label reads by which annotation tracks they overlap.
- Populate BAM tags from file labels, annotation names, or annotation scores.
- Add interval-derived metadata to alignments before downstream filtering or QC.
- Apply same-strand or opposite-strand overlap rules while tagging.
Common Patterns
# 1) Tag reads by which annotation file they overlap
tagBam \
-i reads.bam \
-files genes.bed repeats.bed \
-labels GENE REP \
> tagged.bam
# 2) Populate the tag with the annotation name field on the same strand
tagBam \
-i reads.bam \
-files exons.bed \
-labels EXON \
-names \
-s \
> reads.named-tags.bam
# 3) Record full interval payloads for debugging or provenance
tagBam \
-i reads.bam \
-files loci.bed \
-labels LOCUS \
-intervals \
-tag YK \
> reads.interval-tags.bam
Recommended Workflow
- Choose the annotation files that define the tag source and decide whether the payload should be file labels, annotation names, scores, or full intervals.
- Choose the output tag name with
-tagif the defaultYBis not appropriate. - Add overlap and strand constraints with
-f,-s, or-Sbefore writing the tagged BAM stream to a new file. - Inspect a few records with a BAM viewer or
samtools viewto confirm the expected tags were attached.
Guardrails
-iand-filesare required, and you must also provide a tag payload source via-labels,-names, or-scores.-intervalsstill requires-labelsso the tool can record which annotation file contributed the interval.- The command writes BAM to stdout; redirect to a file or pipe into another BAM-aware tool.
- Custom tags supplied with
-tagmust be exactly two characters. - If you use
-labels, provide one label per annotation file. - Prefer
-hfor help; GNU-style--helpand--versionemit wrapper errors before usage text.