edit

bigBed

Description –––––-

bigBed is a binary file format for representing genomic annotations and often created from BED files. bigBed files are indexed to quickly fetch specific regions.

I/O tools for bigBed are provided from the GenomicFeatures.BigBed module, which exports following three types:

  • Reader type: BigBed.Reader
  • Writre type: BigBed.Writer
  • Element type: BigBed.Record

Examples

A common workflow is to open a file, iterate over records, and close the file:

# Import the BigBed module.
using GenomicFeatures

# Open a bigBed file.
reader = open(BigBed.Reader, "data.bb")

# Iterate over records overlapping with a query interval.
for record in eachoverlap(reader, Interval("Chr2", 5001, 6000))
    # Extract the start position, end position and value of the record,
    startpos = BigBed.chromstart(record)
    endpos = BigBed.chromend(record)
    value = BigBed.value(record)
    # and do something...
end

# Finally, close the reader.
close(reader)

Iterating over all records is also supported:

reader = open(BigBed.Reader, "data.bb")
for record in reader
    # ...
end
close(reader)

Creating a bigBed file can be done as follows. The write call takes a tuple of 3-12 elements (i.e. chromosome name, start position, end position, name, score, strand, thickstart, thickend, RGB color, blockcount, blocksizes and blockstarts). The first three are mandatory fields but others are optional.

# Import RGB type.
using ColorTypes
file = open("data.bb", "w")
writer = BigBed.Writer(file, [("chr1", 1000)])
write(writer, ("chr1", 1, 100, "some name", 100, '+', 10, 90, RGB(0.5, 0.1, 0.2), 2, [4, 10], [10, 20]))
close(writer)

API

# GenomicFeatures.BigBed.ReaderType.

BigBed.Reader(input::IO)

Create a reader for bigBed file format.

Note that input must be seekable.

source

# GenomicFeatures.BigBed.chromlistFunction.

chromlist(reader::BigBed.Reader)::Vector{Tuple{String,Int}}

Get the (name, length) pairs of chromosomes/contigs.

source

# GenomicFeatures.BigBed.WriterType.

BigBed.Writer(output::IO, chromlist; binsize=64)

Create a data writer of the bigBed file format.

Arguments

  • output: data sink
  • chromlist: chromosome list with length
  • binsize=64: size of a zoom with the highest resolution

Examples

output = open("data.bb", "w")
writer = BigBed.Writer(output, [("chr1", 12345), ("chr2", 9100)])
write(writer, ("chr1", 101, 150, "gene 1"))
write(writer, ("chr2", 211, 250, "gene 2"))
close(writer)

source

# GenomicFeatures.BigBed.RecordType.

BigBed.Record()

Create an unfilled bigBed record.

source

# GenomicFeatures.BigBed.chromFunction.

chrom(record::Record)::String

Get the chromosome name of record.

source

# GenomicFeatures.BigBed.chromidFunction.

chromid(record::Record)::UInt32

Get the chromosome ID of record.

source

# GenomicFeatures.BigBed.chromstartFunction.

chromstart(record::Record)::Int

Get the start position of record.

source

# GenomicFeatures.BigBed.chromendFunction.

chromend(record::Record)::Int

Get the end position of record.

source

# GenomicFeatures.BigBed.nameFunction.

name(record::Record)::String

Get the name of record.

source

# GenomicFeatures.BigBed.scoreFunction.

score(record::Record)::Int

Get the score between 0 and 1000.

source

# GenomicFeatures.BigBed.strandFunction.

strand(record::Record)::GenomicFeatures.Strand

Get the strand of record.

source

# GenomicFeatures.BigBed.thickstartFunction.

thickstart(record::Record)::Int

Get the starting position at which record is drawn thickly.

Note that the first base is numbered 1.

source

# GenomicFeatures.BigBed.thickendFunction.

thickend(record::Record)::Int

Get the end position at which record is drawn thickly.

source

# GenomicFeatures.BigBed.itemrgbFunction.

itemrgb(record::Record)::ColorTypes.RGB

Get the RGB value of record.

The return type is defined in ColorTypes.jl.

source

# GenomicFeatures.BigBed.blockcountFunction.

blockcount(record::Record)::Int

Get the number of blocks (exons) in record.

source

# GenomicFeatures.BigBed.blocksizesFunction.

blocksizes(record::Record)::Vector{Int}

Get the block (exon) sizes of record.

source

# GenomicFeatures.BigBed.blockstartsFunction.

blockstarts(record::Record)::Vector{Int}

Get the block (exon) starts of record.

Note that the first base is numbered 1.

source

# GenomicFeatures.BigBed.optionalsFunction.

optionals(record::Record)::Vector{String}

Get optional fields as strings.

source