On Fri, Jan 23, 2009 at 2:30 AM, Daniel Brewer <daniel.brewer@icr.ac.uk>wrote:

> Hello,
>
> Is there any way to add rownames to an IRanges object?  What I am trying
> to do is try and make it easy to reference back to the original table
> that created the IRanges object after an overlap.
>
> Hs1plus <- with(HsapiensAnnot[HsapiensAnnot$seqname == "1" &
> HsapiensAnnot$strand == "+",], IRanges(start, end))
>
> yoda1plus <- with(yip[yip$seqname == "chr1" & yip$strand == "+",],
> IRanges(start, end))
> yoda1plus <- yoda1plus[order(start(yoda1plus)),]
>
> seqoverlap <- overlap(Hs1plus,yoda1plus,multiple=F)
>
> At the moment to get information about the overlaps I have to do
> something like:
> HsapiensAnnot[HsapiensAnnot$start == start(Hs1plus[seqoverlap[1],]) &
> HsapiensAnnot$seqname=="1",]
>
> but I am sure that there is a better way and this can't deal with the
> NAs that might be in seqoverlap
>

Patrick answered the names question, but I'd also like to suggest using
RangedData here. It looks like you're getting your data from a GFF file.
With rtracklayer, you could import() this directly into a RangedData.

This would make things a fair bit easier:

yoda1plus <- ranges(yip[strand(yip) == "+",])
ans <- HsapiensAnnot[strand(HsapiensAnnot) == "+",][yoda1plus]

'ans' would contain the RangedData with the annotations on the positive
strand, that overlap with the IRanges yoda1plus, across all chromosomes.

Couple of caveats:
- the chromosomes should be named the same between the two datasets (eg of
the form chr1).
- the ranges in yip should have been sorted
- requires development versions of IRanges and rtracklayer

Michael


> Thanks
>
> Dan
> --
> **************************************************************
> Daniel Brewer, Ph.D.
>
> Institute of Cancer Research
> Molecular Carcinogenesis
> Email: daniel.brewer@icr.ac.uk
> **************************************************************
>
> The Institute of Cancer Research: Royal Cancer Hospital, a charitable
> Company Limited by Guarantee, Registered in England under Company No. 534147
> with its Registered Office at 123 Old Brompton Road, London SW7 3RP.
>
> This e-mail message is confidential and for use by the...{{dropped:13}}

