This is a test version of Biostars. For the public version, visit https://www.biostars.org.
What should I do with the following error? None of the keys entered are valid keys for 'ENSEMBL'.

library("AnnotationDbi")

library("org.Hs.eg.db")

anno_df$gene_name <- mapIds(org.Hs.eg.db,

  • keys=anno_df$gene_id,
  • column="SYMBOL",
  • keytype="ENSEMBL",
  • multiVals="first")

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.

deseq2 airway

1 answer

One can interpret the error literally, i.e., none of the values of anno_df$gene_id relate to Ensembl gene IDs. Can you show the output of str(anno_df$gene_id), please?

It looks like you are using the airway dataset. One can convert the Ensembl gene IDs in this dataset to gene symbols via:

  library(airway)    
  data('airway')

  # Annotate the Ensembl gene IDs to gene symbols:
    ens <- rownames(airway)

    library(org.Hs.eg.db)
    symbols <- mapIds(org.Hs.eg.db, keys = ens,
      column = c('SYMBOL'), keytype = 'ENSEMBL')
    symbols <- symbols[!is.na(symbols)]
    symbols <- symbols[match(rownames(airway), names(symbols))]
    rownames(airway) <- symbols
    keep <- !is.na(rownames(airway))
    airway <- airway[keep,]

...as I do here in my vignette for EnhancedVolcano: https://github.com/kevinblighe/EnhancedVolcano (see Quick Start)

Please also see my answer here: Translating gene names to entrez id's

Kind regards,

Kevin

This is awesome! Thank you. I am trying the conversion code you gave me but here is the output from str(anno_df$gene_id):

chr [1:34528] "5S_rRNA" "7SK" "A1BG" "A1BG-AS1" "A1CF" "A2M" "A2M-AS1" "A2ML1" "A2ML1-AS2" "A2MP1" "A3GALT2" ..

Hi, therein exists the problem, i.e., your keytype should be SYMBOL, not ENSEMBL

Log in to answer this question.