[BioC] mget() error with NA values

James W. MacDonald jmacdon at med.umich.edu
Mon May 4 16:36:13 CEST 2009


Hi Christian,

Christian Kohler wrote:
> Hi Jim, hi Herve,
> 
> thank you both for replying on my question.
> Please find below a simple code snippet that was run with R/Bioc
> (2.8.1/2.3) and (2.9.0/2.4) and reproduces my error.

What you are calling BioC 2.3 isn't the release version. You have a 
version of AnnotationDbi that was devel somewhere between 2.2 and 2.3, 
but had been updated to 1.4.3 by release.


> The first example (on the mailinglist) was a bad one (sorry Jim).
> As I mentioned, the error first appeared with the latest releases and
> causes the pipeline to break.
> 
> Jim already suggested on how to proceed and I will follow that but can
> you nevertheless tell me the background for this error?
> Have there been changes in the annotation packages? This information
> would help me to investigate and check the remaining pipeline-code.

So to answer your question, the change that affects you here wasn't made 
to the annotation packages, but to the AnnotationDbi package. There is a 
function called .checkKeysAreWellFormed() that, well, checks to see that 
keys used for lookup are well formed (e.g, there are no NA or NULL 
values and all keys are character), and more importantly returns an 
error message that clearly states what the problem was.

The second point is more important than the first, as obscure error 
messages tend to eliminate all possibility that end users might be able 
to self-diagnose their problem.

Best,

Jim


