[BioC] GRanges DitancetoNearest query

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Aug 20 17:14:18 CEST 2012


Hi,

On Mon, Aug 20, 2012 at 7:41 AM, d r <dolevrahat at gmail.com> wrote:
> I am attempting to use GRanges to calculate the distances between
> certain  probes
> and their nearest respective transcription start sites. I have created two
> GRanges objects,  one containing  the position of the probes and another
> containing the positions of the genes (which I produced from USCS Table
> Browser).
>
> This is the code I used:
>
> genes<-GRanges(seqnames=refseq[,1],ranges=IRanges(start=refseq[,4],end=refseq[,5]),strand=refseq[,3],gene=refseq[,11])
>
> probes<-GRanges(seqnames=annotations[,3],ranges=IRanges(start=annotations[,4],end=annotations[,4]),probe=annotations[,1])
>
> distance_from_TSS<-distanceToNearest(probes,genes)
>
> when I tried to run the last command I got this error message:
>
> Error in function (classes, fdef, mtable)  :
>
>   unable to find an inherited method for function "distanceToNearest", for
> signature "GRanges", "GRanges"

Can we get the output of your sessionInfo() please?

This seems to work find here:

R> gr <- GRanges('chr1', IRanges(c(10, 50), width=10), '+')
R> gg <- GRanges('chr1', IRanges(c(1, 30, 80), width=10), '+')
R> distanceToNearest(gr, gg)
DataFrame with 2 rows and 3 columns
  queryHits subjectHits  distance
  <integer>   <integer> <integer>
1         1           2        11
2         2           3        21

R> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] GenomicRanges_1.9.48 IRanges_1.15.35      BiocGenerics_0.3.1

HTH,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the Bioconductor mailing list