The error generated by Rsamtools
1
1
Entering edit mode
20 months ago
wangdp123 ▴ 250

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

Rsamtools Rsubread • 780 views
ADD COMMENT
1
Entering edit mode

Sounds like you have a SAM file rather than a BAM file.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Can you show output of samtools quickcheck -vvv that.bam on that bam file via terminal?

ADD REPLY
0
Entering edit mode

I run the following command line on terminal:

samtools quickcheck -v sample.bam

The output is empty.

ADD REPLY
0
Entering edit mode

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 simple head(sample.bam) will also tellyou if it is not a SAM file in terms of not being binary.

ADD REPLY
0
Entering edit mode

OK. I have run the command line: samtools quickcheck -vvv sample.bam

The output is below:

verbosity set to 3
checking sample.bam
opened sample.bam
sample.bam is sequence data
sample.bam has 1 targets in header
sample.bam has good EOF block
ADD REPLY
0
Entering edit mode

Hmm, ok next step, checking the header: samtools view -H sample.bam

ADD REPLY
0
Entering edit mode
@HD     VN:1.0  SO:unsorted
@SQ     SN:22   LN:50818468
@PG     ID:subread      PN:subread      VN:Rsubread 1.34.7      CL:"subread-align" "-r" "sample.R1.fastq.gz" "-R" "sample.R2.fastq.gz" "-o" "sample.bam" "-i" "index" "--type" "0" "-n" "10" "-m" "3" "-p" "1" "-M" "3" "-T" "1" "-I" "5" "-B" "1" "-d" "50" "-D" "600" "-S" "fr" "--trim5" "0" "--trim3" "0" "-G" "-1" "-E" "0" "-X" "0" "-Y" "2" "-P" "3"
ADD REPLY
1
Entering edit mode
20 months ago
Gordon Smyth ★ 3.5k

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1967 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6