jorainer / ensembldb

This is the ensembldb development repository.
https://jorainer.github.io/ensembldb
33 stars 10 forks source link

mapIds() should fail when keys are invalid #104

Closed mtmorgan closed 4 years ago

mtmorgan commented 4 years ago

This

> ensdb <- AnnotationHub()[["AH75036"]]
snapshotDate(): 2019-10-29
loading from cache
> mapIds(ensdb, "ENSG00000107562", "SYMBOL", "GENEID")
character(0)

was unexpected and it took a long time to realize that the ensdb is for mouse

> head(keys(ensdb))
[1] "ENSMUSG00000000001" "ENSMUSG00000000003" "ENSMUSG00000000028"
[4] "ENSMUSG00000000031" "ENSMUSG00000000037" "ENSMUSG00000000049"

but the keys are from humans.

I was thinking first that mapIds() should have returned a named character vector equal to the length of the input, and perhaps that the invalid keys should have signaled a warning or error as in OrgDb

> mapIds(org.Hs.eg.db, "ENSMUSG00000000001", "SYMBOL", "ENSEMBL")
Error in .testForValidKeys(x, keys, keytype, fks) : 
  None of the keys entered are valid keys for 'ENSEMBL'. Please use the keys method to see a listing of valid arguments.
jorainer commented 4 years ago

Thanks Martin for reporting. You are right, mapIds() should indeed return a character same length of the input. And a warning if something is strange wouldn't hurt either.

Will fix that.

jorainer commented 4 years ago

Fixed in version 2.10.1 - pushed to branch RELEASE_3_10:

ensdb <- AnnotationHub()[["AH75036"]]
mapIds(ensdb, "ENSG00000107562", "SYMBOL", "GENEID")
ENSG00000107562 
             NA 
Warning message:
In .mapIds(x = x, keys = keys, column = column, keytype = keytype,  :
  Unable to map 1 of 1 requested IDs.
jorainer commented 4 years ago

I'm tentatively closing this issue - feel free to re-open if needed @mtmorgan