This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to add Ensembl id to cluster.markers in Seurat

Hello, could someone help me with this question? Thanks so much in advance. When I run Seurat for RNA-seq data, there is a step to find all markers of a cluster, lets say cluster 2. The code is "cluster2.markers <- FindMarkers(pbmc10k, ident.1 = 2, min.pct = 0.25). After run, I can get a data list that consists of columns of gene symbol, ave_Log2FC, pct.1, pct.2 and p_val_adj. I want to have this data list with Ensembl ID for each gene symbol. How to add a code to have Ensembl ID included? Thanks for the help.

id ensembl

1 answer

library(org.Hs.eg.db)
mapped_genes <- data.frame(GeneName = rownames(cluster2.markers),
           ensemblID = mapIds(org.Hs.eg.db, keys =rownames(cluster2.markers), keytype = "SYMBOL", column="ENSEMBL"))
cluster2.markers$ensemblID <- mapped_genes$ensemblID

Log in to answer this question.