Body: <p>I am trying to convert a list of gene names into Ensembl IDs but I'm having a bit of trouble.</p>
  
  <p>I've tried using the EnsDb.Hsapiens.v86 package but I always get LRG-ID values returned as well, even when using the GeneIdFilter "startsWith" thing.<br>
  My code looks like this:</p>
  
  <pre><code>targets &lt;- as.character(targetCSV[, 2])
  
  
  targetEnsemble &lt;- ensembldb::select(
        EnsDb.Hsapiens.v86, 
        filter = GeneIdFilter("ENS", "startsWith"),
        keys = targets, 
        keytype = "SYMBOL", 
        columns = c("SYMBOL","GENEID"))
  </code></pre>
  
  <p>And for example I get back:</p>
  
  <pre><code>    SYMBOL          GENEID
  1     CYR61 ENSG00000142871
  2      CTGF ENSG00000118523
  3    AMOTL2 ENSG00000114019
  4    ANKRD1 ENSG00000148677
  5    ANKRD1         LRG_379
  6    IGFBP3 ENSG00000146674
  7        F3 ENSG00000117525
  </code></pre>
  
  <p>I also tried using org.Hs.eg.db package but get a different problem where some of my genes return NA.</p>
  
  <p>My code:</p>
  
  <pre><code>  mapIds(x = org.Hs.eg.db, 
       keys = targets, 
       "ENSEMBL", 
       "SYMBOL",
       fuzzy = TRUE,
       multiVals = first)
  </code></pre>
  
  <p>And this works on some but not all the genes for some reason.</p>
  
  <pre><code>    $CYR61
  [1] NA
  
  $CTGF
  [1] NA
  
  $AMOTL2
  [1] "ENSG00000114019"
  
  $ANKRD1
  [1] "ENSG00000148677"
  
  $IGFBP3
  [1] "ENSG00000146674"
  
  $F3
  [1] "ENSG00000117525"
  </code></pre>
  
  <p>If anyone can solve either of these problems that would be great, thanks in advance!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-24T13:54:05.070Z
Comments.Text: Have you considered just downloading a list of gene IDs and the associated gene names from Ensembl Biomart?
Comments.UserDisplayName: Devon Ryan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-24T14:08:11.130Z
Comments.Text: Yeah but I wanted to be able to change out the genesets quickly and this just added another annoying step
Comments.UserDisplayName: Jack Henry
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-24T14:21:09.763Z
Comments.Text: There's an R package to allow fetching those programmatically from biomart.
Comments.UserDisplayName: Devon Ryan
Tags: <r><gene><ensembl>
Title: How to map gene names to ensembl Ids in R
ThreadText: # How to map gene names to ensembl Ids in R
  
  (Asked by: username_0 on 2020-04-24)
  
  I am trying to convert a list of gene names into Ensembl IDs but I'm having a bit of trouble.
  
  I've tried using the EnsDb.Hsapiens.v86 package but I always get LRG-ID values returned as well, even when using the GeneIdFilter "startsWith" thing.  
  My code looks like this:
  
  ```
  targets <- as.character(targetCSV[, 2])
  
  targetEnsemble <- ensembldb::select(
        EnsDb.Hsapiens.v86, 
        filter = GeneIdFilter("ENS", "startsWith"),
        keys = targets, 
        keytype = "SYMBOL", 
        columns = c("SYMBOL","GENEID"))
  
  ```
  
  And for example I get back:
  
  ```
      SYMBOL          GENEID
  1     CYR61 ENSG00000142871
  2      CTGF ENSG00000118523
  3    AMOTL2 ENSG00000114019
  4    ANKRD1 ENSG00000148677
  5    ANKRD1         LRG_379
  6    IGFBP3 ENSG00000146674
  7        F3 ENSG00000117525
  
  ```
  
  I also tried using org.Hs.eg.db package but get a different problem where some of my genes return NA.
  
  My code:
  
  ```
    mapIds(x = org.Hs.eg.db, 
       keys = targets, 
       "ENSEMBL", 
       "SYMBOL",
       fuzzy = TRUE,
       multiVals = first)
  
  ```
  
  And this works on some but not all the genes for some reason.
  
  ```
      $CYR61
  [1] NA
  
  $CTGF
  [1] NA
  
  $AMOTL2
  [1] "ENSG00000114019"
  
  $ANKRD1
  [1] "ENSG00000148677"
  
  $IGFBP3
  [1] "ENSG00000146674"
  
  $F3
  [1] "ENSG00000117525"
  
  ```
  
  If anyone can solve either of these problems that would be great, thanks in advance!
  
  **Tags:** r, gene, ensembl
  
  > **Comments:**
  > **username_1**: Have you considered just downloading a list of gene IDs and the associated gene names from Ensembl Biomart?  
  > **username_0**: Yeah but I wanted to be able to change out the genesets quickly and this just added another annoying step  
  > **username_1**: There's an R package to allow fetching those programmatically from biomart.  
  
  ---
  
  ## 0 answers
  
  