Or perhaps something like this?

library(TxDb.appropriateOrganism.appropriateAssembly)
tx.ranges <-  transcripts(TxDb, columns=c('tx_id','gene_id'))
dist.to.tx <- distanceToNearest(your.ranges, tx.ranges)
dist.to.tx
R> dist.to.tx
## DataFrame with 500000 rows and 3 columns
##        queryHits subjectHits  distance
##        <integer>   <integer> <integer>
## 1              1        3965         0
## 2              2        3965         0
## 3              3        3975         0
## 4              4        3975         0
## 5              5        3975         0
## 6              6           4       241
## 7              7           4         0
## 8              8           4     21542
## 9              9        3979      1445
## ...          ...         ...       ...
##
## get Entrez IDs for the nearest genes to the first 6 ranges (obviously
you can do them all)
##
gene_ids <-
as.character(values(tx.ranges[head(dist.to.tx)$subjectHits])$gene_id)
##
## get their symbols
##
unlist(mget(gene_ids, org.Hs.egSYMBOL, ifnotfound=NA))
##
##  653635   653635   653635   653635   653635    79501
## "WASH7P" "WASH7P" "WASH7P" "WASH7P" "WASH7P"  "OR4F5"
##
## get their distances (again just the first 6)
##
head(dist.to.tx$distance)
## [1]   0   0   0   0   0 241

Is that what you are after?

Note: annotatePeakInBatch() might well be just as good or better; I am not
very proficient with ChIPseq packages in R since I mostly use MACS and
ChromHMM for the things I am interested in.  So, no offense meant to any
authors of the many fine ChIPseq packages!  distanceToNearest() is just a
handy new function in GenomicRanges which I have found to provide a fast,
generally useful tool.

--t




On Thu, May 17, 2012 at 9:52 AM, Zhu, Lihua (Julie)
<Julie.Zhu@umassmed.edu>wrote:

> Yadav,
>
> You could try annotatePeakInBatch in ChIPpeakAnno package.
>
> Best regards,
>
> Julie
>
>
> On 5/17/12 12:40 PM, "Yadav Sapkota" <ysapkota@ualberta.ca> wrote:
>
> > Hi,
> >
> > Is there any tool or package that can query neighboring genes (lets say
> 100
> > KB upstream and downstream) of a specific chromosomal range
> (chr1:100-200)?
> > I have thousands of these chromosomal ranges.
> >
> > You help will be greatly appreciated.
> >
> > Regards,
> > Yadav Sapkota
> > Uni of Alberta
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives:
> > http://news.gmane.org/gmane.science.biology.informatics.conductor
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>



-- 
*A model is a lie that helps you see the truth.*
*
*
Howard Skipper<http://cancerres.aacrjournals.org/content/31/9/1173.full.pdf>

	[[alternative HTML version deleted]]

