Learn R Programming

rtracklayer (version 1.26.3)

BamFile-methods: Export to BAM Files

Description

Methods for import and export of GAlignments 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, should be a GAlignments or one of its subclasses, like GappedReads.
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 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

readGAlignments in the GenomicAlignments package for reading BAM files into a GAlignments.

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