Skip to content

read_bed() ​

Read BED files into one table.

BED files count from 0; the table counts from 1. chromStart and thickStart are increased by 1; end positions and blockSizes are kept as they are. blockStarts become 1-based positions relative to chromStart (the first block starts at 1), so the start of a block is chromStart + blockStart - 1. track and browser lines and comments are left out.

Usage ​

python
from geneviewer import read_bed

read_bed(path)

Arguments ​

ArgumentTypeDescription
pathstr or path-likeA BED file, or a folder of them (.bed, .bed6, .bed12, ...).

Value ​

pandas.DataFrame: One row per feature, with as many of the twelve BED columns as the first line has (chrom, chromStart, chromEnd, name, ...); columns after these twelve are V13, V14, ... Columns are separated by tabs, or by spaces in a file without any tab. chrom, name, strand and itemRgb are text and score is numbers, NaN for ".". blockSizes and blockStarts are lists of numbers. For a folder, filename: the file's name without its extension.

Errors ​

ErrorWhen
FileNotFoundErrorWhen the path does not exist, or a folder has no BED files.