annot-tsv(1)

πŸ“¦
version 1.24 Β· 4 versions
, in epel 10, nixpkgs unstable

🌸 annot-tsv β€” bestie's guide to transferring annotations πŸ’…

okay so real talk, this is annot-tsv from the htslib girlies (bioinformatics tools, iykyk) and it's literally the friend who introduces your two other friends because they should know each other. She takes annotations from one TSV file and slides them into another, no cap. 🫢

✨ NAME ✨

annot-tsv β€” transfer annotations from one TSV (tab-separated values) file into another. slay. that's it. that's the job. πŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

annot-tsv [OPTIONS]

🌈 DESCRIPTION 🌈

So the program finds overlaps in two sets of genomic regions (think two CNV call sets, like, the same regions but different files) and then annotates regions of the target file (-t, --target-file) with info from the overlapping regions of the source file (-s, --source-file). it's giving matchmaker energy fr fr. πŸ’…

She can transfer one or multiple columns (-f, --transfer), and she can make the transfer conditional on requiring matching values in one or more columns (-m, --match). and on top of the column transfer (-f) and the special annotations (-a, --annotate), she can also just vibe in a simple grep-like mode and print the matching lines (this happens when neither -f nor -a are given) β€” or, iconic behaviour, drop the matching lines (-x, --drop-overlaps). 😭

lowkey important: all indexes and coordinates are 1-based and inclusive. do not come for her with your 0-based nonsense. πŸŽ€

πŸ‘‘ OPTIONS πŸ‘‘

🌸 Common Options 🌸

  • -c, --core SRC:TGT β€” the list of names of the core columns, in the order of chromosome, start and end positions, and this is irrespective of the header name and order in which they appear in the source or target files. so like, "chr,beg,end:CHROM,START,END" β€” see how she doesn't care that they're spelled different? icon. ✨ if both files use the same header names, you can skip the TGT names entirely, like "chr,beg,end". if the SRC or TGT file has no header, you can hand her 1-based indexes instead, like "chr,beg,end:3,1,2". and ngl the best part: regions are not required β€” the program can work with a plain list of positions, like "chr,beg,end:CHROM,POS,POS". πŸ’–
  • -f, --transfer SRC:TGT β€” comma-separated list of columns to transfer. if the SRC column doesn't exist, she interprets it as the default value to fill in when a match is found β€” or a dot (".") when a match is not found. if the TGT column doesn't exist, a whole new column gets created (main character behaviour). if the TGT column already exists, its values will be overwritten when overlap is found and left as is otherwise. periodt. πŸ’…
  • -m, --match SRC:TGT β€” the columns required to be identical. like, they gotta be the same or she's not doing it. πŸŽ€
  • -o, --output FILE β€” output file name. by default the result is printed on standard output, which is honestly fine too. πŸ¦‹
  • -s, --source-file FILE β€” source file with annotations to transfer. the giver. πŸ’œ
  • -t, --target-file FILE β€” target file to be extend with annotations from -s, --source-file. the receiver. 🫢

