samtools-addreplacerg(1)

πŸ’… samtools-addreplacerg β€” the read-group glow-up tool

Hey bestie, so this is from the samtools manual, page samtools-addreplacerg (like, the whole samtools suite, but this specific little icon). It's the one you call when your BAM file's read groups are looking a mess and you need to fix the vibes. ✨


🌸 NAME 🌸

samtools addreplacerg β€” adds or replaces read group tags. That's it, that's the whole job. It adds them, it replaces them, it slays.


πŸŽ€ SYNOPSIS πŸŽ€

samtools addreplacerg [-r rg-line | -R rg-ID] [-m mode] [-u] [-o
out.bam] in.bam

πŸ’– DESCRIPTION πŸ’–

Okay so picture this: you've got a file, and its read group tags are either missing or just not it. This command adds or replaces read group tags in a file. And because it's an overachiever, it also lets you add and update the @RG lines up in the header. Both. At once. Main character energy honestly. πŸ‘‘


✨ OPTIONS ✨

  • -r STRING β€” lets you specify a read group line to append to the header, and then it applies that to the reads picked out by the -m option. And here's the cute part: if you repeat it, it automatically adds tabs between invocations. No cap, it just does it for you. 🫢
  • -R STRING β€” lets you specify the read group ID of an existing @RG line, and it applies that to the reads you specified.
  • -m MODE β€” picks the mode, bestie. If you choose orphan_only then existing RG tags are not overwritten. If you choose overwrite_all, existing RG tags are overwritten. The default is overwrite_all.
  • -o STRING β€” writes the final output to STRING. The default is to write to stdout. Also, by default, samtools tries to select a format based on the output filename extension; if the output is going to standard output, or if no format can be deduced, sam is selected.
  • -u β€” output uncompressed SAM, BAM or CRAM. Straight up, no compression, raw vibes.
  • -w β€” overwrite an existing @RG line, but only if a new one with the same ID value is provided. Conditional icon. πŸ’…
  • --no-PG β€” do not add a @PG line to the header of the output file. If you don't want that line, you don't get that line.
  • -@, --threads INT β€” number of input/output compression threads to use in addition to the main thread. Default is [0]. Give it more threads if you're feeling impatient. πŸ”₯

πŸ‘‘ AUTHOR πŸ‘‘

Written by Martin Pollard from the Sanger Institute. Respect the author, fr fr.


🌈 SEE ALSO 🌈

Samtools website: <http://www.htslib.org/>


ngl bestie, this one's pretty forgiving β€” but remember overwrite_all is the default, so if you didn't want your existing RG tags clobbered, you gotta say orphan_only out loud. Choose your mode deliberately, okay? 😭

That's the whole page! Shoutout to samtools-1.24, dated 9 July 2026 β€” that's the version and date this little diva came from. Go forth and tag your reads. πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from