If you are just using Gene symbols to do the mapping, you don't need biomaRt
. You could use the Orthology.eg.db
package instead. It maps NCBI Gene IDs between species, so you need to also map symbols to Gene IDs, But a simple function will do that.
mapfun <- function(mousegenes){
gns <- mapIds(org.Mm.eg.db, mousegenes, "ENTREZID", "SYMBOL")
mapped <- select(Orthology.eg.db, gns, "Homo_sapiens","Mus_musculus")
naind <- is.na(mapped$Homo_sapiens)
hsymb <- mapIds(org.Hs.eg.db, as.character(mapped$Homo_sapiens[!naind]), "SYMBOL", "ENTREZID")
out <- data.frame(Mouse_symbol = mousegenes, mapped, Human_symbol = NA)
out$Human_symbol[!naind] <- hsymb
out
}
> library(Orthology.eg.db)
> library(org.Mm.eg.db)
> library(org.Hs.eg.db)
## just get some symbols
> z <- head(keys(org.Mm.eg.db, "SYMBOL"), 40)
> z
[1] "Pzp" "Aanat" "Aatk" "Abca1" "Abca4" "Abca2"
[7] "Abcb7" "Abcg1" "Abi1" "Abl1" "Abl2" "Scgb1b27"
[13] "ac" "Acadl" "Acadm" "Acadvl" "Acads" "Slc33a1"
[19] "Asic2" "Asic1" "Ace" "Ache" "Apoc4" "Macf1"
[25] "Aco1" "Aco2" "Acox1" "Acp1" "Acp2" "Acp5"
[31] "Acr" "Chrna1" "Chrna4" "Chrna6" "Chrna7" "Chrnb1"
[37] "Chrnb2" "Chrnd" "Chrne" "Chrng"
> mapfun(z)
'select()' returned 1:1 mapping between keys and columns
'select()' returned 1:1 mapping between keys and columns
Mouse_symbol Mus_musculus Homo_sapiens Human_symbol
Pzp Pzp 11287 NA <NA>
Aanat Aanat 11298 15 AANAT
Aatk Aatk 11302 9625 AATK
Abca1 Abca1 11303 19 ABCA1
Abca4 Abca4 11304 24 ABCA4
Abca2 Abca2 11305 20 ABCA2
Abcb7 Abcb7 11306 22 ABCB7
Abcg1 Abcg1 11307 9619 ABCG1
Abi1 Abi1 11308 10006 ABI1
Abl1 Abl1 11350 25 ABL1
Abl2 Abl2 11352 27 ABL2
Scgb1b27 Scgb1b27 11354 NA <NA>
ac ac 11358 NA <NA>
Acadl Acadl 11363 33 ACADL
Acadm Acadm 11364 34 ACADM
Acadvl Acadvl 11370 37 ACADVL
Acads Acads 11409 35 ACADS
Slc33a1 Slc33a1 11416 9197 SLC33A1
Asic2 Asic2 11418 40 ASIC2
Asic1 Asic1 11419 41 ASIC1
Ace Ace 11421 1636 ACE
Ache Ache 11423 43 ACHE
Apoc4 Apoc4 11425 346 APOC4
Macf1 Macf1 11426 23499 MACF1
Aco1 Aco1 11428 48 ACO1
Aco2 Aco2 11429 50 ACO2
Acox1 Acox1 11430 51 ACOX1
Acp1 Acp1 11431 52 ACP1
Acp2 Acp2 11432 53 ACP2
Acp5 Acp5 11433 54 ACP5
Acr Acr 11434 49 ACR
Chrna1 Chrna1 11435 1134 CHRNA1
Chrna4 Chrna4 11438 1137 CHRNA4
Chrna6 Chrna6 11440 8973 CHRNA6
Chrna7 Chrna7 11441 1139 CHRNA7
Chrnb1 Chrnb1 11443 1140 CHRNB1
Chrnb2 Chrnb2 11444 1141 CHRNB2
Chrnd Chrnd 11447 1144 CHRND
Chrne Chrne 11448 1145 CHRNE
Chrng Chrng 11449 1146 CHRNG
I didn't really check to see the directionality of your mapping, but if you mean to go from human to mouse, it's simple to modify that function to go the other way. Or modify to use another argument to define the directionality.
Thank you for the update. I was able to get it to work by using a previous archive.
human = useEnsembl("ensembl", dataset = "hsapiens_gene_ensembl", host="https://dec2021.archive.ensembl.org/")