Thank you! What do you mean by 'no tested'? The only thing I don't understand is why Samtools provides a 1-based output when generally a Bam format file uses a 0-based coordinate system? Maybe it depends on the aligner?
Hello everyone, is there an option in samtools depth (or any other way) to obtain an output that considers 0-based coordinates? Or do I need to modify my BAM files and subtract 1 from each position? Thank you very much.
1 answer
no tested:
samtools depth in.bam | awk -F '\t' '{OFS="\t";$2=int($2)-1;print;}'
What do you mean by 'no tested'?
i did not test my command line. I hope it works.
What do you mean by 'no tested'?
Provided code should logically work but has not actually been tested in practice. You can do that and if something does not work the post back here.
I don't understand is why Samtools provides a 1-based output when generally a Bam format file uses a 0-based coordinate system?
Please see the discussion by developers here: https://github.com/samtools/samtools/issues/1063
Thank you very much for your explanation! It is well explained in the discussion.
SAM is 1 based https://samtools.github.io/hts-specs/SAMv1.pdf
1-based leftmost mapping POSition
BAM is ALWAYS 0 based. you don't look at the values in a BAM unless you're a programmer.
Log in to answer this question.