1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
\name{readBed}
\alias{readBed}
\title{
Read bed file
}
\description{
Read the coordinates information from a bed file.
}
\usage{
readBed(bedFile, assemblyFn=NULL)
}
\arguments{
\item{bedFile}{
\code{character}(1): filename of the \sQuote{bed} file to read.
}
\item{assemblyFn}{
\code{character}(1): filename of the twoBit or fasta file of the genome.
}
}
\details{
This function is designed to read the bed file as
\sQuote{chrom}, \sQuote{chromStart}, \sQuote{chromEnd}.
The strand information is also stored where available.
In the bed file, the \sQuote{chromStart} is on the 0-based coordinate system
while \sQuote{chromEnd} is on the 1-based coordinate system.
For example, the first 100 bases of a chromosome are
defined as \sQuote{chromStart=0}, \sQuote{chromEnd=100},
and span the bases numbered 0-99.
When it is read into \code{GRanges},
both the \sQuote{chromStart} and \sQuote{chromEnd} are on 1-based coordinate,
\emph{i.e.},
\sQuote{chromStart=1} and \sQuote{chromEnd=100}.
When \sQuote{assemblyFn} is not \code{NULL}, the corresponding \code{Seqinfo}
will be added into the returned \code{GRanges}.
}
\value{
A \code{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{
Ge Tan
}
\references{
\url{https://genome.ucsc.edu/FAQ/FAQformat.html#format1}
}
\seealso{
\code{\link{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)
}
|