[BioC] an error to open bam file

Martin Morgan mtmorgan at fhcrc.org
Wed Nov 2 23:33:42 CET 2011


On 11/02/2011 03:15 PM, wang peter wrote:
> dear all:
>         sorry to disturb you ,especially martin.
> but i feel so confused, when i use
> alnRanges<- readBamGappedAlignments("s_5_1-IS_sequence.bam",format="BAM")
> it wored well
> but when i use
> paraFlag<- scanBamFlag(hasUnmappedMate = T)
> para<-ScanBamParam(flag = paraFlag)
> alnRanges<-
> readBamGappedAlignments("s_5_1-IS_sequence.bam",format="BAM",which=para)
>
> it reported error
>
> Error in open.BamFile(BamFile(file, index), "rb") :
>    failed to load BAM index
>    file: /home/sgao/Algae_data/s_5_1-IS_sequence.bam
> In addition: Warning message:
> In open.BamFile(BamFile(file, index), "rb") :
>    [bam_index_load] fail to load BAM index.
>

use

   idx = indexBam("s_5_1-IS_sequence.bam")

to create an index. If your bam index file is not named following 
samtools convention (e.g., with extension '.index'), specify it separately

   bf = open(BamFile("s_5_1-IS_sequence.bam", "s_5_1-IS_sequence.index"))
   readBamGappedAlignments(bf)

An index is required to access portions of a bam file.

In R-2-13.2, readBamGappedAlignments only accepts GRanges as 'which'; to 
use ScanBamParam needs R-2-14.0 and Rsamtools 1.6.0.

Martin

>
>> sessionInfo()
> R version 2.13.2 (2011-09-30)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> locale:
>   [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>   [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>   [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>   [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>   [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
> other attached packages:
> [1] ShortRead_1.10.4    Rsamtools_1.4.3     lattice_0.19-33
> [4] Biostrings_2.20.4   GenomicRanges_1.4.8 IRanges_1.10.6
> loaded via a namespace (and not attached):
> [1] Biobase_2.12.2 grid_2.13.2    hwriter_1.3
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: 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



More information about the Bioconductor mailing list