You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AnnotationDbi报错:输入的ENSEMBL键无效问题求助

Fixing ENSEMBL to Gene Symbol Conversion Errors with AnnotationDbi

Hey there! Let's walk through fixing those two errors you ran into when converting ENSEMBL IDs to gene symbols with AnnotationDbi. Both issues boil down to how you're passing the keys parameter—let's break it down step by step.

First Error: object 'GeneNameEnsembl' not found

This error pops up because you haven't defined the GeneNameEnsembl variable yet. The keys argument expects a vector of actual ENSEMBL gene IDs, not just a variable name you haven't set up.

For example, if you have a list of mouse ENSEMBL IDs, you need to first store them in GeneNameEnsembl like this:

# Replace these with your actual ENSEMBL IDs
GeneNameEnsembl <- c("ENSMUSG00000000001", "ENSMUSG00000000003", "ENSMUSG00000000028")

Second Error: None of the keys entered are valid keys for 'ENSEMBL'

When you changed keys=GeneNameEnsembl to keys='GeneNameEnsembl', you told R to treat the string literal "GeneNameEnsembl" as an ENSEMBL ID—which it's not! Valid ENSEMBL IDs for mice start with ENSMUSG followed by numbers, so R can't find a match in the annotation database.

Full Working Code

Here's the complete, corrected workflow to get your gene symbols:

  1. First, make sure you have the required annotation package installed and loaded (since you're working with mouse data, we use org.Mm.eg.db):

    # Install the package if you haven't already
    if (!require("org.Mm.eg.db")) {
        BiocManager::install("org.Mm.eg.db")
    }
    library(org.Mm.eg.db)
    
  2. Define your ENSEMBL ID vector:

    # Replace with your actual list of ENSEMBL IDs
    GeneNameEnsembl <- c("ENSMUSG00000000001", "ENSMUSG00000000003", "ENSMUSG00000000028")
    
  3. Run the conversion:

    GeneNameSymbol <- AnnotationDbi::select(org.Mm.eg.db,
                                            keys = GeneNameEnsembl,
                                            columns = 'SYMBOL',
                                            keytype = 'ENSEMBL')
    

Quick Tip

If you ever want to check what valid ENSEMBL IDs look like for your organism, you can run this to see a few examples:

# View the first 5 valid mouse ENSEMBL IDs
head(keys(org.Mm.eg.db, keytype = "ENSEMBL"))

内容的提问来源于stack exchange,提问作者Maryam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 17:50:22