I recently downloaded Tablet to assess read coverage of my de novo assembly of RNA-Seq of marine snail venom duct tissue. I have tried to run a script supplied by Tablet, coveragestats.py, which will give me: number of coverage values (=contig length), average depth, percent of bases with a depth greater than zero (percent coverage), and maximum depth.
I get the following error when I try to run the script
Traceback (most recent call last):
File "coveragestats.py", line 91, in <module>
stats = '\t'.join(templateStr) % tuple([func(coverages) for func in funcList])
File "coveragestats.py", line 71, in average
return float(sum(ints))/float(len(ints))
ZeroDivisionError: float division by zero
I am fairly certain this is happening because when I load my .bam and reference files to Tablet I get the following warning:
The index for this BAM file is reporting a total read count of zero. Although this may be correct, it is more likely that the index file was generated prior to read metrics being available. It is advisable to recreate this index using samtools 0.1.8 or higher.
I have verified my version of samtools as being the latest version and have reindexed my .bam file several times. Still the same problem (read count 0). However I do see the number of reads associated with my contigs in the Tablet header (and they are displayed), just not in the actual list of contigs in the left panel where this info should be associated to each contig.
Thanks in advance for any help.
Does 'samtools idxstats your_file.bam' confirm no mapped reads? This is the information Tablet is using to get the read count.
And what exactly is your version of samtools?
re version problem is I am now home (I can answer this with more certainty tomorrow) but, I made sure I had the at least 0.1.18 by running
sudo apt-get update
and thensudo apt-get install samtools
. then for good measure, since I saw there was a .19 version, I git cloned that on to my machine and indexed again. here at home I also have ubuntu running and samtools is most assuredly 0.1.18.I did transport the files home with me (
myfile.bam
,myfile_sorted.bam
andmyfile_sorted.bam.bai
) and when I runidxstats
command I get this(then I reindexed one more time for good measure and same result) incidentally this is a bowtie2 mapped file, I have also done mapping with
bwa-mem
so I could see what happens with this.bam
file as wellto make sure I am doing what you want, I should be running
idxstats
on.bam
file and not sorted file?There you have your answer that is not a properly sorted and indexed BAM file. Not even samtools can read it.
Go back to the beginning and redo the BAM file generation.
Also BAM files should always be sorted otherwise they can't be indexed.
I have already tried rebuilding and yesterday I followed Tablet protocol exactly for generating BAM file
it all seemed to work fine....
This was approach I had taken to building BAM file previously
both approaches produced the expected files
now you need to test that the process completed as expected, for example what do commands such as
produce? (substitute real values for contig/start/stop etc) those need to run without a hitch to assure that the bamfile is indeed correct.
Once again telling me not indexed. weird. will try whole routine with my BWA-mem mapped file and see what happens?
the answer is simple - as the errors says you don't actually have an indexed BAM file.
now why and how to fix that is for you to sort out.
great. still working on it, the mystery continues....
for the record I am using seqtk to extract 50K reads from my /1 and /2 fastq files (keeping pairing) and will map these to my assembly for sam to bam conversion, sort and index. will make file easier to pass around to willing victims (I mean candidates)
An update: I was running idxstats on the wrong file (namely the .bam file and not the sorted.bam file). So as it turns out my BAM file is sorted and indexed correctly. I was able to take a different approach from Tablet (using edgeR and bedtools) http://ged.msu.edu/angus/tutorials-2013/rnaseq_bwa_counting.html in order to get read counts on my contigs. Am in discussion with Tablet developer to see why read counts will not display properly.
Duplicate post on SEQanswers, http://seqanswers.com/forums/showthread.php?t=32870
Run samtools and post the first two lines it prints, like so
OK. will report in more detail tomorrow (in meantime see above)