# 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)