🌟 Other options 🌟

  • --allow-dups β€” add the same annotations multiple times if multiple overlaps are found. yes she'll say it twice. she's committed. 😭
  • --help β€” this help message. hi bestie. 🌸
  • --max-annots INT β€” add at most INT annotations per column to save time when many overlaps are found with a single region. efficiency queen. ⭐
  • --version β€” print version string and exit. short and sweet. πŸŽ€
  • -a, --annotate LIST β€” add one or more special annotation and its target name separated by ':'. if no target name is given, the special annotation's name will be used in output header. the specials are:
    • cnt β€” number of overlapping regions πŸ”₯
    • frac β€” fraction of the target region with an overlap 🧚
    • nbp β€” number of source base pairs in the overlap πŸ’«
  • -d, --delim SRC:TGT β€” column delimiter in the source and the target file. for example, if both files are comma-delimited, run with "--delim ,:," or simply "--delim ,". if the source file is comma-delimited and the target file is tab-delimited, run with "-d $',:\t'". choose your fighter. 🌈
  • -h, --headers SRC:TGT β€” line number of the header row with column names. by default the first line is interpreted as header if it starts with the comment character ("#"), otherwise she expects numeric indices. but β€” plot twist β€” if the first line does not start with "#" but still contains the column names, use "--headers 1:1". to ignore an existing header (skip comment lines) and use numeric indices, use "--headers 0:0", which is equivalent to "--ignore-headers". and when a negative value is given, it's interpreted as the number of lines from the end of the comment block. specifically, "--headers -1" takes the column names from the last line of the comment block (e.g., the "#CHROM" line in the VCF format). she contains multitudes. πŸ’…
  • -H, --ignore-headers β€” ignore the headers completely and use numeric indexes even when a header exists. no thoughts, just numbers. πŸ™ˆ
  • -I, --no-hdr-idx β€” suppress index numbers in the printed header. if given twice, drop the entire header. gone. deleted. πŸ’€
  • -O, --overlap FLOAT,[FLOAT] β€” minimum overlap as a fraction of region length in SRC and TGT, respectively (that's with two numbers), or in at least one of the overlapping regions (with a single number). if also -r, --reciprocal is given, require at least FLOAT overlap with respect to both regions. two identical numbers are equivalent to running with -r, --reciprocal. math is mathing. πŸ“
  • -r, --reciprocal β€” require the -O, --overlap with respect to both overlapping regions. mutual effort only. πŸ’–
  • -x, --drop-overlaps β€” drop overlapping regions. cannot be combined with -f, --transfer β€” like, she literally cannot, don't ask. 🚫

🧚 EXAMPLE 🧚

both SRC and TGT input files must be tab-delimited files with or without a header, their columns can be named differently, and can appear in arbitrary order. she's flexible like that. πŸ’…

for example, consider the source file:

#chr   beg   end   sample   type   qual
chr1   100   200   smpl1    DEL    10
chr1   300   400   smpl2    DUP    30

and the target file:

150   200   chr1   smpl1
150   200   chr1   smpl2
350   400   chr1   smpl1
350   400   chr1   smpl2

in the first example we transfer type and quality but only for regions with matching sample. notice that the header is present in SRC but not in TGT, therefore we use column indexes for the latter. πŸŽ€

annot-tsv -s src.txt.gz -t tgt.txt.gz -c chr,beg,end:3,1,2 -m sample:4 -f type,qual
150   200   chr1   smpl1   DEL   10
150   200   chr1   smpl2   .     .
350   400   chr1   smpl1   .     .
350   400   chr1   smpl2   DUP   30

the next example demonstrates the special annotations nbp and cnt, with target name as pair,count. in this case we use a target file with headers so that column names will be copied to the output. 🌟

#from     to   chrom     sample
150  200  chr1 smpl1
150  200  chr1 smpl2
350  400  chr1 smpl1
350  400  chr1 smpl2
annot-tsv -s src.txt.gz -t tgt_hdr.txt.gz -c chr,beg,end:chrom,from,to -m sample -f type,qual -a nbp,cnt:pair,count
#[1]from  [2]to     [3]chrom  [4]sample [5]type   [6]qual   [7]pair   [8]count
150  200  chr1 smpl1     DEL  10   51   1
150  200  chr1 smpl2     .    .    0    0
350  400  chr1 smpl1     .    .    0    0
350  400  chr1 smpl2     DUP  30   51   1

one of the SRC or TGT file can be streamed from stdin. πŸ¦‹

cat src.txt | annot-tsv -t tgt.txt -c chr,beg,end:3,2,1 -m sample:4 -f type,qual -o output.txt
cat tgt.txt | annot-tsv -s src.txt -c chr,beg,end:3,2,1 -m sample:4 -f type,qual -o output.txt

the program can be used in a grep-like mode to print only matching regions of the target file without modifying the records. no edits, just vibes. πŸ”₯

annot-tsv -s src.txt -t tgt.txt -c chr,beg,end:3,2,1 -m sample:4
150   200   chr1   smpl1
350   400   chr1   smpl2

πŸ’œ AUTHORS πŸ’œ

the program was written by Petr Danecek and was originally published on github as annot-regs. we stan. πŸ‘‘βœ¨

πŸŽ€ COPYING πŸŽ€

The MIT/Expat License, see the LICENSE document for details.

Copyright (c) Genome Research Ltd.


okay that's the whole thing bestie, go annotate something. this page is from htslib-1.24, dated 9 July 2026 β€” she's fresh, she's iconic, she's annot-tsv(1). bye mwah πŸ’‹πŸ’–πŸŒΈ

πŸ“¦ where this page comes from