This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BAM file read stats (A/T/C/G/ins/del) for each base position

Hi all,

I have a bunch of Oxford Nanopore reads with a reference fasta. Wondering if anyone knows of any software / packages that would create some kind of csv or txt file that takes each base position in the reference sequence and determines how many A/T/G/C/del/ins etc for each read that covers the base. Looking for something like what JBrowse / IGV provides when you hover over a base, but for every base in the reference sequence and compiled in a txt or csv file that could be used to plot on a graph.

enter image description here

Already looked into samtools / vcftools / bbmap / alfred etc. but could be missing something in those. Appreciate any guidance!

sam bam nanopore jbrowse

2 answers

I've used perbase for this in the past:

https://github.com/sstadick/perbase

Dave - thank you so much!!! This is exactly what I was looking for. You rock!!

I had to spend a while searching for this excellent tool some time ago, so I'm happy to share that information!

samtools mpileup in.bam --fasta-ref ref.fa  |\
awk '{gsub(/[,\.]/,$3,$5);$5=toupper($5);A=$5;T=$5;C=$5;T=$5;print $1,$2,gsub(/[A]/,"",A),gsub(/[C]/,"",C),gsub(/[G]/,"",G),gsub(/[T]/,"",T);}' 

Log in to answer this question.