R: bamSave: Creation of a sorted copy of a BAM file.

bamSave {rbamtools} | R Documentation

## bamSave: Creation of a sorted copy of a BAM file.

### Description

The methods for `bamSave` write BAM alignment data (either single alignments as `bamAlign` objects or lists of alignments as `bamRange` objects) out to a bamWriter.

### Usage

    bamSave(object, value, refid, ...)

### Arguments

`object` | `bamWriter`. The writer must be opened.

`value` | Object of type `bamAlign` or `bamRange`.

`refid` | (Optional) Defines sequence association (ID) in Reference sequence dictionary of output BAM file. May be given as numeric, or character. When missing, ID is determined from reference name (only for `bamRange`).

`...` | Currently unused.

### Details

The different methods specialize on different methods for determining the Reference sequence ID in the output file.

### Author(s)

Wolfgang Kaisers

### Examples

    bam<-system.file("extdata","accepted_hits.bam",package="rbamtools")
    reader<-bamReader(bam, idx=TRUE)
    rg <- bamRange(reader, getRefCoords(reader,"chr1"))

    writer <- bamWriter(bamReader, "out.BAM")
    bamSave(writer, rg)
    bamClose(writer)

[Package rbamtools version 2.16.17 Index]