Import Bam index (Rsamtools)
1
0
Entering edit mode
@francesco-mancuso-4483
Last seen 9.6 years ago
Dear list, I have an error when I try to import a Bam file with the respective index using both method in Rsamtools "ScanBam()" and "open(BamFile())".The sorted file was created with "sortBam()" and the indexed with the function "indexBam()". For the sorting I obtain also a warning that I would like to understand. Is this happen because the file is too big and so it first splitted in more files and then merged? I am using the following code (with the relative output): > sortedFile <- sortBam("xxx.bam", "xxx_sorted", byQname=FALSE, maxMemory=512) [1] "xxx_sorted.bam" Warning message: In .local(file, destination, ...) : [bam_sort_core] merging from 2 files... > indexedFile <- indexBam("xxx_sorted.bam") > bf = open(BamFile(sortedFile, indexedFile)) Error in open.BamFile(BamFile("xxx_sorted.bam", : failed to load BAM index file: xxx_sorted.bam.bai In addition: Warning message: In open.BamFile(BamFile("xxx_sorted.bam", : [bam_index_load] fail to load BAM index. > param <- ScanBamParam(flag=scanBamFlag(isUnmappedQuery=FALSE), what=c("qname", "pos", "qwidth", "rname")) > aln <- scanBam(sortedFile, index=indexedFile, param=param) Error in open.BamFile(BamFile(file, index), "rb") : failed to load BAM index file: xxx_sorted.bam.bai In addition: Warning message: In open.BamFile(BamFile(file, index), "rb") : [bam_index_load] fail to load BAM index. Any suggestions is welcomed. Cheers, Francesco > sessionInfo() R version 2.15.0 (2012-03-30) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] C/en_US.UTF-8/C/C/C/C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Rsamtools_1.8.0 Biostrings_2.24.1 GenomicRanges_1.8.3 IRanges_1.14.2 BiocGenerics_0.2.0 loaded via a namespace (and not attached): [1] bitops_1.0-4.1 stats4_2.15.0 tools_2.15.0 zlibbioc_1.2.0 -- *Francesco Mattia Mancuso* Bioinformatician - Bioinformatics Core Facility - Proteomics Core Facility CRG-Centre for Genomic Regulation (Room 439) C/ Dr. Aiguader, 88 (Edif. PRBB) 08003 Barcelona, Spain Mail: francesco.mancuso@crg.eu <mailto:francesco.mancuso@crg.eu> Phone: +34 933160202 http://www.crg.es/bioinformatics_unit [[alternative HTML version deleted]]
Proteomics Rsamtools Proteomics Rsamtools • 2.8k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 5 days ago
United States
On 04/05/2012 08:36 AM, Francesco Mancuso wrote: > Dear list, > I have an error when I try to import a Bam file with the respective > index using both method in Rsamtools "ScanBam()" and > "open(BamFile())".The sorted file was created with "sortBam()" and the > indexed with the function "indexBam()". > For the sorting I obtain also a warning that I would like to understand. > Is this happen because the file is too big and so it first splitted in > more files and then merged? > > I am using the following code (with the relative output): > > sortedFile<- sortBam("xxx.bam", "xxx_sorted", byQname=FALSE, > maxMemory=512) > [1] "xxx_sorted.bam" > Warning message: > In .local(file, destination, ...) : [bam_sort_core] merging from 2 files... I think this warning is ok, just samtools telling you that to sort with the memory constraint you provided it had to split the file, but that these were merged in the fianl veraino. > > > indexedFile<- indexBam("xxx_sorted.bam") > > bf = open(BamFile(sortedFile, indexedFile)) > Error in open.BamFile(BamFile("xxx_sorted.bam", : > failed to load BAM index > file: xxx_sorted.bam.bai > In addition: Warning message: > In open.BamFile(BamFile("xxx_sorted.bam", : > [bam_index_load] fail to load BAM index. indexBam returns the (correct) path to the index. The samtools convention is that the index is named *without* the '.bai' extension, so for example in your case simply BamFile("xxx_sorted.bam") or BamFile("xxx_sorted.bam", sub(".bai$", "", indexedFile)). Hope that helps and sorry for the rough edges. Martin > > param<- ScanBamParam(flag=scanBamFlag(isUnmappedQuery=FALSE), > what=c("qname", "pos", "qwidth", "rname")) > > aln<- scanBam(sortedFile, index=indexedFile, param=param) > Error in open.BamFile(BamFile(file, index), "rb") : > failed to load BAM index > file: xxx_sorted.bam.bai > In addition: Warning message: > In open.BamFile(BamFile(file, index), "rb") : > [bam_index_load] fail to load BAM index. > > > Any suggestions is welcomed. > Cheers, > Francesco > > > > sessionInfo() > R version 2.15.0 (2012-03-30) > Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) > > locale: > [1] C/en_US.UTF-8/C/C/C/C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] Rsamtools_1.8.0 Biostrings_2.24.1 GenomicRanges_1.8.3 > IRanges_1.14.2 BiocGenerics_0.2.0 > > loaded via a namespace (and not attached): > [1] bitops_1.0-4.1 stats4_2.15.0 tools_2.15.0 zlibbioc_1.2.0 > > > -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793
ADD COMMENT

Login before adding your answer.

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