Hello , I have noticed that when using the getBM function the actual order at the function's result, is not in the same order as the vector that is used for the "values" argument. How can I put the final results at the same order as the vector of the "values" argument?
Reproducible code follows:
library(GEOquery)
library(biomaRt)
df=getGEO("GSE138206")
df1=df[[1]]
df2=exprs(df1)
df3=df2[,-c(4,10,16)]
df4=df3[,1:10] #first 5 cancer,last 5 contra
#biomart
ensembl <- useMart("ensembl")
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")
affyids=rownames(df4)
gene_names=getBM(attributes=c('affy_hg_u133_plus_2', 'entrezgene_id'),
filters = 'affy_hg_u133_plus_2',
values =affyids,
mart = ensembl)
#probe to gene
result1=head(affyids)
result2=head(gene_names)
result1
result2 #OMG what the h... is that??!??! they are not the same!!!
Your answer was correct, I attach the code for solving this biomaRt disfunction with your help
Thank you for the answer, I will try that. I cannot understand what's the point of someone using biomaRt , if it's not working as it is expected.
Not working to => your <= expectation