Answers.Body: <p>You need to specify the number without the version. Instead of "ENSMUST00000178862.1" just "ENSMUST00000178862":</p>
  
  <p>You can do this with one more line:</p>
  
  <pre class="lang-R prettyprint-override"><code>g &lt;- gsub("\\..*", "", rownames(txi.kallisto$counts))
  (hgnc_symbols &lt;- getBM(attributes = c("hgnc_symbol", "chromosome_name", "ensembl_transcript_id"), filters = "ensembl_transcript_id", values = g, mart = mart))
  ##  hgnc_symbol chromosome_name ensembl_transcript_id
  ##1          NA              14    ENSMUST00000177564
  ##2          NA               6    ENSMUST00000178537
  ##3          NA               6    ENSMUST00000178862
  ##4          NA              12    ENSMUST00000179520
  ##5          NA              14    ENSMUST00000179664
  ##6          NA              14    ENSMUST00000196221
  </code></pre>
  
  <p>With these transcripts it doesn't seem that there is an equivalent hgnc_symbol. But is recognized, otherwise they are not recognized:</p>
  
  <pre class="lang-R prettyprint-override"><code>(hgnc_symbols &lt;- getBM(attributes = c("hgnc_symbol", "chromosome_name", "ensembl_transcript_id"), filters = "ensembl_transcript_id", values = rownames(txi.kallisto$counts), mart = mart))
  ## [1] hgnc_symbol           chromosome_name       ensembl_transcript_id
  ##&lt;0 rows&gt; (or 0-length row.names)
  </code></pre>
  
  <p>However you might be interested in doing something like <a href="http://bioconductor.org/packages/release/bioc/vignettes/biomaRt/inst/doc/biomaRt.html#given-the-human-gene-tp53-retrieve-the-human-chromosomal-location-of-this-gene-and-also-retrieve-the-chromosomal-location-and-refseq-id-of-its-homolog-in-mouse." rel="noreferrer">this</a>:</p>
  
  <pre class="lang-R prettyprint-override"><code>human = useMart("ensembl", dataset = "hsapiens_gene_ensembl")
  mouse = useMart("ensembl", dataset = "mmusculus_gene_ensembl")
  getLDS(attributes = "ensembl_transcript_id",
         filters = "ensembl_transcript_id", values = g,mart = mouse,
        attributesL = "hgnc_symbol", martL = human)
  ## The query to the BioMart webservice returned an invalid result: the number of 
  ## columns in the result table does not equal the number of 
  ## attributes in the query. Please report this to the mailing list.
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-28T21:16:04.060Z
Answers.LastActivityDate: 2017-06-29T07:18:05.463Z
Answers.LastEditDate: 2017-06-29T07:18:05.463Z
Answers.UserDisplayName: llrs
Body: <p>I have a matrix of gene counts which I'm going to use as input for DESeq.  Right now, each gene is labeled by its Ensemble transcript ID, but I'd like to convert these to their HGNC symbols before I input them into DESeq for analysis. I'm attempting to do this conversion using biomaRt, however, this is my first time using the program, and I'm running into issues.  Here is my current code:</p>
  
  <pre class="lang-R prettyprint-override"><code>library("biomaRt")
  mart &lt;- useMart(biomart = "ENSEMBL_MART_ENSEMBL", dataset = "mmusculus_gene_ensembl")
  transcript.ids &lt;- rownames(txi.kallisto$counts)
  hgnc_symbols &lt;- getBM(attributes = "hgnc_symbol", filters = "ensembl_transcript_id", values = transcript.ids, mart = mart)
  </code></pre>
  
  <p>Printing hgnc_symbols shows that it isn't what I want:</p>
  
  <pre class="lang-R prettyprint-override"><code>&gt;ghnc_symbols
  [1] hgnc_symbol
  &lt;0 rows&gt; (or 0-length row.names)
  </code></pre>
  
  <p>Lastly, here is what the input transcript IDs look like:</p>
  
  <pre class="lang-R prettyprint-override"><code>&gt; head(rownames(txi.kallisto$counts))
  [1] "ENSMUST00000178862.1" "ENSMUST00000178537.1" "ENSMUST00000196221.1"
  [4] "ENSMUST00000179664.1" "ENSMUST00000177564.1" "ENSMUST00000179520.1"
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-06-28T21:45:46.507Z
Comments.Text: I may be missing something here, but why would you be looking for HGNC (*Human* Genome Organisation  Gene Nomenclature Committee) names for *mouse* genes?
Comments.UserDisplayName: terdon
Tags: <r><bioconductor><deseq2><biomart><ensembl>
Title: Trouble using biomaRt to retrieve hgnc symbols from Ensembl transcript ids
ThreadText: # Trouble using biomaRt to retrieve hgnc symbols from Ensembl transcript ids
  
  (Asked by: username_0 on 2017-06-28)
  
  I have a matrix of gene counts which I'm going to use as input for DESeq. Right now, each gene is labeled by its Ensemble transcript ID, but I'd like to convert these to their HGNC symbols before I input them into DESeq for analysis. I'm attempting to do this conversion using biomaRt, however, this is my first time using the program, and I'm running into issues. Here is my current code:
  
  ```R
  library("biomaRt")
  mart <- useMart(biomart = "ENSEMBL_MART_ENSEMBL", dataset = "mmusculus_gene_ensembl")
  transcript.ids <- rownames(txi.kallisto$counts)
  hgnc_symbols <- getBM(attributes = "hgnc_symbol", filters = "ensembl_transcript_id", values = transcript.ids, mart = mart)
  
  ```
  
  Printing hgnc\_symbols shows that it isn't what I want:
  
  ```R
  >ghnc_symbols
  [1] hgnc_symbol
  <0 rows> (or 0-length row.names)
  
  ```
  
  Lastly, here is what the input transcript IDs look like:
  
  ```R
  > head(rownames(txi.kallisto$counts))
  [1] "ENSMUST00000178862.1" "ENSMUST00000178537.1" "ENSMUST00000196221.1"
  [4] "ENSMUST00000179664.1" "ENSMUST00000177564.1" "ENSMUST00000179520.1"
  
  ```
  
  **Tags:** r, bioconductor, deseq2, biomart, ensembl
  
  > **Comments:**
  > **username_1**: I may be missing something here, but why would you be looking for HGNC (*Human* Genome Organisation  Gene Nomenclature Committee) names for *mouse* genes?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-06-28. Score: 8
  
  You need to specify the number without the version. Instead of "ENSMUST00000178862.1" just "ENSMUST00000178862":
  
  You can do this with one more line:
  
  ```R
  g <- gsub("\\..*", "", rownames(txi.kallisto$counts))
  (hgnc_symbols <- getBM(attributes = c("hgnc_symbol", "chromosome_name", "ensembl_transcript_id"), filters = "ensembl_transcript_id", values = g, mart = mart))
  ##  hgnc_symbol chromosome_name ensembl_transcript_id
  ##1          NA              14    ENSMUST00000177564
  ##2          NA               6    ENSMUST00000178537
  ##3          NA               6    ENSMUST00000178862
  ##4          NA              12    ENSMUST00000179520
  ##5          NA              14    ENSMUST00000179664
  ##6          NA              14    ENSMUST00000196221
  
  ```
  
  With these transcripts it doesn't seem that there is an equivalent hgnc\_symbol. But is recognized, otherwise they are not recognized:
  
  ```R
  (hgnc_symbols <- getBM(attributes = c("hgnc_symbol", "chromosome_name", "ensembl_transcript_id"), filters = "ensembl_transcript_id", values = rownames(txi.kallisto$counts), mart = mart))
  ## [1] hgnc_symbol           chromosome_name       ensembl_transcript_id
  ##<0 rows> (or 0-length row.names)
  
  ```
  
  However you might be interested in doing something like [this](http://bioconductor.org/packages/release/bioc/vignettes/biomaRt/inst/doc/biomaRt.html#given-the-human-gene-tp53-retrieve-the-human-chromosomal-location-of-this-gene-and-also-retrieve-the-chromosomal-location-and-refseq-id-of-its-homolog-in-mouse.):
  
  ```R
  human = useMart("ensembl", dataset = "hsapiens_gene_ensembl")
  mouse = useMart("ensembl", dataset = "mmusculus_gene_ensembl")
  getLDS(attributes = "ensembl_transcript_id",
         filters = "ensembl_transcript_id", values = g,mart = mouse,
        attributesL = "hgnc_symbol", martL = human)
  ## The query to the BioMart webservice returned an invalid result: the number of 
  ## columns in the result table does not equal the number of 
  ## attributes in the query. Please report this to the mailing list.
  
  ```
  
  
  ---
  
  