This is because the values โโin your gene column are not gene identifiers, but peptide identifiers (they start with ENSP). To get the information you need, try replacing ensembl_gene_id with ensembl_peptide_id :
G_list <- getBM(filters = "ensembl_peptide_id", attributes = c("ensembl_peptide_id", "entrezgene", "description"), values = genes, mart = mart)
In addition, what you are really looking for is hgnc_symbol
Here is the complete code to get your output:
library('biomaRt') mart <- useDataset("hsapiens_gene_ensembl", useMart("ensembl")) genes <- df$genes df<-df[,-4] G_list <- getBM(filters= "ensembl_peptide_id", attributes= c("ensembl_peptide_id","hgnc_symbol"),values=genes,mart= mart) merge(df,G_list,by.x="gene",by.y="ensembl_peptide_id")
source share