text: user2247: 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?
  
  user776: Here's a Python script (e.g., called map_entrez_to_ensembl.py that uses mygene.info 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, if you really need to use R.
  You could use their API test page 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
  
  
original_text: 2247: <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>
   776: <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>
  