[Bioc-sig-seq] mget with case-insensitive keys

Martin Morgan mtmorgan at fhcrc.org
Wed Apr 7 04:47:50 CEST 2010


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 at 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 Bioc-sig-sequencing at r-project.org 
> 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



More information about the Bioc-sig-sequencing mailing list