Answers.Body: <pre><code>library(dplyr)
  #create the function to convert mouse to human genes
  homologs = read.csv(&quot;http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt&quot;,sep=&quot;\t&quot;)
  ms2hs &lt;- function(gene_list){
    output = c()
    for(gene in gene_list){
      class_key = (homologs %&gt;% filter(Symbol == gene &amp; Common.Organism.Name==&quot;mouse, laboratory&quot;))[['DB.Class.Key']]
      if(!identical(class_key, integer(0)) ){
        human_genes = (homologs %&gt;% filter(DB.Class.Key == class_key &amp; Common.Organism.Name==&quot;human&quot;))[,&quot;Symbol&quot;]
        for(human_gene in human_genes){
          output = append(output,human_gene)
        }
      }
    }
    return (output)
  }
  
  #apply the function
  msgenes=c(&quot;Zfp192&quot;, &quot;Ifitm2&quot;, &quot;Mettl8&quot;, &quot;Kcnh2&quot;, &quot;Npdc1&quot;, &quot;Pitpnc1&quot;, &quot;Ooep&quot;, &quot;Mettl8&quot;)
  ms2hs(msgenes)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-09T06:53:33.173Z
Answers.LastActivityDate: 2024-01-09T06:53:33.173Z
Answers.UserDisplayName: nicholaspooran
Answers.Body: <p>Mice genes are usually the same as the human ones, but lower case with only the first character as upper (<code>Sox17</code> -&gt; <code>SOX17</code>).
  <code>toupper(rownames(mouse_only))</code> will do the trick.</p>
  <p>Unfortunately, there are exceptions, and it is always better to relay on information from databases. The function bellow takes a vector of human genes, and uses <code>biomaRt</code> to return the corresponding genes in mouse.</p>
  <pre><code># from Human to Mouse
  convertHumanGeneList &lt;- function(x){
  
     library(&quot;biomaRt&quot;)
     human &lt;- useMart(&quot;ensembl&quot;, dataset = &quot;hsapiens_gene_ensembl&quot;)
     mouse &lt;- useMart(&quot;ensembl&quot;, dataset = &quot;mmusculus_gene_ensembl&quot;)
  
     genesV2 &lt;- getLDS(attributes = c(&quot;hgnc_symbol&quot;), filters = &quot;hgnc_symbol&quot;, 
                   values = x , mart = human, attributesL = c(&quot;mgi_symbol&quot;), martL = mouse, uniqueRows=T)
  
     humanx &lt;- unique(genesV2[, 2])
  
     return(humanx)
  }
  </code></pre>
  <p>You simply need to invert the 2 and you should be able to convert your vector <code>rownames(mouse_only)</code></p>
  <p>#---- Update using SOX17 as example
  <a href="https://i.sstatic.net/adHUN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/adHUN.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-05T21:07:20.760Z
Answers.Text: That didn't work. genesV2 is empty.
Answers.UserDisplayName: mmpp
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-05T21:30:24.017Z
Answers.Text: Works for me. I added a figure in my answer to show you the output I get
Answers.UserDisplayName: fra
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-05T21:59:41.670Z
Answers.Text: Figured out the issue, I didn't assign `x` a value. Now that I have the human genes, how can I do a correlation between the mouse genes from the PTX data vs the genes from patient data?
Answers.UserDisplayName: mmpp
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-06T18:07:25.907Z
Answers.Text: That's probably a topic for another question :D. You should accept the answer (if you managed to convert the genes name), and open a different topic.
Answers.UserDisplayName: fra
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-05T14:11:57.497Z
Answers.LastActivityDate: 2021-08-05T21:29:40.720Z
Answers.LastEditDate: 2021-08-05T21:29:40.720Z
Answers.UserDisplayName: fra
Body: <p>I'm trying to convert mouse genes from PTX data to human genes in order to do a comparison with patient data to see what genes are being conserved. I'm using this file for the orthologs.
  <strong><a href="http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt" rel="nofollow noreferrer">http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt</a></strong></p>
  <p>I read the table with:</p>
  <pre><code>gene_conversion &lt;- read.table(&quot;HOM_MouseHumanSequence.rpt.txt&quot;, sep=&quot;\t&quot;, header=T, fill=T)
  </code></pre>
  <p>I have subsetted the mouse genes from the PTX seurat object to only include the mouse genes with:</p>
  <pre><code>mouse_only &lt;- subset(scData, features = mouse_1)
  head(rownames(mouse_only))
  [1] &quot;Xkr4&quot;    &quot;Gm37180&quot; &quot;Gm37363&quot; &quot;Gm19938&quot; &quot;Sox17&quot;   &quot;Gm6085&quot; 
  </code></pre>
  <p>Now I'm not sure how to convert the mouse genes in my mouse-only seurat object to match the human genes in the file.</p>
  <p>Any help would be greatly appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-05T08:49:40.050Z
