R: readerToFastq: Extraction of a subset of alignments from a...

readerToFastq {rbamtools} | R Documentation

## readerToFastq: Extraction of a subset of alignments from a BAM files into fastq format.

### Description

The function `readerToFastq` writes (remaining) aligns or some part of the stored aligns in a BAM file as reads into a compressed fastq file.

### Usage

    readerToFastq(object, filename, which, append=FALSE)

### Arguments

`object` | bamReader. Must be opened.

`filename` | Name of output 'fastq' file.

`which` | (Optional) Logical vector. When given, the routine checks for each of the given values the value of which. When TRUE the next retrieved align will be written to the output file, otherwise will be skipped.

`append` | (Optional) When TRUE, the routine will append to an existing file. Otherwise existing files will be overwritten.

### Value

numeric

### Author(s)

Wolfgang Kaisers

### Examples

    bam <- system.file("extdata", "accepted_hits.bam", package="rbamtools")
    reader <- bamReader(bam)
    readerToFastq(reader, "out.fq.gz")
    bamClose(reader)
    # Reopen in order to point to first align
    reader <- bamReader(bam)
    index <- sample(1:100, 20)
    readerToFastq(reader, "out_subset.fq.gz", which=index)

[Package rbamtools version 2.16.17 Index]