rtracklayer (version 1.32.1)

BamFile-methods: Export to BAM Files

Description

Methods for import and export of GAlignments or GAlignmentPairs objects from and to BAM files, represented as BamFile objects.

Usage

"import"(con, format, text, use.names = FALSE, param = ScanBamParam(...), ...) "export"(object, con, format, ...)

Arguments

object
The object to export, such as a GAlignments or GAlignmentPairs.
con
A path, URL, connection or BamFile object.
format
If not missing, should be “bam”.
text
Not supported.
use.names
Whether to parse QNAME as the names on the result.
param
The ScanBamParam object governing the import.
...
Arguments that are passed to ScanBamParam if param is missing.

Details

BAM fields not formally present in the GAlignments[Pairs] object are extracted from the metadata columns, if present; otherwise, the missing value, “"."”, is output. The file is sorted and indexed. This can be useful for subsetting BAM files, although filterBam may eventually become flexible enough to be the favored alternative.

See Also

The readGAlignments and readGAlignmentPairs functions for reading BAM files.

Examples

Run this code
     library(Rsamtools)
     ex1_file <- system.file("extdata", "ex1.bam", package="Rsamtools")
     gal <- import(ex1_file, param=ScanBamParam(what="flag"))
     gal.minus <- gal[strand(gal) == "-"]
## Not run: 
#      export(gal, BamFile("ex1-minus.bam"))
# ## End(Not run)

Run the code above in your browser using DataLab