Comments.Text: Just checking / confirming... shouldn't that be a double equals in the subset command? are you using `features == mouse_1`?
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-05T14:00:43.520Z
Comments.Text: No, just a single equals. When I run the command with double I get an error.
  `subset(scData, features == mouse_1)
  Error in FetchData(object = object, vars = unique(x = expr.char[vars.use]),  : 
    None of the requested variables were found:`
Comments.UserDisplayName: mmpp
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-05T20:52:46.920Z
Comments.Text: Oh, I see now! Thanks. This seems to be an undocumented / new feature of subset that I haven't encountered before.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-05T21:08:09.513Z
Comments.Text: Any suggestions on how to continue?
Comments.UserDisplayName: mmpp
Tags: <r><seurat><single-cell><conversion>
Title: converting mouse genes to human genes
ThreadText: # converting mouse genes to human genes
  
  (Asked by: username_0 on 2021-08-04)
  
  I'm trying to convert mouse genes from PTX data to human genes in order to do a comparison with patient data to see what genes are being conserved. I'm using this file for the orthologs.
  **<http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt>**
  
  I read the table with:
  
  ```
  gene_conversion <- read.table("HOM_MouseHumanSequence.rpt.txt", sep="\t", header=T, fill=T)
  
  ```
  
  I have subsetted the mouse genes from the PTX seurat object to only include the mouse genes with:
  
  ```
  mouse_only <- subset(scData, features = mouse_1)
  head(rownames(mouse_only))
  [1] "Xkr4"    "Gm37180" "Gm37363" "Gm19938" "Sox17"   "Gm6085" 
  
  ```
  
  Now I'm not sure how to convert the mouse genes in my mouse-only seurat object to match the human genes in the file.
  
  Any help would be greatly appreciated.
  
  **Tags:** r, seurat, single-cell, conversion
  
  > **Comments:**
  > **username_1**: Just checking / confirming... shouldn't that be a double equals in the subset command? are you using `features == mouse_1`?  
  > **username_0**: No, just a single equals. When I run the command with double I get an error. `subset(scData, features == mouse_1) Error in FetchData(object = object, vars = unique(x = expr.char[vars.use]),  :    None of the requested variables were found:`  
  > **username_1**: Oh, I see now! Thanks. This seems to be an undocumented / new feature of subset that I haven't encountered before.  
  > **username_0**: Any suggestions on how to continue?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2021-08-05. Score: 3 | Accepted answer
  
  Mice genes are usually the same as the human ones, but lower case with only the first character as upper (`Sox17` -> `SOX17`).
  `toupper(rownames(mouse_only))` will do the trick.
  
  Unfortunately, there are exceptions, and it is always better to relay on information from databases. The function bellow takes a vector of human genes, and uses `biomaRt` to return the corresponding genes in mouse.
  
  ```
  # from Human to Mouse
  convertHumanGeneList <- function(x){
  
     library("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])
  
     return(humanx)
  }
  
  ```
  
  You simply need to invert the 2 and you should be able to convert your vector `rownames(mouse_only)`
  
  #---- Update using SOX17 as example
  [![enter image description here](https://i.sstatic.net/adHUN.png)](https://i.sstatic.net/adHUN.png)
  
  > **Comments:**
  > **username_0**: That didn't work. genesV2 is empty.  
  > **username_3**: Works for me. I added a figure in my answer to show you the output I get  
  > **username_0**: Figured out the issue, I didn't assign `x` a value. Now that I have the human genes, how can I do a correlation between the mouse genes from the PTX data vs the genes from patient data?  
  > **username_3**: That's probably a topic for another question :D. You should accept the answer (if you managed to convert the genes name), and open a different topic.  
  
  ---
  
  ### Answer by username_2 on 2024-01-09. Score: 0
  
  ```
  library(dplyr)
  #create the function to convert mouse to human genes
  homologs = read.csv("http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt",sep="\t")
  ms2hs <- function(gene_list){
    output = c()
    for(gene in gene_list){
      class_key = (homologs %>% filter(Symbol == gene & Common.Organism.Name=="mouse, laboratory"))[['DB.Class.Key']]
      if(!identical(class_key, integer(0)) ){
        human_genes = (homologs %>% filter(DB.Class.Key == class_key & Common.Organism.Name=="human"))[,"Symbol"]
        for(human_gene in human_genes){
          output = append(output,human_gene)
        }
      }
    }
    return (output)
  }
  
  #apply the function
  msgenes=c("Zfp192", "Ifitm2", "Mettl8", "Kcnh2", "Npdc1", "Pitpnc1", "Ooep", "Mettl8")
  ms2hs(msgenes)
  
  ```
  
  
  ---
  
  