Learn R Programming

CompGO (version 1.8.1)

annotateBedFromDb: Annotate .bed file to genes

Description

Wrapper for transcriptsByOverlaps(). Returns a GRanges with the gene and transcript ids associated with the input .bed regions. Sometimes it is necessary to expand the search window a bit, because not all .bed regions directly overlap with a transcription start site, so the 'window' parameter is provided to accomplish this.

Usage

annotateBedFromDb(pathToBed = NULL, gRanges = NULL, db = NULL, window = 5000)

Arguments

pathToBed
The system path to a .bed file (directory + file name)
gRanges
If the user has a .bed file already loaded in R, they can supply it here as a GRanges object rather than re-importing it
db
A TxDb object containing the transcripts of the organism (required)
window
The window around a .bed region to search for genes, default 5kb

Value

A GRanges object with corresponding EntrezGene IDs in gene_id column, plus transcript IDs in tx_id

Examples

Run this code
library(TxDb.Mmusculus.UCSC.mm9.knownGene)
txdb = TxDb.Mmusculus.UCSC.mm9.knownGene
data(bed.sample)
range = GRanges(seqnames=bed.sample$chr, IRanges(start=bed.sample$start, end=bed.sample$end))
x = annotateBedFromDb(gRanges = range, db = txdb)
x

Run the code above in your browser using DataLab