The error generated by Rsamtools
Hi there,
I use Rsubread to produce the BAM files and then use Rsamtools to manipulate the BAM files.
A few errors were thrown out:
1)
> indexBam(files = "sample.bam")
Error in FUN(X[[i]], ...) : failed to build index
2)
> asSam(file = "sample.bam")
> asBam(file = "sample.sam")
Error in value[[3L]](cond) : 'asBam' truncated input file at record 8
I have checked the content of the BAM file generated by Rsubread by converting it into a SAM file and it seems that it uses quite a few CR (carriage return) in the middle of each long line. Does Rsamtools not recognise this format?
Many thanks,
Tom
• 3,265 views
•
link
1 answer
Rsubread can sort and index the BAM file on-the-fly during the alignment. It is much faster to take advantage of that facility than to sort and index the BAM file afterwards.
indexBAM might perhaps assume that the BAM file is location-sorted but, by default, it won't be.
• 0 views
•
link
Log in to answer this question.
Sounds like you have a SAM file rather than a BAM file.
No. I have checked that it is BAM file. I can use asSam() function to convert sample.bam to sample.sam but cannot convert back from sample.sam to sample.bam using asBam() function.
Can you show output of
samtools quickcheck -vvv that.bamon that bam file via terminal?I run the following command line on terminal:
The output is empty.
Please use
vvv, this is not a typo. Tripple-v means "set verbosity to 3" which is "output everything". It will give a more detailed output message from the tool. A simplehead(sample.bam)will also tellyou if it is not a SAM file in terms of not being binary.OK. I have run the command line:
samtools quickcheck -vvv sample.bamThe output is below:
Hmm, ok next step, checking the header:
samtools view -H sample.bam