Biostar Beta. Not for public use.
Question: From BAM to BAI to BIGWIG
0
Entering edit mode

Hello,

I have indexed my bam files as:

> samtools index -b file.bam

I get as a result a file.bam.bai. But when I try to convert it to BigWig with bamCoverage as:

> bamCoverage -b file.bam.bai -o file.bw

I get the following error:

[E::hts_hopen] fail to open file 'file.bam.bai'
[E::hts_open_format] fail to open file 'file.bam.bai'
The file file.bam.bai does not have BAM format

The error persists if I change the file name to file.bam.bai.

I checked with samtools flagstat, and I get the same error

> samtools flagstat file.bam.bai
[E::hts_hopen] fail to open file 'file.bam.bai'
[E::hts_open_format] fail to open file 'file.bam.bai'
samtools flagstat: Cannot open input file "file.bam.bai": Exec format error

If I dont index the bam file bamCoverage tells me i MUST index it first...

I think I have done this before without any problems and I dont understand why am I getting this error. Could it be that the files are corrupted? Any help is well appreciated!

ADD COMMENTlink 12 months ago raquelgarza95 • 40 • updated 12 months ago h.mon 25k
4
Entering edit mode

The .bai file is just an index, you have to convert the .bam file to bigWig - as shown on the bamCoverage documentation:

bamCoverage -b reads.bam -o coverage.bw
ADD COMMENTlink 12 months ago h.mon 25k
Entering edit mode
0

Wow, that was simple! Thank you so much! :)

ADD REPLYlink 12 months ago
raquelgarza95
• 40
Entering edit mode
1

If an answer was helpful, please consider to mark it as accepted.

enter image description here

ADD REPLYlink 12 months ago
ATpoint
17k

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0