Hi Valerie,

  speaking of distance and nearest methods, a friend/colleague would like
the option to have "signed" distances based on strand.  I started
implementing this (it looked like a 2-liner) and then thought, "hmmm, maybe
I better see if this belongs in C".  Is there any reason for me not to
percolate "signByStrand" through the distanceToNearest and distance methods
if I'm writing a patch?

  Writing this out, I suspect I know the answer ("profile it yourself,
knucklehead!") but it seemed like a good question at the time.

  If you have any thoughts on the matter before I time the patched version,
please let me know.

  Thanks,

--t


On Wed, Sep 5, 2012 at 9:14 AM, Valerie Obenchain <vobencha@fhcrc.org>wrote:

> Hi Dario,
>
> Thanks for catching this. Now fixed in GenomicRanges 1.9.61.
>
> It was already the case for nearest,GenomicRanges,**GenomicRanges that
> self-hits were found when both 'x' and 'subject' were present but not when
> only 'x' was provided. The problem in distanceToNearest was that when
> 'subject' was missing it was set equal to 'x' before calling nearest. This
> resulted in self-hits being found regardless of how the method was called.
>  distanctToNearst now behaves appropriately,.
>
>
> gr <- GRanges("1", IRanges(c(1, 10, 1000), width=2), "+")
> > gr
>
> GRanges with 3 ranges and 0 metadata columns:
>       seqnames       ranges strand
> <Rle> <IRanges> <Rle>
>   [1]        1 [   1,    2]      +
>   [2]        1 [  10,   11]      +
>   [3]        1 [1000, 1001]      +
>   ---
>   seqlengths:
>     1
>    NA
>
> When only 'x' is provided no self-hits are found,
>
> > distanceToNearest(gr)
>
> DataFrame with 3 rows and 3 columns
>   queryHits subjectHits  distance
> <integer> <integer> <integer>
> 1         1           2         8
> 2         2           1         8
> 3         3           2       989
>
> When both 'x' and 'subject' are provided self-hits are found,
>
> > distanceToNearest(gr, gr)
>
> DataFrame with 3 rows and 3 columns
>   queryHits subjectHits  distance
> <integer> <integer> <integer>
> 1         1           1         0
> 2         2           2         0
> 3         3           3         0
>
>
> Valerie
>
>
> On 09/04/2012 11:00 PM, Dario Strbenac wrote:
>
>> Hello,
>>
>> In findOverlaps, there is an argument ignoreSelf, that means overlaps
>> aren't found for the same range when only the query object is provided. I
>> was hoping I could use something similar for the distanceToNearest function
>> in GenomicRanges, with only the query provided. Would this be a worthwhile
>> addition ?
>>
>> Example :
>>
>>  g1
>>>
>> GRanges with 3 ranges and 0 metadata columns:
>>        seqnames       ranges strand
>>           <Rle>     <IRanges>   <Rle>
>>    [1]        1 [   1,    2]      +
>>    [2]        1 [  10,   11]      +
>>    [3]        1 [1000, 1010]      +
>>    ---
>>    seqlengths:
>>      1
>>     NA
>>
>>> distanceToNearest(g1, ignoreSelf = TRUE) # Not implemented
>>>
>> DataFrame with 3 rows and 3 columns
>>    queryHits subjectHits  distance
>>    <integer>    <integer>  <integer>
>> 1         1           1         0
>> 2         2           2         0
>> 3         3           3         0
>>
>>> findOverlaps(g1, ignoreSelf = TRUE) # Implemented
>>>
>> Hits of length 0
>> queryLength: 3
>> subjectLength: 3
>>
>> ------------------------------**--------
>> Dario Strbenac
>> PhD Student
>> University of Sydney
>> Camperdown NSW 2050
>> Australia
>>
>> ______________________________**_________________
>> Bioc-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/**listinfo/bioc-devel<https://stat.ethz.ch/mailman/listinfo/bioc-devel>
>>
>
> ______________________________**_________________
> Bioc-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/bioc-devel<https://stat.ethz.ch/mailman/listinfo/bioc-devel>
>



-- 
*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]]

