Can't argue with a working solution :)
I have an expression set matrix with the rownames being what I think is a GENCODE ID in the format for example "ENSG00000000003.14" "ENSG00000000457.13" "ENSG00000000005.5" and so on.
I would like to convert these to gene_symbol but I am not sure of the best way to do so, especially because of the ".14" or ".13" which I believe is the version.
Should I first trim all IDs for what is after the dot and then use biomaRt to convert? if so, what is the most efficient way of doing it? Is there a better way to get to the gene_symbol?
Many thanks for you help
2 answers
Thanks! In the meantime I did this and seem to have worked. Although with larger sets I guess the sapply would be faster
df$ensembl_gene_id <- gsub('\\..+$', '', df$ensembl_gene_id)
library(biomaRt)
mart <- useDataset("hsapiens_gene_ensembl", useMart("ensembl"))
genes <- df$ensembl_gene_id
symbol <- getBM(filters = "ensembl_gene_id",
attributes = c("ensembl_gene_id","hgnc_symbol"),
values = genes,
mart = mart)
df <- merge(x = symbol,
y = df,
by.x="ensembl_gene_id",
by.y="ensembl_gene_id")
Yes, you will likely need to trim off the version before merging with data from biomart, which will lack those. I don't know if it's the "most efficient" method, but at least a convenient and "good enough" one is:
> foo = as.character(c("ENSG00000000003.14", "ENSG00000000457.13", "ENSG00000000005.5"))
> fixed_names = sapply(strsplit(foo, ".", fixed=T), function(x) x[1])
You can replace foo with the row.names() accessor.
Log in to answer this question.
you can try this database. It s super fast and accurate
https://biodbnet-abcc.ncifcrf.gov/db/db2db.php