The first three required BED fields are (part of all supported sub-formats):
chrom - The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671).
chromStart - The starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0.
chromEnd - The ending position of the feature in the chromosome or scaffold. The chromEnd base is not included in the display of the feature. For example, the first 100 bases of a chromosome are defined as chromStart=0, chromEnd=100, and span the bases numbered 0-99.
The 9 additional optional BED fields are (part of sub-format "Optional"):
name - Defines the name of the BED line. This label is displayed to the left of the BED line in the Genome Browser window when the track is open to full display mode or directly to the left of the item in pack mode.
score - A score between 0 and 1000. If the track line useScore attribute is set to 1 for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). This table shows the Genome Browser's translation of BED score values into shades of gray:
shade
strand - Defines the strand - either '+' or '-'.
thickStart - The starting position at which the feature is drawn thickly (for example, the start codon in gene displays).
thickEnd - The ending position at which the feature is drawn thickly (for example, the stop codon in gene displays).
itemRgb - An RGB value of the form R,G,B (e.g. 255,0,0). If the track line itemRgb attribute is set to "On", this RBG value will determine the display color of the data contained in this BED line. NOTE: It is recommended that a simple color scheme (eight colors or less) be used with this attribute to avoid overwhelming the color resources of the Genome Browser and your Internet browser.
blockCount - The number of blocks (exons) in the BED line.
blockSizes - A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount.
blockStarts - A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount.
ENCODE also defines broadpeaks and narrowpeaks format (part of our "Peaks" sub-format):
name - Defines the name of the BED line. This label is displayed to the left of the BED line in the Genome Browser window when the track is open to full display mode or directly to the left of the item in pack mode.
score - Indicates how dark the peak will be displayed in the browser (0-1000). If all scores were '0' when the data were submitted to the DCC, the DCC assigned scores 1-1000 based on signal value. Ideally the average signalValue per base spread is between 100-1000.
strand - +/- to denote strand or orientation (whenever applicable). Use '.' if no orientation is assigned.
signalValue - Measurement of overall (usually, average) enrichment for the region.
pValue - Measurement of statistical significance (-log10). Use -1 if no pValue is assigned.
qValue - Measurement of statistical significance using false discovery rate (-log10). Use -1 if no qValue is assigned.
peak - Point-source called for this peak; 0-based offset from chromStart. Use -1 if no point-source called.
MACS also defines a "summit" peaks format (part of our "Summit" sub-format)
It contains the peak summits locations for every peaks. The 5th column in this file is the .
In addition to the required three, the following fields follow:
length [redundant, ignored]
summit summit height of fragment pileup
tags
pValue [-10*log10(pvalue)]
fold [enrichment]
FDR [%; optional]
"CCAT" BED-like file format:
chromosome,
peakcenter [converted to summit],
regionstart,
regionend,
tags [tagcount],
bg [bgcount],
zscore,
fdr
"""
def__init__(self,entries,format='Limited'):
"""
Create a BedFile instance.
:param entries: an iterable of entries or a filename
:param format: the format of the BED file
"""
self.format=format
ifisinstance(entries,str):# filename
self.chroms=readBedFile(entries,format)
else:
self.chroms=dict()
forentryinentries:
# check if the chromosome has been seen before
tree=self.chroms.get(entry.chrom)
ifnottree:
tree=ival.IntervalTree()
self.chroms[entry.chrom]=tree
# put the entry in the interval tree for the appropriate chromosome