BamFile-methods {rtracklayer} | R Documentation |
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
## S4 method for signature 'BamFile,ANY,ANY'
import(con, format, text, paired = FALSE,
use.names = FALSE,
param = ScanBamParam(...),
genome = NA_character_, ...)
## S4 method for signature 'ANY,BamFile,ANY'
export(object, con, format, ...)
Arguments
object |
The object to export, such as
a |
con |
A path, URL, connection or |
format |
If not missing, should be “bam”. |
text |
Not supported. |
paired |
If |
use.names |
Whether to parse QNAME as the names on the result. |
param |
The |
genome |
Single string or |
... |
Arguments that are passed to |
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.
Author(s)
Michael Lawrence
See Also
The readGAlignments
and
readGAlignmentPairs
functions
for reading BAM files.
Examples
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)