Answers.Body: <p>The genes that are missed are probably not official mgi symbols.</p>
  
  <p>You might wanna look them up at mgi:</p>
  
  <pre><code>cd45 -&gt; Ptprc 
  
  cd11b -&gt; Itgam 
  
  p2ry12 -&gt; P2ry12 (?) (CAPS sensitive?)    
  
  glast -&gt; Slc1a3 
  
  s100a -&gt; S100a1 
  
  pecam -&gt; Pecam1 (?)
  </code></pre>
  
  <p>I suspect biomaRt is not the problem here, the only better way I can come up with is to download the ENSEMBL annotation (GTF) <a href="ftp://ftp.ensembl.org/pub/release-92/gtf/mus_musculus" rel="nofollow noreferrer">file</a>, and get the symbol out of this annotation with AWK or in R.</p>
  
  <p>Here an example in R, since you don't want to use AWK:</p>
  
  <pre><code>file &lt;- read.table("Mus_musculus.GRCm38.78.gtf", sep = "\t", comment.char = "#")
  
  exons &lt;- subset(file, V3 == 'exon')
  
  V9 &lt;- file[,"V9"]
  
  ensembl_names &lt;- sub("gene_id ","",V9)
  
  split &lt;- strsplit(ensembl_names, ";")
  
  splitting &lt;- sapply(split, function(x) x[1])
  
  split_symbol &lt;- strsplit(ensembl_names, "gene_name ")
  
  splitting_symbol &lt;- sapply(split_symbol, function(x) x[2])
  
  splitting_symbol2 &lt;- strsplit(splitting_symbol, "; ")
  
  symbol_names &lt;- sapply(splitting_symbol2, function(x) x[1])
  
  ensemble_symbol_big &lt;- cbind(splitting, symbol_names)
  
  ensembl_symbol &lt;- unique(ensemble_symbol_big)
  
  colnames(ensembl_symbol) &lt;- c("ENSEMBL", "Symbol")
  
  write.table(ensembl_symbol, "ensembl_symbol.txt", sep = "\t", row.names = F)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T04:56:22.227Z
