BigBedFile-class {rtracklayer} | R Documentation

## BigBed Import and Export

### Description

These functions support the import and export of the UCSC BigBed format, a compressed, binary form of BED with a spatial index and precomputed summaries. These functions do not work on Windows.

### Usage

    ## S4 method for signature 'BigBedFile,ANY,ANY'
    import(con, format, text,
                       selection = BigBedSelection(which, ...),
                       which = con, ...)
    import.bb(con, ...)

    ## S4 method for signature 'ANY,BigBedFile,ANY'
    export(object, con, format, ...)
    ## S4 method for signature 'GenomicRanges,BigBedFile,ANY'
    export(object, con, format,
                       compress = TRUE, extraIndexes = "")
    export.bb(object, con, ...)

### Arguments

`con` | A path, URL or `BigBedFile` object. Connections are not supported. For the functions ending in `.bb`, the file format is indicated by the function name. For the `export` and `import` methods, the format must be indicated another way. If `con` is a path, or URL, either the file extension or the `format` argument needs to be “bigBed” or “bb”.
`object` | The object to export, should be `GRanges`.
`format` | If not missing, should be “bigBed” or “bb” (case insensitive).
`text` | Not supported.
`selection` | A `BigBedSelection` object indicating the ranges to load.
`which` | A range data structure coercible to `IntegerRangesList`, like a `GRanges`, or a `BigBedFile`. Only the intervals in the file overlapping the given ranges are returned. By default, the value is the `BigBedFile` itself. Its `Seqinfo` object is extracted and coerced to a `IntegerRangesList` that represents the entirety of the file.
`compress` | If `TRUE`, compress the data. No reason to change this.
`extraIndexes` | If set, make an index on each field in a comma separated list
`...` | Arguments to pass down to methods to other methods. For import, the flow eventually reaches the `BigBedFile` method on `import`.

### `BigBedFile` objects

A `BigWigFile` object, an extension of `BiocFile` is a reference to a BigBed file. To cast a path, URL or connection to a `BigBedFile`, pass it to the `BigBedFile` constructor.

BigBed files are more complex than most track files, and there are a number of methods on `BigBedFile` for accessing the additional information:

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

When accessing remote data, the UCSC library caches data in the ‘/tmp/udcCache’ directory. To clean the cache, call `cleanBigBedCache(maxDays)`, where any files older than `maxDays` days old will be deleted.

### Author(s)

Michael Lawrence

### Examples

    if (.Platform$OS.type != "windows") {
      test_path <- system.file("tests", package = "rtracklayer")
      test_bb <- file.path(test_path, "test.bb")

      ## Returns ranges with all fields
      gr <- import(test_bb)
      gr

      ## Retuns ranges only for 'chr10'
      ## between 180185-180185 with all fields
      which <- GRanges(c("chr10"), IRanges(c(180185, 180185)))
      import(test_bb, which = which)

      ## Retuns ranges only for 'chr10'
      ## between 180185-180185 with name and peak fields
      selection <- BigBedSelection(which, colnames = c("name", "peak"))
      import(test_bb, selection = selection)

    ## Not run:
      test_bb_out <- file.path(tempdir(), "test_out.bb")
      export(test, test_bb_out)

      ## make an index for 'name'
      test_bb_out <- file.path(tempdir(), "test_out.bb")
      export(test, test_bb_out, extraIndexes = "name")

    ## End(Not run)
    }

[Package rtracklayer version 1.52.1 Index]