Description Usage Arguments Details Value Author(s) Examples
Compresses character vectors into raw vectors, or decompresses raw vectors into character vectors using a variety of codecs.
1 2 3 4 |
x |
Either a character vector to be compressed, or a list of raw vectors to be decompressed. |
compression |
The type of compression algorithm to use when |
compressRepeats |
Logical specifying whether to compress exact repeats and reverse complement repeats in a character vector input ( |
processors |
The number of processors to use, or |
Codec
can be used to compress/decompress character vectors using different algorithms. The "nbit"
and "qbit"
methods are tailored specifically to nucleotides and quality scores, respectively. These two methods will store the data as plain text ("ASCII"
format) when it is incompressible. In such cases, a second compression
method can be given to use in lieu of plain text. For example compression = c("nbit", "gzip")
will use "gzip"
compression when "nbit"
compression is inappropriate.
When performing the reverse operation, decompression, the type of compression
is automatically detected based on the unique signature ("magic number") added by each compression algorithm.
If x
is a character vector to be compressed, the output is a list with one element containing a raw vector per character string. If x
is a list of raw vectors to be decompressed, then the output is a character vector with one string per list element.
Erik Wright eswright@pitt.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | fas <- system.file("extdata", "Bacteria_175seqs.fas", package="DECIPHER")
dna <- as.character(readDNAStringSet(fas)) # aligned sequences
object.size(dna)
# compression
system.time(x <- Codec(dna, compression="nbit"))
object.size(x)/sum(nchar(dna)) # bytes per position
system.time(g <- Codec(dna, compression="gzip"))
object.size(g)/sum(nchar(dna)) # bytes per position
# decompression
system.time(y <- Codec(x))
stopifnot(dna==y)
system.time(z <- Codec(g))
stopifnot(dna==z)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.