One thing worth adding for anyone landing here from search: alias lookups are one-to-many, and some tools pick a winner silently.
In R, rescuing the unmatched genes is a small change ' switch the keytype from SYMBOL to ALIAS:
library(org.Hs.eg.db)
genes <- c("TP53", "CCDC109B", "C11orf59", "SEPT2")
hits <- AnnotationDbi::select(org.Hs.eg.db, keys = genes,
columns = c("SYMBOL", "ENTREZID"),
keytype = "ALIAS")
hits
# ALIAS ENTREZID SYMBOL
# TP53 7157 TP53
# CCDC109B 55013 MCUB
# C11orf59 55004 LAMTOR1
# SEPT2 4735 SEPTIN2
# SEPT2 23157 SEPTIN6
Note SEPT2: it is a previous symbol of SEPTIN2 and an alias of SEPTIN6, so it maps to two different genes. Before joining back to the DE table, find those cases and resolve them by hand (or drop them):
ambiguous <- names(which(table(hits$ALIAS) > 1))
The trap is that the convenient functions hide this. mapIds(org.Hs.eg.db, genes, "ENTREZID", keytype = "ALIAS") returns a single ID for SEPT2 (4735) with only a "1:many mapping" message, and limma::alias2SymbolTable() returns just SEPTIN2 plus a warning that multiple symbols were ignored - easy to miss in a long script, and in a DE list it quietly attaches the wrong gene to a result. HGNChelper::checkGeneSymbols() keeps the ambiguity visible (SEPTIN2 /// SEPTIN6), which is safer.
With ~800 rescued genes out of 6200, two more things are worth doing:
- record the annotation version you used (
packageVersion("org.Hs.eg.db")) — alias tables change between Bioconductor releases, which is also why symbols from older datasets such as TCGA stop matching;
- keep a column saying how each gene was matched (exact symbol vs alias), so the 13% that were rescued stay identifiable.
Disclosure: for the same problem in Python I wrote gene-tidy (pip install gene-tidy or conda install -c bioconda gene-tidy). It runs offline against a bundled HGNC snapshot and writes ambiguous cases like SEPT2 to a separate file instead of choosing one. If you're working in R, though, the approach above or HGNChelper is all you need. https://github.com/MargoSolo/gene-tidy