Answers.Body: <p>Here's a Python script (e.g., called <code>map_entrez_to_ensembl.py</code> that uses <a href="https://github.com/biothings/mygene.py" rel="nofollow noreferrer">mygene.info</a> to convert a list of Entrez IDs to Ensembl gene names:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import sys
  import mygene
  
  mg = mygene.MyGeneInfo()
  
  genes = ['3815',
           '3816',
           '2341']
  
  results = mg.querymany(genes, scopes=['entrezgene'], fields=['ensembl'], species='human', verbose=False)
  
  for res in results:
      entrez_id = res['query']
      if 'ensembl' in res and 'gene' in res['ensembl']:
          sys.stdout.write('%s\t%s\n' % (entrez_id, res['ensembl']['gene']))
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>$ ./map_entrez_to_ensembl.py 
  3815    ENSG00000157404
  3816    ENSG00000167748
  </code></pre>
  
  <p>Looks like there's an <a href="https://www.bioconductor.org/packages/release/bioc/html/mygene.html" rel="nofollow noreferrer">R-based interface to mygene.info</a>, if you really need to use R.</p>
  
  <p>You could use their <a href="http://mygene.info/tryapi/" rel="nofollow noreferrer">API test page</a> to see how data are structured and what keywords are available for different kinds of searches. </p>
  
  <p>For instance, if you wanted aliases, in addition to Ensembl names:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import sys
  import mygene
  
  mg = mygene.MyGeneInfo()
  
  genes = ['3815',
           '3816',
           '2341']
  
  results = mg.querymany(genes, scopes=['entrezgene'], fields=['ensembl', 'alias'], species='human', verbose=False)
  
  for res in results:
      entrez_id = res['query']
      if 'ensembl' in res and 'gene' in res['ensembl'] and 'alias' in res:
          for alias in res['alias']:
              sys.stdout.write('%s\t%s\t%s\n' % (entrez_id, alias, res['ensembl']['gene']))
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>$ ./map_entrez_to_alias_and_ensembl.py
  3815    C-Kit   ENSG00000157404
  3815    CD117   ENSG00000157404
  3815    PBT     ENSG00000157404
  3815    SCFR    ENSG00000157404
  3816    KLKR    ENSG00000167748
  3816    Klk6    ENSG00000167748
  3816    hK1     ENSG00000167748
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-28T00:45:17.663Z
Answers.LastActivityDate: 2018-04-29T23:12:11.423Z
Answers.LastEditDate: 2018-04-29T23:12:11.423Z
Answers.UserDisplayName: Alex Reynolds
Body: <p>I have downloaded KIRC Methylation data (450K) using TCGA toolbox. The beta values given are with reference to CPG probes. Is there any package or function in R through which I can get the gene names corresponding to these probes? I was able to get the gene I.Ds using <code>getMappedEntrezIDs</code>. Is there any function to map these I.Ds to respective gene names?</p>
  
Tags: <r><illumina>
Title: Get gene names corresponding to CPG probes
ThreadText: # Get gene names corresponding to CPG probes
  
  (Asked by: username_0 on 2018-04-27)
  
  I have downloaded KIRC Methylation data (450K) using TCGA toolbox. The beta values given are with reference to CPG probes. Is there any package or function in R through which I can get the gene names corresponding to these probes? I was able to get the gene I.Ds using `getMappedEntrezIDs`. Is there any function to map these I.Ds to respective gene names?
  
  **Tags:** r, illumina
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-04-28. Score: 3 | Accepted answer
  
  Here's a Python script (e.g., called `map_entrez_to_ensembl.py` that uses [mygene.info](https://github.com/biothings/mygene.py) to convert a list of Entrez IDs to Ensembl gene names:
  
  ```
  #!/usr/bin/env python
  
  import sys
  import mygene
  
  mg = mygene.MyGeneInfo()
  
  genes = ['3815',
           '3816',
           '2341']
  
  results = mg.querymany(genes, scopes=['entrezgene'], fields=['ensembl'], species='human', verbose=False)
  
  for res in results:
      entrez_id = res['query']
      if 'ensembl' in res and 'gene' in res['ensembl']:
          sys.stdout.write('%s\t%s\n' % (entrez_id, res['ensembl']['gene']))
  
  ```
  
  Result:
  
  ```
  $ ./map_entrez_to_ensembl.py 
  3815    ENSG00000157404
  3816    ENSG00000167748
  
  ```
  
  Looks like there's an [R-based interface to mygene.info](https://www.bioconductor.org/packages/release/bioc/html/mygene.html), if you really need to use R.
  
  You could use their [API test page](http://mygene.info/tryapi/) to see how data are structured and what keywords are available for different kinds of searches.
  
  For instance, if you wanted aliases, in addition to Ensembl names:
  
  ```
  #!/usr/bin/env python
  
  import sys
  import mygene
  
  mg = mygene.MyGeneInfo()
  
  genes = ['3815',
           '3816',
           '2341']
  
  results = mg.querymany(genes, scopes=['entrezgene'], fields=['ensembl', 'alias'], species='human', verbose=False)
  
  for res in results:
      entrez_id = res['query']
      if 'ensembl' in res and 'gene' in res['ensembl'] and 'alias' in res:
          for alias in res['alias']:
              sys.stdout.write('%s\t%s\t%s\n' % (entrez_id, alias, res['ensembl']['gene']))
  
  ```
  
  Then:
  
  ```
  $ ./map_entrez_to_alias_and_ensembl.py
  3815    C-Kit   ENSG00000157404
  3815    CD117   ENSG00000157404
  3815    PBT     ENSG00000157404
  3815    SCFR    ENSG00000157404
  3816    KLKR    ENSG00000167748
  3816    Klk6    ENSG00000167748
  3816    hK1     ENSG00000167748
  
  ```
  
  
  ---
  
  