> 
> Again, I very much appreciate your help.
> 
> Best,
> Christian
> 
> 
> 
> #####################
> ##    R(2.8.1) and BioC(2.3)    ##
> #####################
> 
> options(error=recover)
> rm(list=ls(all=TRUE))
> 
> x<-"209569_x_at"
> is.upreg<-as.logical(c(0,0,1,1)) ## logical-vector as result from some
> prior calculation
> x.up<-x[is.upreg]
> x.down<-x[!is.upreg]
> library(hgu133plus2.db)
> up.out<-unique(unlist(mget(x.up,env=hgu133plus2ENTREZID,ifnotfound=NA)))
> [1] NA
> down.out<-unique(unlist(mget(x.down,env=hgu133plus2ENTREZID,ifnotfound=NA)))
> [1] "27065" NA
> 
> sessionInfo()
> R version 2.8.1 (2008-12-22)
> i686-pc-linux-gnu
> 
> locale:
> C
> 
> attached base packages:
> [1] tools     stats     graphics  grDevices datasets  utils     methods
> [8] base
> 
> other attached packages:
> [1] hgu133plus2.db_2.2.5 RSQLite_0.7-0        DBI_0.2-4
> [4] AnnotationDbi_1.3.15 Biobase_2.1.7        R.utils_1.0.1
> [7] R.oo_1.4.5           R.methodsS3_1.0.3
> 
> ####################################################################
> 
> #####################
> ##    R(2.9.0) and BioC(2.4)    ##
> #####################
> options(error=recover)
> rm(list=ls(all=TRUE))
> 
> x<-"209569_x_at"
> is.upreg<-as.logical(c(0,0,1,1)) ## logical-vector as result from some
> prior calculation
> x.up<-x[is.upreg]
> x.down<-x[!is.upreg]
> library(hgu133plus2.db)
> up.out<-unique(unlist(mget(x.up,env=hgu133plus2ENTREZID,ifnotfound=NA)))
> Error in .checkKeysAreWellFormed(keys) :
>   keys must be supplied in a character vector with no NAs
> 
> Enter a frame number, or 0 to exit
> 
>  1: unique(unlist(mget(x.up, env = hgu133plus2ENTREZID, ifnotfound = NA)))
>  2: unlist(mget(x.up, env = hgu133plus2ENTREZID, ifnotfound = NA))
>  3: mget(x.up, env = hgu133plus2ENTREZID, ifnotfound = NA)
>  4: mget(x.up, env = hgu133plus2ENTREZID, ifnotfound = NA)
>  5: `keys<-`(`*tmp*`, value = c(NA, NA))
>  6: `keys<-`(`*tmp*`, value = c(NA, NA))
>  7: switch(as.character(direction(x)), `1` = `Lkeys<-`(x, value), `-1` =
> `Rkeys
>  8: `Lkeys<-`(x, value)
>  9: `Lkeys<-`(x, value)
> 10: .checkKeys(value, Lkeys(x), x at ifnotfound)
> 11: .checkKeysAreWellFormed(keys)
> 
> down.out<-unique(unlist(mget(x.down,env=hgu133plus2ENTREZID,ifnotfound=NA)))
> Error in .checkKeysAreWellFormed(keys) :
>   keys must be supplied in a character vector with no NAs
> 
> Enter a frame number, or 0 to exit
> 
>  1: unique(unlist(mget(x.down, env = hgu133plus2ENTREZID, ifnotfound = NA)))
>  2: unlist(mget(x.down, env = hgu133plus2ENTREZID, ifnotfound = NA))
>  3: mget(x.down, env = hgu133plus2ENTREZID, ifnotfound = NA)
>  4: mget(x.down, env = hgu133plus2ENTREZID, ifnotfound = NA)
>  5: `keys<-`(`*tmp*`, value = c("209569_x_at", NA))
>  6: `keys<-`(`*tmp*`, value = c("209569_x_at", NA))
>  7: switch(as.character(direction(x)), `1` = `Lkeys<-`(x, value), `-1` =
> `Rkeys
>  8: `Lkeys<-`(x, value)
>  9: `Lkeys<-`(x, value)
> 10: .checkKeys(value, Lkeys(x), x at ifnotfound)
> 11: .checkKeysAreWellFormed(keys)
> 
> ## sessionInfo()
> R version 2.9.0 (2009-04-17)
> i686-pc-linux-gnu
> 
> locale:
> C
> 
> attached base packages:
> [1] stats     graphics  grDevices datasets  utils     methods   base
> 
> other attached packages:
> [1] hgu133plus2.db_2.2.11 RSQLite_0.7-1         DBI_0.2-4
> [4] AnnotationDbi_1.6.0   Biobase_2.4.0         R.utils_1.1.1
> [7] R.oo_1.4.6            R.methodsS3_1.0.3
> 
> 
> James W. MacDonald wrote:
>> Hi Christian,
>>
>> Christian Kohler wrote:
>>> DeaR bioconductors,
>>>
>>> we run an internal microarray analysis pipeline and switched today from
>>> R/BioC (2.8.1/2.3) to 2.9/2.4.
>>> After running some test code, I came across the following error:
>>>
>>> testCode:
>>>> x<-rep(NA,10)
>>>> unique(unlist(mget(x, env=hgu133plus2ENTREZID,ifnotfound=NA)))
>>>
>>> when I run this code snippet with 2.8.1/2.3 the corresponding return
>>> value is
>>>> [1] NA
>> Really?
>>
>>> x <- rep(NA, 10)
>>> mget(x, hgu95av2ENTREZID)
>> Error in .checkKeysAreWellFormed(keys) :
>>   keys must be supplied in a character vector with no NAs
>>> sessionInfo()
>> R version 2.8.1 (2008-12-22)
>> i386-pc-mingw32
>>
>> locale:
>> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
>> States.1252;LC_MONETARY=English_United
>> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] tools     stats     graphics  grDevices datasets  utils     methods
>> [8] base
>>
>> other attached packages:
>> [1] hgu95av2.db_2.2.5   RSQLite_0.7-1       DBI_0.2-4
>> [4] AnnotationDbi_1.4.3 Biobase_2.2.2
>>
>>
>>> but with 2.9/2.4 I got the following error:
>>>> Error during wrapup: keys must be supplied in a character vector with
>>> no NAs
>>>
>>> This causes our pipeline to break there and stop the analysis while in
>>> the previous case the analysis still continued with NA values.
>>>
>>> Please do not think that I am a picky person, but was there any urgent
>>> need to change the behaviour of mget()?
>>> Is it possible to somehow bypass this?
>> The easiest way is to strip the NA values, using the canonical
>>
>> x <- x[!is.na(x)]
>>
>> Best,
>>
>> Jim
>>
>>
>>>
>>> Thanks a lot for any help.
>>>
>>> Christian
>>>
>>>
>>>
> 
> 

-- 
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826



More information about the Bioconductor mailing list