Body: <p>I am trying to convert my gene_id accessions given by the RNAseq as EntrezGene gene numbers into Ensemble annotation. I need the Ensemble annotation for further GO analysis. I am using BiomaRT package in R studio.</p>
  <p>In order to create a list with all my EntrezGene IDs I did the following:</p>
  <pre class="lang-r prettyprint-override"><code>gene_data &lt;- read_excel('gene_diff_control vs treatment.xls')
  mygenes &lt;- gene_data$gene_id  # gene_id is the column containing the EntrezGene IDs
  
  # here is an example of the gene_id`s I have in my file: gene_diff_control vs treatmen.xls&quot;
  # 27304 
  # 8228
  # 83698
  # 7283
  # and so on till row number 16,620
  
  # then I use the following code:
  hsmart &lt;- useMart(dataset = &quot;hsapiens_gene_ensembl&quot;, biomart = &quot;ensembl&quot;)
  
  mapping &lt;- getBM(
      attributes = c('ensembl_gene_id', 'ensembl_transcript_id', 'entrezgene_id', 'hgnc_symbol'),
      filters = 'hgnc_symbol',
      values = mygenes,
      mart = hsmart
  )
  
  #Eventually the mapping gets 0 entries:
  [1] ensembl_gene_id       ensembl_transcript_id entrezgene_id        
  [4] hgnc_symbol          
  &lt;0 rows&gt; (or 0-length row.names)
  
  # So I modified my code in order to use the 'gene_symbol' instead
  
  mygenes &lt;- gene_data$gene_symbol
  hsmart &lt;- useMart(dataset = &quot;hsapiens_gene_ensembl&quot;, biomart = &quot;ensembl&quot;)
  mapping &lt;- getBM(
      attributes = c('ensembl_gene_id', 'ensemble_gene_id_version', 'ensembl_transcript_id', 'entrezgene_id', 'hgnc_symbol'),
      filters = 'hgnc_symbol',
      values = mygenes,
      mart = hsmart
  )
  </code></pre>
  <p>But then, the resulting mapping output contain more than 300,000 rows of mapping data between EntrezGene ID and Ensemble gene IDs not related to my dataset.</p>
  <p>What am I doing wrong?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-23T14:29:58.573Z
Comments.Text: Change `filter` to `entrez_gene_id` - the IDs you have are not `hgnc_symbol`.
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-23T15:45:54.117Z
Comments.Text: I am not 100% sure but the 300,000 rows might be corresponding to the transcripts, you have `'ensembl_transcript_id'` within the `attributes` argument when calling `getBM()`.
Comments.UserDisplayName: haci
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-24T09:33:48.523Z
Comments.Text: Something went wrong with this post. I had two very useful comments and now they are gone!!! If any of you guys see this post again, please write again what you think about the issue described above.
Comments.UserDisplayName: Petar
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-24T12:21:33.873Z
Comments.Text: Now I`ve simplified the code to the following lines:
  
  >library(biomaRt)
  >ensembl <- useEnsembl(biomart = "genes", dataset = "hsapiens_gene_ensembl")
  >gene_data <- read_excel('MyData.xls')
  >mygenes <- gene_data$gene_id
  
  >hsmart <- useMart(dataset = "hsapiens_gene_ensembl", biomart = "ensembl")
  > mapping <- getBM(
  +          attributes = 'ensembl_gene_id',
  +          filters = 'entrezgene_id', #
  +          values = mygenes,
  +          mart = hsmart
  +      )
  
  my data set contains 16620 rows. The output of mapping is 18773 rows with corresponding ensemble gene IDs. 
  What is wrong?
Comments.UserDisplayName: Petar
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-04-26T13:36:28.580Z
Comments.Text: Please update the question with the changes you have made. I have undeleted the comments. If they are indeed helpful and solve the issue, it would be great if you could post an answer explaining how you solved it with their guidance.
Comments.UserDisplayName: terdon
Tags: <read-mapping>
Title: Converting EntrezGene IDs to Ensemble IDs
ThreadText: # Converting EntrezGene IDs to Ensemble IDs
  
  (Asked by: username_0 on 2024-04-23)
  
  I am trying to convert my gene\_id accessions given by the RNAseq as EntrezGene gene numbers into Ensemble annotation. I need the Ensemble annotation for further GO analysis. I am using BiomaRT package in R studio.
  
  In order to create a list with all my EntrezGene IDs I did the following:
  
  ```r
  gene_data <- read_excel('gene_diff_control vs treatment.xls')
  mygenes <- gene_data$gene_id  # gene_id is the column containing the EntrezGene IDs
  
  # here is an example of the gene_id`s I have in my file: gene_diff_control vs treatmen.xls"
  # 27304 
  # 8228
  # 83698
  # 7283
  # and so on till row number 16,620
  
  # then I use the following code:
  hsmart <- useMart(dataset = "hsapiens_gene_ensembl", biomart = "ensembl")
  
  mapping <- getBM(
      attributes = c('ensembl_gene_id', 'ensembl_transcript_id', 'entrezgene_id', 'hgnc_symbol'),
      filters = 'hgnc_symbol',
      values = mygenes,
      mart = hsmart
  )
  
  #Eventually the mapping gets 0 entries:
  [1] ensembl_gene_id       ensembl_transcript_id entrezgene_id        
  [4] hgnc_symbol          
  <0 rows> (or 0-length row.names)
  
  # So I modified my code in order to use the 'gene_symbol' instead
  
  mygenes <- gene_data$gene_symbol
  hsmart <- useMart(dataset = "hsapiens_gene_ensembl", biomart = "ensembl")
  mapping <- getBM(
      attributes = c('ensembl_gene_id', 'ensemble_gene_id_version', 'ensembl_transcript_id', 'entrezgene_id', 'hgnc_symbol'),
      filters = 'hgnc_symbol',
      values = mygenes,
      mart = hsmart
  )
  
  ```
  
  But then, the resulting mapping output contain more than 300,000 rows of mapping data between EntrezGene ID and Ensemble gene IDs not related to my dataset.
  
  What am I doing wrong?
  
  **Tags:** read-mapping
  
  > **Comments:**
  > **username_1**: Change `filter` to `entrez_gene_id` - the IDs you have are not `hgnc_symbol`.  
  > **username_2**: I am not 100% sure but the 300,000 rows might be corresponding to the transcripts, you have `'ensembl_transcript_id'` within the `attributes` argument when calling `getBM()`.  
  > **username_0**: Something went wrong with this post. I had two very useful comments and now they are gone!!! If any of you guys see this post again, please write again what you think about the issue described above.  
  > **username_0**: Now I`ve simplified the code to the following lines:  >library(biomaRt) >ensembl <- useEnsembl(biomart = "genes", dataset = "hsapiens_gene_ensembl") >gene_data <- read_excel('MyData.xls') >mygenes <- gene_data$gene_id  >hsmart <- useMart(dataset = "hsapiens_gene_ensembl", biomart = "ensembl") > mapping <- getBM( +          attributes = 'ensembl_gene_id', +          filters = 'entrezgene_id', # +          values = mygenes, +          mart = hsmart +      )  my data set contains 16620 rows. The output of mapping is 18773 rows with corresponding ensemble gene IDs.  What is wrong?  
  > **username_3**: Please update the question with the changes you have made. I have undeleted the comments. If they are indeed helpful and solve the issue, it would be great if you could post an answer explaining how you solved it with their guidance.  
  
  ---
  
  ## 0 answers
  
  