<p>It is filtering by your GO terms, it is only giving you genes associated with those GO terms. However the GO terms in the output are not linked to the GO terms in your input, so it is giving you all the GO terms linked to the genes which are associated with the GO terms you filtered by.</p>
<p>Essentially BioMart is not very clever. It has a table of all the GO terms linked to the genes, it filters the genes to only include those linked to the GO terms you've given it. Then it takes that list of genes and queries that same table completely separately, getting the GO terms for each gene.</p>

CC BY-SA 4.0
2021-02-09T12:21:33.443Z
Thank you for the comment; It does make sense.
nano
CC BY-SA 4.0
2021-02-08T14:10:15.667Z
2021-02-08T14:10:15.667Z
Emily_Ensembl
<p>I'm looking for an easy way to retrieve all the genes in a list that are associated with a certain GO term, preferably using R/Bioconductor packages. I'm not interested in under/overrepresentation or enrichment.</p>
<p>For instance, I want a list of all genes known to be located in 'presynaptic endosome' (GO:009883).</p>
<p>I tried the method referred to in an older post (<a href="https://bioinformatics.stackexchange.com/questions/5398/retrieve-all-genes-for-a-specific-gene-ontology">Retrieve all genes for a specific gene ontology</a> and <a href="https://www.biostars.org/p/52101/" rel="nofollow noreferrer">https://www.biostars.org/p/52101/</a>); following is my code:</p>
<pre><code>ensembl = useMart(&quot;ensembl&quot;,dataset=&quot;hsapiens_gene_ensembl&quot;) #retrieve human.ensembl data via biomaRt

go_1 = c(&quot;GO:0098830&quot;, &quot;GO:0098954&quot;, &quot;GO:0099007&quot;, &quot;GO:0099067&quot;, &quot;GO:0099037&quot;, &quot;GO:0098955&quot;, &quot;GO:0099592&quot;, &quot;GO:0099532&quot;) #GO IDs of all terms associated with &quot;presynaptic endosome&quot; (inclusive of child terms) 

pre.gene.data &lt;- getBM(attributes=c('hgnc_symbol', 'ensembl_gene_id', 'go_id', 'go_linkage_type'),
                    filters = 'go', values = list(go_1), mart = ensembl)
</code></pre>
<p>but my code doesn't filter the genes based on the GO terms. It gives me the following output:</p>
<pre><code>GO:0006886 AP3D1 ENSG00000065000 intracellular protein transport IEA
GO:0016192 AP3D1 ENSG00000065000 vesicle-mediated transport IEA
GO:0030117 AP3D1 ENSG00000065000 membrane coat IEA

... and 49 other entries for the gene &quot;AP3D1&quot;
</code></pre>
<p>I'm unable to understand what might be the problem. I replaced the filter &quot;go_id&quot; to &quot;go&quot; because of the updated filters used:listFilters(ensembl).</p>
<p>Please help!</p>

<bioconductor><gene><biomart><gene-ontology>
Retrieving all genes for a gene ontology term
# Retrieving all genes for a gene ontology term

(Asked by: username_0 on 2021-02-08)

I'm looking for an easy way to retrieve all the genes in a list that are associated with a certain GO term, preferably using R/Bioconductor packages. I'm not interested in under/overrepresentation or enrichment.
For instance, I want a list of all genes known to be located in 'presynaptic endosome' (GO:009883).
I tried the method referred to in an older post (Retrieve all genes for a specific gene ontology and https://www.biostars.org/p/52101/); following is my code:
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl") #retrieve human.ensembl data via biomaRt

go_1 = c("GO:0098830", "GO:0098954", "GO:0099007", "GO:0099067", "GO:0099037", "GO:0098955", "GO:0099592", "GO:0099532") #GO IDs of all terms associated with "presynaptic endosome" (inclusive of child terms) 

pre.gene.data <- getBM(attributes=c('hgnc_symbol', 'ensembl_gene_id', 'go_id', 'go_linkage_type'),
                    filters = 'go', values = list(go_1), mart = ensembl)

but my code doesn't filter the genes based on the GO terms. It gives me the following output:
GO:0006886 AP3D1 ENSG00000065000 intracellular protein transport IEA
GO:0016192 AP3D1 ENSG00000065000 vesicle-mediated transport IEA
GO:0030117 AP3D1 ENSG00000065000 membrane coat IEA

... and 49 other entries for the gene "AP3D1"

I'm unable to understand what might be the problem. I replaced the filter "go_id" to "go" because of the updated filters used:listFilters(ensembl).
Please help!

**Tags:** bioconductor, gene, biomart, gene-ontology

---

## 1 answers

### Answer by username_1 on 2021-02-08. Score: 1

It is filtering by your GO terms, it is only giving you genes associated with those GO terms. However the GO terms in the output are not linked to the GO terms in your input, so it is giving you all the GO terms linked to the genes which are associated with the GO terms you filtered by.

Essentially BioMart is not very clever. It has a table of all the GO terms linked to the genes, it filters the genes to only include those linked to the GO terms you've given it. Then it takes that list of genes and queries that same table completely separately, getting the GO terms for each gene.

> **Comments:**
> **username_0**: Thank you for the comment; It does make sense.  

---

