TwoBitFile-class {rtracklayer}R Documentation

2bit Files

Description

The export.2bit and import.2bit support the export and import, respectively, of the UCSC 2bit compressed sequence format. The main advantage is speed of subsequence retrieval, as it only loads the sequence in the requested intervals. Compared to the FA format supported by Rsamtools, 2bit offers the additional feature of masking and also has better support in Java (and thus most genome browsers). The supporting TwoBitFile class is a reference to a TwoBit file.

Accessor Methods

In the code snippets below, x represents a TwoBitFile object.

seqinfo(x): Gets the Seqinfo object indicating the lengths of the sequences in the file. No circularity or genome information is available.

Import

import.2bit(con, which = as(seqinfo(con), "GenomicRanges"), ...): Imports sequence from 2bit file con, which can be a string (path or URL) or TwoBitFile object. The sequence retrieval is restricted to the intervals given by which, which should be something coercible to a GRanges. The returned DNAStringSet contains a DNAString for every interval in which.

Export

export.2bit(object, con, which = as(seqinfo(con), "GenomicRanges"), ...): Exports object in the two bit format to con, a path or URL. The object should be a DNAStringSet (or something coercible to one) or a BSgenome object. If a BSgenome object, the arguments in ... are passed to bsapply during the export of each sequence.

Author(s)

Michael Lawrence

Examples

tbf <- TwoBitFile(system.file("tests", "test.2bit", package = "rtracklayer"))
seqinfo(tbf)
sequence <- import.2bit(tbf) # the whole file
subrange <- IRanges::resize(as(seqinfo(tbf), "GenomicRanges"), width = 50)
subsequence <- import.2bit(tbf, which = subrange)

[Package rtracklayer version 1.14.1 Index]