annot-tsv(1)
πΈ 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,--reciprocalis 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,--overlapwith 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
- epel 10: htslib-tools 1.24-1.el10_3 Β· MIT AND BSD-3-Clause AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: htslib 1.24
- Copyright (C) 2015, 2017-2018, 2023-2024 Genome Research Ltd
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms