I have a DEGs data frame with Gene IDs. Pic for reference below
I am trying to convert the Gene_IDs into Ensembl IDs. I have tried the following methods
library("AnnotationDbi") library("org.Hs.eg.db") res3$ensid = mapIds(org.Hs.eg.db, keys=res3$Gene_ID, column="ENSEMBL", keytype = "SYMBOL", multiVals = "first")
The above code converted most of the gene IDs but gave NA values for a couple of them. Can someone please shed some light on this as I can't understand why?
Also tried with
library("biomaRt") listMarts() ensembl <- useMart("ensembl") datasets <- listDatasets(ensembl) ensembl = useDataset("hsapiens_gene_ensembl", mart = ensembl) options(max.print = 1000000) res3$ensid <- getBM(attributes = c('external_gene_name','ensembl_gene_id'), filters = 'external_gene_name', values = res3$Gene_ID, mart = ensembl, uniqueRows = FALSE)
but giving the following error
Error in `$<-.data.frame`(`*tmp*`, ensid, value = list(external_gene_name = c("KRT23", : replacement has 16202 rows, data has 17281
which shows there are more number of rows with Gene IDs in the data. can someone please guide me? Thank you!