<p>You can use <a href="http://www.ensembl.org/biomart/martview" rel="nofollow noreferrer">BioMart</a> to filter by your GO term and get the genes as attributes. BioMart is ontology-aware so will pull out all genes associated with your term and with any of its child terms.</p>

<p>There is no need to look up the GO child terms as BioMart already deals with this. A term may have more than one parent term, but if it's associated with a gene then everything about that term is associated with the gene. The term is not associated with the gene via parent X or parent Y, it means that both are relevant. So if the child term is associated with the gene, then the parent term is by proxy.</p>

<p>If you're not already familiar with BioMart, there's a <a href="https://www.youtube.com/watch?v=QvGT2G0-hYA" rel="nofollow noreferrer">help video</a>.</p>

<p><a href="http://www.ensembl.org/biomart/martview/dc43680a090b326feaf65bec5d81dcef?VIRTUALSCHEMANAME=default&amp;ATTRIBUTES=hsapiens_gene_ensembl.default.feature_page.ensembl_gene_id|hsapiens_gene_ensembl.default.feature_page.external_gene_name|hsapiens_gene_ensembl.default.feature_page.go_id|hsapiens_gene_ensembl.default.feature_page.name_1006&amp;FILTERS=hsapiens_gene_ensembl.default.filters.go_parent_term.%22GO:0030098%22&amp;VISIBLEPANEL=resultspanel" rel="nofollow noreferrer">Here's a BioMart query that gets you exactly what you need in human using the web interface</a></p>

<p>If you want to work with the R interface to biomaRt, <a href="https://bioconductor.org/packages/release/bioc/vignettes/biomaRt/inst/doc/biomaRt.html#retrieve-all-entrezgene-identifiers-and-hugo-gene-symbols-of-genes-which-have-a-map-kinase-activity-go-term-associated-with-it." rel="nofollow noreferrer">here's some documentation</a> and this is the identical query to above:</p>

<pre><code>library(biomaRt)
ensembl=useEnsembl(biomart="ensembl", dataset='hsapiens_gene_ensembl')
getBM(attributes = c('ensembl_gene_id','external_gene_name', 'go_parent_term', 'name_1006'), 
      filters = 'go', 
      values = 'GO:0030098', 
      mart = ensembl)
</code></pre>

CC BY-SA 4.0
2018-11-08T09:33:23.613Z
ok, so as you're suggesting what I should look, in GO, is for the children of my GO term. But a child of my term can contain genes from other parents, isn't it?

according to this link http://www.geneontology.org/page/ontology-structure it seems that some kind of association may appear between different branches.
gbt
CC BY-SA 4.0
2018-11-08T10:11:48.067Z
No, don't worry about looking in GO. Just put the one term you have into BioMart. It will find all genes associated with your term and all genes associated with its children.

