This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to convert gene IDs to gene symbols in R?

I am performing PCA in R and I got top 10 measurements (genes) that contribute for PC1:

loading_scores <- pca$rotation[,1]
gene_scores <- abs(loading_scores) ## get the magnitudes
gene_score_ranked <- sort(gene_scores, decreasing=TRUE)
top_10_genes <- names(gene_score_ranked[1:10])
top_10_genes

output:

 [1] "ENSG00000169018.5"  "ENSG00000181038.13" "ENSG00000103275.18" "ENSG00000174796.12"
 [5] "ENSG00000164087.7"  

How can I convert the ouputs from "gene IDs" into gene symbols? so that the outputs be like:

FEM1B

METTL23

UBE2I

etc..

Thanks in advance

gene r pca ids

for humans, use org.hs.eg.db

yes for humans, but how?

1 answer

Hello, please check my answer, here: Translating gene names to entrez id's

Note that you will need to remove those numerical suffixes from the Ensembl gene IDs

I run the first command:

library(org.Hs.eg.db)
mapIds(
  org.Hs.eg.db,
  keys = genes,
  column = 'ENTREZID',
  keytype = 'SYMBOL')
select(
  org.Hs.eg.db,
  keys = genes,
  column = c('SYMBOL', 'ENTREZID', 'ENSEMBL'),
  keytype = 'SYMBOL')

But I still cant convert the extracted genesIDs to the symbols? How related to that code? Where I should put top_10_genes?

Thanks for answering

require(org.Hs.eg.db)

mapIds(
  org.Hs.eg.db,
  keys = genes,
  column = 'SYMBOL',
  keytype = 'ENSEMBL')

select(
  org.Hs.eg.db,
  keys = genes,
  column = c('SYMBOL', 'ENTREZID', 'ENSEMBL'),
  keytype = 'ENSEMBL')

How related to that code? Where I should put top_10_genes?

I have provided enough information such that you should be able to adapt my code to your own code. Please review my answer via the other link, to help you understand.

keys = top_10_genes

Log in to answer this question.