readBed: Read bed file

View source: R/IO-methods.R

readBedR Documentation

Read bed file

Description

Read the coordinates information from a bed file.

Usage

  readBed(bedFile, assemblyFn=NULL)

Arguments

bedFile

character(1): filename of the ‘bed’ file to read.

assemblyFn

character(1): filename of the twoBit or fasta file of the genome.

Details

This function is designed to read the bed file as ‘chrom’, ‘chromStart’, ‘chromEnd’. The strand information is also stored where available.

In the bed file, the ‘chromStart’ is on the 0-based coordinate system while ‘chromEnd’ is on the 1-based coordinate system. For example, the first 100 bases of a chromosome are defined as ‘chromStart=0’, ‘chromEnd=100’, and span the bases numbered 0-99. When it is read into GRanges, both the ‘chromStart’ and ‘chromEnd’ are on 1-based coordinate, i.e., ‘chromStart=1’ and ‘chromEnd=100’.

When ‘assemblyFn’ is not NULL, the corresponding Seqinfo will be added into the returned GRanges.

Value

A GRanges object is returned. When no strand information is available in the bed file, all the ranges are assumed to be on the positive strand.

Author(s)

Ge Tan

References

https://genome.ucsc.edu/FAQ/FAQformat.html#format1

See Also

import.bed

Examples

  bedFn <- file.path(system.file("extdata", package="CNEr"), 
                     "filter_regions.hg38.bed")
  assemblyFn <- file.path(system.file("extdata",
                          package="BSgenome.Hsapiens.UCSC.hg38"),
                          "single_sequences.2bit")
  bed <- readBed(bedFn, assemblyFn=assemblyFn)

ge11232002/CNEr documentation built on Oct. 26, 2022, 7:08 p.m.