[BioC] filterBam using rname

rcaloger raffaele.calogero at gmail.com
Thu Oct 18 15:57:34 CEST 2012

I have the necessity to filter a Bam file,  keeping only reads 
associated to a subset of references.
I wanted to do it with filterBam (Rsamtools)
but I could not manage to find a way of doing it.
If I use the code:
filterBam("onlymapped.bam", "filtered.bam", 
param=ScanBamParam(which=my.rnames, what=scanBamWhat("rname")))
I get:
Error in function (classes, fdef, mtable)  :
   unable to find an inherited method for function "ScanBamParam", for 
signature "character"

checking the help it seems to me that ScanBamParam(which=) only support 
GRanges, RangesList, RangedData objects.

There is any other way to filter a bam file on the basis of the rname?

 > sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods base

other attached packages:
  [1] ShortRead_1.14.4     latticeExtra_0.6-24  RColorBrewer_1.0-5 
lattice_0.20-10      Rsamtools_1.8.6
  [6] Biostrings_2.24.1    GenomicRanges_1.8.13 IRanges_1.14.4 
Biobase_2.16.0       BiocGenerics_0.2.0

loaded via a namespace (and not attached):
[1] bitops_1.0-4.1 grid_2.15.1    hwriter_1.3    stats4_2.15.1 
tools_2.15.1   zlibbioc_1.2.0


Prof. Raffaele A. Calogero
Bioinformatics and Genomics Unit
MBC Centro di Biotecnologie Molecolari
Via Nizza 52, Torino 10126
tel.   ++39 0116706457
Fax    ++39 0112366457
Mobile ++39 3333827080
email: raffaele.calogero at unito.it
www:   http://www.bioinformatica.unito.it

More information about the Bioconductor mailing list