[Bioc-sig-seq] Rsamtools: Select reads on a chromosome

Martin Morgan mtmorgan at fhcrc.org
Thu Jan 7 07:11:43 CET 2010


Steve Lianoglou wrote:
> Hi,
> 
> Not a pressing issue, but I feel like I'm doing this wrong.
> 
> Currently in order to get all the reads on a chromosome using
> Rsamtools (to extract from a BAM file), I'm making an IRanges object
> that's "as long" as the chromosome I want the reads for.
> 
> For instance, for chr1:
> 
> which <- RangesList(chr1=IRanges(start=1, end=247249719))
> params <- ScanBamParams(which=which)
> reads <- scanBam(my.bam.file, param=params)[[1]]
> 
> Is there are "better" way to do it, eg. w/o making the IRanges object
> that's stretches over the chromosome?

I don't think so, though 'end' doesn't have to be a literal end, e.g,.
.Machine$integer.max and 'stretches' doesn't really involve any cost --
just two numbers.

The use case I was thinking of was a well-defined collection of regions
of interest, probably coming from some genome annotation, but I guess
you're interested in chromosome-at-a-time processing?

Martin

> 
> Just curious, thanks.
> -steve
> 


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



More information about the Bioc-sig-sequencing mailing list