Hi Martin,

Thanks for your help. It works.
But why mget doesn't have an argument of ignore.case like grep? I think it is 
necessary, especially when we retrieve information using gene symbols, which 
are from different databases and in different formats.

Best regards,
Xiang


2010-04-07 



xuxiang086 



发件人: Martin Morgan 
发送时间: 2010-04-07  10:47:13 
收件人: xuxiang086 
抄送: bioc-sig-sequencing 
主题: Re: [Bioc-sig-seq] mget with case-insensitive keys 
 
On 04/06/2010 06:20 PM, xuxiang086 wrote:
> Hi all,
> 
> I am using the mget function to retrieve some information from
> org.eg.Mm.db, but the keys used by mget function are case-sensitive.
> How can I make them case-insensitive? Thanks.
Hi Xiang -- I don't know whether you can. Here is a hack that might work
MGET <- function(x, envir, ..., mapWith=toupper)
{
    keys <- ls(envir)
    names(keys) <- mapWith(keys)
    mget(keys[mapWith(x)], envir, ...)
}
and then
> mget("WN", org.Mm.egSYMBOL2EG)
Error in .checkKeys(value, Rkeys(x), x...@ifnotfound) :
  value for "WN" not found
> MGET("WN", org.Mm.egSYMBOL2EG)
$wn
[1] "22407"
I haven't really tested it, and it recalculates the 'keys' map between
upper and lower case each time so is not efficient.
I wonder what your use case is?
Martin
> 
> Best regards,
> 
> Xiang
> 
> 2010-04-07
> 
> 
> 
> xuxiang086
> 
> [[alternative HTML version deleted]]
> 
> _______________________________________________ Bioc-sig-sequencing
> mailing list [email protected] 
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793

        [[alternative HTML version deleted]]

_______________________________________________
Bioc-sig-sequencing mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing

Reply via email to