Skip to content

Instantly share code, notes, and snippets.

@FloWuenne
Created November 14, 2017 15:03
Show Gist options
  • Select an option

  • Save FloWuenne/d16cbb29c73ad469bbf10e42caac1fb7 to your computer and use it in GitHub Desktop.

Select an option

Save FloWuenne/d16cbb29c73ad469bbf10e42caac1fb7 to your computer and use it in GitHub Desktop.
Translate human to mouse gene symbols for cell cycling genes using biomart and save results for faster reading next time
# 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)
}
## Translate gene names from human to mouse
#### Regev lab gene list
## List of regev genes
s_genes_human_regev <- cc.genes$s.genes
g2m_genes_human_regev <- cc.genes$g2m.genes
s_mouse_genes_regev <- convertHumanGeneList(s_genes_human_regev)
g2m_mouse_genes_regev <- convertHumanGeneList(g2m_genes_human_regev)
s_mouse <- data.frame("s_mouse"=s_mouse_genes_regev)
write.table(s_mouse,
file="s_mouse_genes.txt",
sep="\t",
col.names=T,
row.names=T,
quote=F)
g2M_mouse <- data.frame("g2m_mouse"=g2m_mouse_genes_regev)
write.table(g2M_mouse,
file="g2m_mouse_genes.txt",
sep="\t",
col.names=T,
row.names=T,
quote=F)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment