Converting mouse to human gene names with biomaRt package

Converting mouse gene names to the human equivalent and vice versa is not always as straightforward as it seems, so I wrote a function to simplify the task. The function takes advantage of the getLDS() function from the biomaRt to get the hgnc symbol equivalent from the mgi symbol.

Converting mouse gene names to the human equivalent and vice versa is not always as straightforward as it seems, so I wrote a function to simplify the task. The function takes advantage of the getLDS() function from the biomaRt to get the hgnc symbol equivalent from the mgi symbol. For example, let’s convert the following mouse gene symbols, Hmmr, Tlx3, and Cpeb4, to their human equivalent.

musGenes <- c("Hmmr", "Tlx3", "Cpeb4")

# Basic function to convert mouse to human gene names
convertMouseGeneList <- function(x){

require("biomaRt")
human = useMart("ensembl", dataset = "hsapiens_gene_ensembl")
mouse = useMart("ensembl", dataset = "mmusculus_gene_ensembl")

genesV2 = getLDS(attributes = c("mgi_symbol"), filters = "mgi_symbol", values = x , mart = mouse, attributesL = c("hgnc_symbol"), martL = human, uniqueRows=T)
humanx <- unique(genesV2[, 2])

# Print the first 6 genes found to the screen
print(head(humanx))
return(humanx)
}

We can just as easily write a function to go from human to mouse genes.

# Basic function to convert human to mouse gene names
convertHumanGeneList <- function(x){

require("biomaRt")
human = useMart("ensembl", dataset = "hsapiens_gene_ensembl")
mouse = useMart("ensembl", dataset = "mmusculus_gene_ensembl")

genesV2 = getLDS(attributes = c("hgnc_symbol"), filters = "hgnc_symbol", values = x , mart = human, attributesL = c("mgi_symbol"), martL = mouse, uniqueRows=T)

humanx <- unique(genesV2[, 2])

# Print the first 6 genes found to the screen
print(head(humanx))
return(humanx)
}

genes <- convertHumanGeneList(humGenes) 

If you have any other suggestions on how to convert mouse to human gene names in R, I would love to hear them just email me at info@rjbioinformatics.com.

Author: radiaj

I am a Research Scientist & Bioinformatician who specializes in Immunology and Cancer Biology. I routinely use R and other programing languages to explore genomic data of cancer cells to identify molecular changes and risk factors that contributes to cancer development.

3 thoughts on “Converting mouse to human gene names with biomaRt package”

  1. Hi radiaj, thank you for this. I was looking for how to do this in R and your answer really helped.
    One thing that annoyed me though was that the getLDS() function returns a table in a different order to the input string, so I modified your function to return a list of mouse genes in the same order as the input list of human genes:

    convertHumanGeneList <- function(x){
    require("biomaRt")
    human <- useMart("ensembl", dataset = "hsapiens_gene_ensembl")
    mouse <- useMart("ensembl", dataset = "mmusculus_gene_ensembl")

    genesV2 <- getLDS(attributes = c("hgnc_symbol"),
    filters = "hgnc_symbol",
    values = x,
    mart = human,
    attributesL = c("mgi_symbol"),
    martL = mouse,
    uniqueRows=TRUE)

    # resulting table is in a different order to the input list
    # reorder to get the output the right way around
    row.names(genesV2) <- genesV2$HGNC.symbol

    mouse_genes <- genesV2[x, 2 ]

    return(human_genes)
    }

    Thanks again!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s