Answers.Text: I am not sure what you mean by look up at `mgi`. I tried supplying `mgi` instead of `mgi_symbol`, and it did not work. Not sure whether it is an issue with `biomart` or not. How to do that with `AWK`? Can you give any links for doing that, tutorials? To learn whole new language just to do translation of `ensembl ids` to `symbols` seems like an overkill a bit, if it is not very easy.
Answers.UserDisplayName: Nikita Vlasenko
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-11T06:49:35.260Z
Answers.Text: What I mean with "look up at mgi", is look up the genes that are missed: e.g., [cd45](http://www.informatics.jax.org/marker/MGI:97810), and [cd11b](http://www.informatics.jax.org/marker/MGI:96607). You'll see that your names do not match the name given after **Symbol**, so how do you expect biomaRt to recognize them? I think `AWK` is a great tool for bioinformaticians, but if you don't want to make use of this tool, don't. I do not want to force you into something.
Answers.UserDisplayName: benn
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-04T19:27:44.643Z
Answers.LastActivityDate: 2018-05-11T12:55:43.683Z
Answers.LastEditDate: 2018-05-11T12:55:43.683Z
Answers.UserDisplayName: benn
Body: <p>I have a list of gene symbols:</p>
  
  <pre><code>c("cd45", "Tmem119", "CD11b", "P2Yr12", "Csf1r", "Bst2", "Cd74", 
  "Cx3cr1", "Trem2", "Lyz2", "GLAST", "GFAP", "ALDH1L1", "Aldoc", "Aqp4", 
  "Glul", "S100a", "Olig1", "Olig2", "Olig3", "Mbp", "Pdgfra", "Pecam", 
  "Cldn5", "Cldn10", "Epas1", "Crip1")
  </code></pre>
  
  <p>If I feed it to <code>BioMart</code> to get <code>ensembl ids</code>:</p>
  
  <pre><code>mart &lt;- useDataset("mmusculus_gene_ensembl", useMart("ensembl"))
  list &lt;- getBM(filters= "mgi_symbol", attributes= c("ensembl_gene_id",
                             "mgi_symbol","description"),values=symbols,mart= mart)
  </code></pre>
  
  <p>the following genes are missed:</p>
  
  <pre><code>"cd45"   "cd11b"  "p2yr12" "glast"  "s100a"  "pecam" 
  </code></pre>
  
  <p>All of them are pretty well-known genes, and I can manually find their <code>ensembl ids</code> by googling it, for instance:</p>
  
  <p><a href="http://www.informatics.jax.org/marker/MGI:97810" rel="nofollow noreferrer">http://www.informatics.jax.org/marker/MGI:97810</a></p>
  
  <p>I tried supplying aliases, but it does not change the output. So, from my understanding <code>BioMart</code> is not working properly either because I am doing something wrong here or because <code>BioMart</code> itself is not a good tool to use. Is there a better way of getting the mapping that would map all of the gene symbols?</p>
  
Tags: <r><biomart>
Title: BioMart Ensembl id imperfect retrieval
ThreadText: # BioMart Ensembl id imperfect retrieval
  
  (Asked by: username_0 on 2018-05-04)
  
  I have a list of gene symbols:
  
  ```
  c("cd45", "Tmem119", "CD11b", "P2Yr12", "Csf1r", "Bst2", "Cd74", 
  "Cx3cr1", "Trem2", "Lyz2", "GLAST", "GFAP", "ALDH1L1", "Aldoc", "Aqp4", 
  "Glul", "S100a", "Olig1", "Olig2", "Olig3", "Mbp", "Pdgfra", "Pecam", 
  "Cldn5", "Cldn10", "Epas1", "Crip1")
  
  ```
  
  If I feed it to `BioMart` to get `ensembl ids`:
  
  ```
  mart <- useDataset("mmusculus_gene_ensembl", useMart("ensembl"))
  list <- getBM(filters= "mgi_symbol", attributes= c("ensembl_gene_id",
                             "mgi_symbol","description"),values=symbols,mart= mart)
  
  ```
  
  the following genes are missed:
  
  ```
  "cd45"   "cd11b"  "p2yr12" "glast"  "s100a"  "pecam" 
  
  ```
  
  All of them are pretty well-known genes, and I can manually find their `ensembl ids` by googling it, for instance:
  
  <http://www.informatics.jax.org/marker/MGI:97810>
  
  I tried supplying aliases, but it does not change the output. So, from my understanding `BioMart` is not working properly either because I am doing something wrong here or because `BioMart` itself is not a good tool to use. Is there a better way of getting the mapping that would map all of the gene symbols?
  
  **Tags:** r, biomart
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-05-04. Score: 4
  
  The genes that are missed are probably not official mgi symbols.
  
  You might wanna look them up at mgi:
  
  ```
  cd45 -> Ptprc 
  
  cd11b -> Itgam 
  
  p2ry12 -> P2ry12 (?) (CAPS sensitive?)    
  
  glast -> Slc1a3 
  
  s100a -> S100a1 
  
  pecam -> Pecam1 (?)
  
  ```
  
  I suspect biomaRt is not the problem here, the only better way I can come up with is to download the ENSEMBL annotation (GTF) [file](ftp://ftp.ensembl.org/pub/release-92/gtf/mus_musculus), and get the symbol out of this annotation with AWK or in R.
  
  Here an example in R, since you don't want to use AWK:
  
  ```
  file <- read.table("Mus_musculus.GRCm38.78.gtf", sep = "\t", comment.char = "#")
  
  exons <- subset(file, V3 == 'exon')
  
  V9 <- file[,"V9"]
  
  ensembl_names <- sub("gene_id ","",V9)
  
  split <- strsplit(ensembl_names, ";")
  
  splitting <- sapply(split, function(x) x[1])
  
  split_symbol <- strsplit(ensembl_names, "gene_name ")
  
  splitting_symbol <- sapply(split_symbol, function(x) x[2])
  
  splitting_symbol2 <- strsplit(splitting_symbol, "; ")
  
  symbol_names <- sapply(splitting_symbol2, function(x) x[1])
  
  ensemble_symbol_big <- cbind(splitting, symbol_names)
  
  ensembl_symbol <- unique(ensemble_symbol_big)
  
  colnames(ensembl_symbol) <- c("ENSEMBL", "Symbol")
  
  write.table(ensembl_symbol, "ensembl_symbol.txt", sep = "\t", row.names = F)
  
  ```
  
  > **Comments:**
  > **username_0**: I am not sure what you mean by look up at `mgi`. I tried supplying `mgi` instead of `mgi_symbol`, and it did not work. Not sure whether it is an issue with `biomart` or not. How to do that with `AWK`? Can you give any links for doing that, tutorials? To learn whole new language just to do translation of `ensembl ids` to `symbols` seems like an overkill a bit, if it is not very easy.  
  > **username_1**: What I mean with "look up at mgi", is look up the genes that are missed: e.g., [cd45](http://www.informatics.jax.org/marker/MGI:97810), and [cd11b](http://www.informatics.jax.org/marker/MGI:96607). You'll see that your names do not match the name given after **Symbol**, so how do you expect biomaRt to recognize them? I think `AWK` is a great tool for bioinformaticians, but if you don't want to make use of this tool, don't. I do not want to force you into something.  
  
  ---
  
  