[R] [BioC] comparing two tables

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Oct 26 16:57:56 CEST 2011


Hi Assa,


On Wed, Oct 26, 2011 at 9:44 AM, Assa Yeroslaviz <frymor at gmail.com> wrote:
> Thanks Steve,
>
> I already did it and it went perfectly well.
>
> I was just trying to understand the functions David wrote, so that I can use
> them maybe for other queries.
> Unfortunately I wasn't able to add a condition for the fact that there is a
> third parameter to be compared.
>
> I would still ove to know whether there is a way of adding such a perameter.

Sorry, I didn't realize you were after some personal "R study"

> I tried to do it with a third argument in this line:       any( apply(locs,
> 1, function(x){vec["start"]>x[2] & vec["start"]<=x[3] &
> as.character(vec["chr"])==as.character(x["chr"])
> but it doesn't seems to work at all.

You have to change the "table" you are sending to the second param of
your "inregion" function.

currently you are sending into the `locs` parameter a two column table
that just has c("Start", "End"), eg:

R> Think about inregion(genetable[2, ], loctable[, c("Start", "End")])

Look at what `loctable[, c("Start", "End")]` gives you

It looks like your change to inregion should work once you pass in the
"Chr" column from your loctable (barring case-sensitive issues (you
have 'chr' and "Chr" in your separate tables), eg use your modified
inregion function and call it like so:

R> inregion(genetable[2, ], loctable[, c("Chr", "Start", "End")])

modulo this or that.


-- 
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 R-help mailing list