WIG Import and Export
These functions support the import and export of the UCSC WIG (Wiggle) format.
## S4 method for signature 'WIGFile,ANY,ANY' import(con, format, text, genome = NA, trackLine = TRUE, which = NULL, seqinfo = NULL, ...) import.wig(con, ...) ## S4 method for signature 'ANY,WIGFile,ANY' export(object, con, format, ...) ## S4 method for signature 'GenomicRanges,WIGFile,ANY' export(object, con, format, dataFormat = c("auto", "variableStep", "fixedStep"), writer = .wigWriter, append = FALSE, ...) ## S4 method for signature 'GenomicRangesList,WIGFile,ANY' export(object, con, format, ...) ## S4 method for signature 'UCSCData,WIGFile,ANY' export(object, con, format, trackLine = TRUE, ...) export.wig(object, con, ...)
con |
A path, URL, connection or |
object |
The object to export, should be a |
format |
If not missing, should be “wig”. |
text |
If |
trackLine |
Whether to parse/output a UCSC track line. An
imported track line will be stored in a |
genome |
The identifier of a genome, or |
seqinfo |
If not |
which |
A range data structure like |
append |
If |
dataFormat |
Probably best left to “auto”. Exists only for historical reasons. |
writer |
Function for writing out the blocks; for internal use only. |
... |
Arguments to pass down to methods to other methods. For
import, the flow eventually reaches the |
The WIG format is a text-based format for efficiently representing a
dense genome-scale score vector. It encodes, for each feature, a range
and score. Features from the same sequence (chromosome) are grouped
together into a block, with a single block header line indicating the
chromosome. There are two block formats: fixed step and variable
step. For fixed step, the number of positions (or step) between
intervals is the same across an entire block. For variable step, the
start position is specified for each feature. For both fixed and
variable step, the span (or width) is specified in the header and thus
must be the same across all features. This requirement of uniform
width dramatically limits the applicability of WIG. For scored
features of variable width, consider BEDGraph or
BigWig, which is generally preferred over both WIG
and BEDGraph. To efficiently convert an existing WIG or BEDGraph file
to BigWig, call wigToBigWig
. Neither WIG, BEDGraph nor
BigWig allow overlapping features.
A GRanges
with the score values in the score
metadata column,
which is accessible via the score
function.
The WIGFile
class extends RTLFile
and is a
formal represention of a resource in the WIG format.
To cast a path, URL or connection to a WIGFile
, pass it to
the WIGFile
constructor.
Michael Lawrence
test_path <- system.file("tests", package = "rtracklayer") test_wig <- file.path(test_path, "step.wig") ## basic import calls test <- import(test_wig) test import.wig(test_wig) test_wig_file <- WIGFile(test_wig) import(test_wig_file) test_wig_con <- file(test_wig) import(test_wig_con, format = "wig") test_wig_con <- file(test_wig) import(WIGFile(test_wig_con)) ## various options import(test_wig, genome = "hg19") import(test_wig, trackLine = FALSE) which <- as(test[3:4,], "IntegerRangesList") import(test_wig, which = which) ## Not run: ## basic export calls test_wig_out <- file.path(tempdir(), "test.wig") export(test, test_wig_out) export.wig(test, test_wig_out) test_foo_out <- file.path(tempdir(), "test.foo") export(test, test_foo_out, format = "wig") test_wig_out_file <- WIGFile(test_wig_out) export(test, test_wig_out_file) ## appending test2 <- test metadata(test2)$trackLine <- initialize(metadata(test)$trackLine, name = "test2") export(test2, test_wig_out_file, append = TRUE) ## passing track line parameters export(test, test_wig_out, name = "test2") ## no track line export(test, test_wig_out, trackLine = FALSE) ## gzip test_wig_gz <- paste(test_wig_out, ".gz", sep = "") export(test, test_wig_gz) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.