A term may have more than one parent term, but if it's associated with a gene then everything about that term is associated with the gene. The term is not associated with the gene via parent X or parent Y, it means that both are relevant. So if the child term is associated with the gene, then the parent term is by proxy.
Emily_Ensembl
CC BY-SA 4.0
2018-11-08T10:25:22.963Z
[Here's a BioMart query that gets you exactly what you need in human](http://www.ensembl.org/biomart/martview/dc43680a090b326feaf65bec5d81dcef?VIRTUALSCHEMANAME=default&ATTRIBUTES=hsapiens_gene_ensembl.default.feature_page.ensembl_gene_id|hsapiens_gene_ensembl.default.feature_page.external_gene_name|hsapiens_gene_ensembl.default.feature_page.go_id|hsapiens_gene_ensembl.default.feature_page.name_1006&FILTERS=hsapiens_gene_ensembl.default.filters.go_parent_term."GO:0030098"&VISIBLEPANEL=resultspanel)
Emily_Ensembl
CC BY-SA 4.0
2018-11-08T10:27:39.377Z
@Emily_Ensembl please [edit] the comments to your answer (the comments might be deleted and there are very useful comments). Thanks for answering this
llrs
CC BY-SA 4.0
2018-11-08T10:28:05.777Z
Why would the comments be deleted?
Emily_Ensembl
CC BY-SA 4.0
2018-11-08T11:07:08.300Z
Emily, one more detail. The example query you sent, is equivalent to this piece of code (changing the mart and the GO entry)?
http://127.0.0.1:19280/library/biomaRt/doc/biomaRt.html#retrieve-all-entrezgene-identifiers-and-hugo-gene-symbols-of-genes-which-have-a-map-kinase-activity-go-term-associated-with-it.
gbt
CC BY-SA 4.0
2018-11-08T11:10:59.997Z
I don't have permission to connect to that. Can you send it as a proper URL.
Emily_Ensembl
CC BY-SA 4.0
2018-11-08T11:11:24.233Z
@Emily_Ensembl Because in Stackexchange the are for clarifications and improvements of questions and answers, and as such the content is assumed to be added to the relevant question or answer. Also they are considered "second class citizens"...
llrs
CC BY-SA 4.0
2018-11-08T11:18:44.173Z
Emily, if you click on it then it does not work, if you copy-paste in a new tab, definitely it will. Otherwise, from the page that it opens, I'm focusing on the section _4.6  Retrieve all entrezgene identifiers and HUGO gene symbols of genes which have a “MAP kinase activity” GO term associated with it._
gbt
CC BY-SA 4.0
2018-11-08T11:20:19.207Z
@gabrielet the first section of your link (http://127.0.0.1:19280) is for a *local* port of your machine! We can't access your machine, so we cannot see the code you are mentioning
llrs
CC BY-SA 4.0
2018-11-08T11:40:22.910Z
ops! sorry Llopis and Emily, you're right. This should work
https://bioconductor.org/packages/release/bioc/vignettes/biomaRt/inst/doc/biomaRt.html#retrieve-all-entrezgene-identifiers-and-hugo-gene-symbols-of-genes-which-have-a-map-kinase-activity-go-term-associated-with-it.
gbt
CC BY-SA 4.0
2018-11-08T11:44:09.467Z
Yes, that's it. But change the attributes to whatever you want to see in your results table.
Emily_Ensembl
CC BY-SA 4.0
2018-11-08T09:27:44.450Z
2018-11-28T14:45:21.140Z
2018-11-28T14:45:21.140Z
Emily_Ensembl
<p>I'm having a bit of confusion about how can I retrieve all the genes that are associated to a specific gene ontology.</p>

<p>Lets say I need to find all the genes that are associated with this GO entry:</p>

<blockquote>
  <p>GO:0030098 lymphocyte differentiation</p>
</blockquote>

<p><a href="https://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0030098" rel="nofollow noreferrer">This</a> is the graph representing the parents of my GO. In the same page I find the <strong>Child Terms</strong> that represent the children of my term.</p>

<p>Now, I can download the goa file (related to the organism I'm interested into) containing the GO associations and <code>grep</code> my term to extract a list of associated genes but, as far as I can understand, this list does not represent the whole graph that actually describe my GO term. </p>

<p>Should I also get the genes in the childred terms of my term? Or in the parents terms? If yes, then again I have to go back in the graph and find the parents/children of the found parents/children and so on, till the whole graph is visited.</p>

<p>Is this the correct approach? Or should I only focus on those genes related to my GO:0030098, and that's it?</p>

<p>I found this:
<a href="https://bioinformatics.stackexchange.com/questions/2533/retrieving-a-list-of-human-genes-having-go-associations">Retrieving a list of human genes having GO associations</a>
and <a href="https://www.biostars.org/p/52101/" rel="nofollow noreferrer">this</a> but I think they don't address my question since they do not describe the parent-children association.</p>

<p>Also I found <a href="http://www.geneontology.org/faq/how-can-i-programmatically-get-list-go-terms-associated-gene-identifier" rel="nofollow noreferrer">this</a>, on the GO FAQ, but what I need to do is quite the opposite.</p>

<p>Summarising: I need to find the genes associated to a specific GO term. Should I also look for its parents or children or not?</p>

<p>Any clues?</p>

<gene-ontology>
Retrieve all genes for a specific gene ontology
# Retrieve all genes for a specific gene ontology

(Asked by: username_0 on 2018-11-08)

I'm having a bit of confusion about how can I retrieve all the genes that are associated to a specific gene ontology.

Lets say I need to find all the genes that are associated with this GO entry:

> GO:0030098 lymphocyte differentiation

[This](https://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0030098) is the graph representing the parents of my GO. In the same page I find the **Child Terms** that represent the children of my term.

Now, I can download the goa file (related to the organism I'm interested into) containing the GO associations and `grep` my term to extract a list of associated genes but, as far as I can understand, this list does not represent the whole graph that actually describe my GO term.

Should I also get the genes in the childred terms of my term? Or in the parents terms? If yes, then again I have to go back in the graph and find the parents/children of the found parents/children and so on, till the whole graph is visited.

Is this the correct approach? Or should I only focus on those genes related to my GO:0030098, and that's it?

I found this:
[Retrieving a list of human genes having GO associations](https://bioinformatics.stackexchange.com/questions/2533/retrieving-a-list-of-human-genes-having-go-associations)
and [this](https://www.biostars.org/p/52101/) but I think they don't address my question since they do not describe the parent-children association.

Also I found [this](http://www.geneontology.org/faq/how-can-i-programmatically-get-list-go-terms-associated-gene-identifier), on the GO FAQ, but what I need to do is quite the opposite.

Summarising: I need to find the genes associated to a specific GO term. Should I also look for its parents or children or not?

Any clues?

**Tags:** gene-ontology

---

## 1 answers

### Answer by username_1 on 2018-11-08. Score: 4 | Accepted answer

You can use BioMart to filter by your GO term and get the genes as attributes. BioMart is ontology-aware so will pull out all genes associated with your term and with any of its child terms.
There is no need to look up the GO child terms as BioMart already deals with this. A term may have more than one parent term, but if it's associated with a gene then everything about that term is associated with the gene. The term is not associated with the gene via parent X or parent Y, it means that both are relevant. So if the child term is associated with the gene, then the parent term is by proxy.
If you're not already familiar with BioMart, there's a help video.
Here's a BioMart query that gets you exactly what you need in human using the web interface
If you want to work with the R interface to biomaRt, here's some documentation and this is the identical query to above:
library(biomaRt)
ensembl=useEnsembl(biomart="ensembl", dataset='hsapiens_gene_ensembl')
getBM(attributes = c('ensembl_gene_id','external_gene_name', 'go_parent_term', 'name_1006'), 
      filters = 'go', 
      values = 'GO:0030098', 
      mart = ensembl)

> **Comments:**
> **username_0**: ok, so as you're suggesting what I should look, in GO, is for the children of my GO term. But a child of my term can contain genes from other parents, isn't it?  according to this link http://www.geneontology.org/page/ontology-structure it seems that some kind of association may appear between different branches.  
> **username_1**: No, don't worry about looking in GO. Just put the one term you have into BioMart. It will find all genes associated with your term and all genes associated with its children.  A term may have more than one parent term, but if it's associated with a gene then everything about that term is associated with the gene. The term is not associated with the gene via parent X or parent Y, it means that both are relevant. So if the child term is associated with the gene, then the parent term is by proxy.  
> **username_1**: [Here's a BioMart query that gets you exactly what you need in human](http://www.ensembl.org/biomart/martview/dc43680a090b326feaf65bec5d81dcef?VIRTUALSCHEMANAME=default&ATTRIBUTES=hsapiens_gene_ensembl.default.feature_page.ensembl_gene_id|hsapiens_gene_ensembl.default.feature_page.external_gene_name|hsapiens_gene_ensembl.default.feature_page.go_id|hsapiens_gene_ensembl.default.feature_page.name_1006&FILTERS=hsapiens_gene_ensembl.default.filters.go_parent_term."GO:0030098"&VISIBLEPANEL=resultspanel)  
> **username_2**: @Emily_Ensembl please [edit] the comments to your answer (the comments might be deleted and there are very useful comments). Thanks for answering this  
> **username_1**: Why would the comments be deleted?  
> **username_0**: Emily, one more detail. The example query you sent, is equivalent to this piece of code (changing the mart and the GO entry)? http://127.0.0.1:19280/library/biomaRt/doc/biomaRt.html#retrieve-all-entrezgene-identifiers-and-hugo-gene-symbols-of-genes-which-have-a-map-kinase-activity-go-term-associated-with-it.  
> **username_1**: I don't have permission to connect to that. Can you send it as a proper URL.  
> **username_2**: @Emily_Ensembl Because in Stackexchange the are for clarifications and improvements of questions and answers, and as such the content is assumed to be added to the relevant question or answer. Also they are considered "second class citizens"...  
> **username_0**: Emily, if you click on it then it does not work, if you copy-paste in a new tab, definitely it will. Otherwise, from the page that it opens, I'm focusing on the section _4.6  Retrieve all entrezgene identifiers and HUGO gene symbols of genes which have a “MAP kinase activity” GO term associated with it._  
> **username_2**: @gabrielet the first section of your link (http://127.0.0.1:19280) is for a *local* port of your machine! We can't access your machine, so we cannot see the code you are mentioning  
> **username_0**: ops! sorry Llopis and Emily, you're right. This should work https://bioconductor.org/packages/release/bioc/vignettes/biomaRt/inst/doc/biomaRt.html#retrieve-all-entrezgene-identifiers-and-hugo-gene-symbols-of-genes-which-have-a-map-kinase-activity-go-term-associated-with-it.  
> **username_1**: Yes, that's it. But change the attributes to whatever you want to see in your results table.  

---

