Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

## 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 GAlignments or GAlignmentPairs.

con

A path, URL, connection or BamFile object.

format

If not missing, should be “bam”.

text

Not supported.

paired

If TRUE, return a GAlignmentPairs object, otherwise a GAlignments.

use.names

Whether to parse QNAME as the names on the result.

param

The ScanBamParam object governing the import.

genome

Single string or Seqinfo object identifying the genome

...

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.

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)

rtracklayer

R interface to genome annotation files and the UCSC genome browser

v1.50.0
Artistic-2.0 + file LICENSE
Authors
Michael Lawrence, Vince Carey, Robert Gentleman
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.