BamFile-methods: Export to BAM Files

Description Usage Arguments Details Author(s) See Also Examples

Description

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

Usage

1
2
3
4
5
6
7
## 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

1
2
3
4
5
6
7
8
     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 documentation built on Nov. 8, 2020, 6:50 p.m.