From BAM to BAI to BIGWIG
1
0
Entering edit mode
5.8 years ago
compuTE ▴ 140

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!

bigwig samtools index bamCoverage bai • 13k views
ADD COMMENT
12
Entering edit mode
5.8 years ago
h.mon 35k

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 COMMENT
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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

enter image description here

ADD REPLY
0
Entering edit mode

Hi,

I run the command line "bamCoverage -b reads.bam -o coverage.bw" in order to convert bam RNA-seq data to .bw files and I get error "command not found". Please advise what is wrong there. Thank you

ADD REPLY
1
Entering edit mode

Hi, it seems like you don't have deeptools installed. Try,

bamCoverage --help

If this doesn't show you the help page, follow the deeptools installation instructions

ADD REPLY

Login before adding your answer.

Traffic: 2005 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