This is one of those things that reasonable people can argue about for, like, forever, and still not come up with a wholly acceptable compromise.
We sort of did something similar with the annotation packages in the past, where if there were a one-to-many match, we returned an NA, because we figured it wasn't our decision to say which returned value was 'the right one'. These days the select function returns everything, and we are all like 'you are on your own, dude', but mapIds by default just returns the first of any multiple match, hiding from those allergic to help pages the fact that there may be more matches. There is a cogent argument for either default, and I tend to want to err on the side of more information rather than less, but then you get people wanting to know what they should do with all this unwanted extra complexity.
Yes, that might be the reason, thanks.
Based on your answer, I was able to rectify this in this way:
library(org.Hs.eg.db) library(TxDb.Hsapiens.UCSC.hg38.knownGene) geneid <- mapIds(org.Hs.eg.db, "PDCD1", "ENTREZID", "SYMBOL") hg38.genes <- genes(keepStandardChromosomes(TxDb.Hsapiens.UCSC.hg38.knownGene)) geneid %in% hg38.genes$gene_id # TRUE
Btw, this doesn't strike me as a sane default behaviour.
This is one of those things that reasonable people can argue about for, like, forever, and still not come up with a wholly acceptable compromise.
We sort of did something similar with the annotation packages in the past, where if there were a one-to-many match, we returned an NA, because we figured it wasn't our decision to say which returned value was 'the right one'. These days the
select
function returns everything, and we are all like 'you are on your own, dude', butmapIds
by default just returns the first of any multiple match, hiding from those allergic to help pages the fact that there may be more matches. There is a cogent argument for either default, and I tend to want to err on the side of more information rather than less, but then you get people wanting to know what they should do with all this unwanted extra complexity.