agiFromBam {girafe} | R Documentation

## Create AlignedGenomeIntervals objects from BAM files.

### Description

Function to create `AlignedGenomeIntervals` objects from BAM (binary alignment map format) files. Uses functions from package `Rsamtools` to parse BAM files.

### Usage

    agiFromBam(bamfile, ...)

### Arguments

`bamfile` | File path of BAM file. BAM file should be sorted and have an index in the same directory (see Details below).
`...` | further arguments passed on to function `scanBam`

### Details

Note: the BAM files must be sorted and must also have an index file (`*.bai`) in the same directory. These should be done when creating the BAM. However, the functions `sortBam` and `indexBam` can be used for the same purpose, as can the respective modules of the “samtools” library (‘samtools sort’ and ‘samtools index’).

The BAM files are parsed chromosome by chromosome to limit the memory footprint of the function. Thus, this function aims to be a less-memory-consuming alternative to first reading in the BAM file using the `readAligned` function and then converting the `AlignedRead` object into an `AlignedGenomeIntervals` object.

### Value

An object of class `AlignedGenomeIntervals`.

### Author(s)

J Toedling

### References

http://samtools.sourceforge.net

### See Also

`scanBam`, `AlignedGenomeIntervals-class`

### Examples

      fl <- system.file("extdata", "ex1.bam", package="Rsamtools")
      ExGi <- agiFromBam(fl)
      head(detail(ExGi))

[Package girafe version 1.34.0 Index]