I can confirm using bowtie2 to generate sam files, using samtools from the
command line to convert sam files to sorted bam files, as well as
generating a bam file in R space of the same filesize using asBam() in
Rsamtools. Both ways loaded the bam files into R fine using scanBam().

Here is a thread on seqanswers with similar a error to yours;

http://seqanswers.com/forums/showthread.php?t=18119

More information is required about your specific problem for anyone to
potentially help out, but it looks like there is something inconsistent in
your sam file header information.


Marcus





On Thu, May 31, 2012 at 4:14 PM, Martin Morgan <mtmorgan@fhcrc.org> wrote:

> On 05/30/2012 08:57 PM, Yu Chuan Tai wrote:
>
>> Hi,
>>
>> I tried to convert a SAM file from Bowtie2 output to a BAM file,
>> however, it didn't work.
>>
>
> I guess you're talking about Rsamtools; if you mean samtools, then this is
> not the right forum. How did you try to convert the file? It should be
>
>  library(Rsamtools)
>  asBam("../AlignedData/S1_L001_**001.SAM", "../AlignedData/S1_L001_001")
>
> What did you try? Also, Bowtie2 will be able to output BAM files directly.
>
> Martin
>
>
>  [bam_header_read] EOF marker is absent. The input is probably truncated.
>>
>> [bam_header_read] invalid BAM binary header (this is not a BAM file).
>>
>> [main_samview] fail to read the header from
>> "../AlignedData/S1_L001_001.**SAM".
>>
>> When I used Bowtie2, I tried to include SAM headers and not include SAM
>> headers, both gave me the same error.
>> Could anyone tell me what's going on here, since I just started to use
>> samtools today.
>>
>> Thanks!
>> Yu Chuan
>>
>> ______________________________**_________________
>> Bioconductor mailing list
>> Bioconductor@r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https://stat.ethz.ch/mailman/listinfo/bioconductor>
>> Search the archives:
>> http://news.gmane.org/gmane.**science.biology.informatics.**conductor<http://news.gmane.org/gmane.science.biology.informatics.conductor>
>>
>
>
> --
> Computational Biology
> Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109
>
> Location: M1-B861
> Telephone: 206 667-2793
>
>
> ______________________________**_________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https://stat.ethz.ch/mailman/listinfo/bioconductor>
> Search the archives: http://news.gmane.org/gmane.**
> science.biology.informatics.**conductor<http://news.gmane.org/gmane.science.biology.informatics.conductor>
>

	[[alternative HTML version deleted]]

