LTLA / csaw

Clone of the Bioconductor repository for the csaw package.

Home Page:https://bioconductor.org/packages/devel/bioc/html/csaw.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in .extractSE(bam.file, where = where, param = param): failed to open BAM index at ...

muhammed-ali opened this issue · comments

Hello,

I have my sorted .bam files and the corresponding .bai files in a given location. When I try to read them using the "windowCounts" function, I get the following error:

> data <- windowCounts(bam.files, filter=1)
Error in .extractSE(bam.file, where = where, param = param) : 
  failed to open BAM index at '/scratch/users/mali/Tasks/Magda/chipseq_bam/78.sort.bam.bai'

Here if I do the following system command, then it shows the file size, confirming that .bam and .bai files exist in that path:

> system("ls -l /scratch/users/mali/Tasks/Magda/chipseq_bam/78.sort.bam.bai")
-rw-r--r-- 1 mali clusterusers 2904779 Jul  2 08:17 /scratch/users/mali/Tasks/Magda/chipseq_bam/78.sort.bam.bai
> system("ls -l /scratch/users/mali/Tasks/Magda/chipseq_bam/78.sort.bam")
-rw-r--r-- 1 mali clusterusers 2119963418 Jun  2 18:36 /scratch/users/mali/Tasks/Magda/chipseq_bam/78.sort.bam

Out of curiosity, I checked the header of the csaw package provided sample bam files and my bam files, and found significant differences. Kindly see below:

$ samtools view /mnt/irisgpfs/users/mali/R/x86_64-pc-linux-gnu-library/3.6/csaw/exdata/rep1.bam | head -n 5
x	16	chrA	3	191	10M	*	0	0	NNNNNNNNNN	..........
x	1040	chrA	4	181	10M	*	0	0	NNNNNNNNNN	..........
x	0	chrA	6	60	10M	*	0	0	NNNNNNNNNN	..........
x	16	chrA	8	192	10M	*	0	0	NNNNNNNNNN	..........
x	0	chrA	10	63	10M	*	0	0	NNNNNNNNNN	..........
$ samtools view /scratch/users/mali/Tasks/Magda/chipseq_bam/78.sort.bam | head -n 3
ST-K00127:205:HJJ2HBBXX:5:1101:8623:30187	163	10	3100113	42	50M	=	3100249	186	CCAGTTAGAATGGCTAAGATCAAAAACTCAGGTGACAACAGATGTTGGCG	AAAFFJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ	AS:i:0	XS:i:-6	XN:i:0	XM:i:0	XO:i:0	XG:i:0	NM:i:0	MD:Z:50	YS:i:0	YT:Z:CP
ST-K00127:205:HJJ2HBBXX:5:1101:8623:30187	83	10	3100249	42	50M	=	3100113	-186	TCAGAAAATTGGACATAGTACTACCGGAGTACCCAGATGCCCCTCAACAG	JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJFFFAA	AS:i:0	XN:i:0	XM:i:0	XO:i:0	XG:i:0	NM:i:0	MD:Z:50	YS:i:0	YT:Z:CP
ST-K00127:205:HJJ2HBBXX:5:1112:7862:39629	163	10	3101206	42	50M	=	3101436	280	AGAATAATCATATTATTCTCAAATTTTGTATCAATATAAAAAAAAAAGAA	AAFFFJJJJJJJJJJJJJJJJJJJFJAJJJJJJJJJJJFJJJJJJJJJJJ	AS:i:0	XS:i:-29	XN:i:0	XM:i:0	XO:i:0	XG:i:0	NM:i:0	MD:Z:50	YS:i:0	YT:Z:CP

Could you please tell me if it is the difference in the bam files that is causing this problem or if I am doing something wrong here?

Thanking you in advance and looking forward to your kind response.

I guess there was a problem with the bai files, generated the new via samtools index command and this error was gone.

Oh good. That was what I was going to suggest anyway.