<p>Sorry, this was my mistake in the last question. To search down the ontology, rather than just for the specific association with a term, biomaRt needs a different filter: 'go_parent_term'.</p>

<p>Try:</p>

<pre><code>gene &lt;- getBM(attributes = c('external_gene_name'), filters = 'go_parent_term', values = 'GO:0030098', mart = ensembl)
</code></pre>

CC BY-SA 4.0
2018-11-09T09:27:10.680Z
ooook, that works perfectly!
A small point, though. Is this using only "is_a" relations or is it using any kind of GO relations?
gbt
CC BY-SA 4.0
2018-11-09T14:11:01.260Z
These are the mapping we use between parent and child: biological_process = is_a,part_of,regulates,positively_regulates,negatively_regulates;
cellular_component = is_a,part_of;
molecular_function = is_a,part_of
Emily_Ensembl
CC BY-SA 4.0
2018-11-09T09:18:38.357Z
2018-11-09T09:18:38.357Z
Emily_Ensembl
<p>I am playing with biomart in order to get the list of genes associated to a specific gene ontology (GO) term.</p>

<p>So, if I use the webservice as in this <a href="http://www.ensembl.org/biomart/martview/b222cd479ae7a7ab534cc7d672a80df5" rel="nofollow noreferrer">query</a>:</p>

<p>I get at least 50 genes. If I download the file I can gen an exact count of them:</p>

<pre><code>$ cat mart_export.txt | wc -l
347
</code></pre>

<p>Now, I can do the same operation by using the R library biomaRt. Specifically:</p>

<pre><code>&gt; ensembl &lt;- useEnsembl(biomart="ENSEMBL_MART_ENSEMBL", dataset='hsapiens_gene_ensembl')
&gt; gene &lt;- getBM(attributes = c('external_gene_name'), filters = 'go', values = 'GO:0030098', mart = ensembl)
&gt; unique(gene)
  external_gene_name
1               SPI1
2              PRKDC
3                TOX
4               LY6D
5               CBFB
6              IKZF1
7               RELB
8             FLT3LG
</code></pre>

<p>By doing so, these are all the genes I retrieve. The two results are totally different and I don't know why it. All these eight genes are found in the biomart file (I grepped it, to be sure).</p>

<p>I believe this is not <a href="https://www.biostars.org/p/109246/" rel="nofollow noreferrer">an issue related to databases versions</a> since I checked:</p>

<pre><code>&gt;listMarts()
               biomart               version
1 ENSEMBL_MART_ENSEMBL      Ensembl Genes 94
2   ENSEMBL_MART_MOUSE      Mouse strains 94
3     ENSEMBL_MART_SNP  Ensembl Variation 94
4 ENSEMBL_MART_FUNCGEN Ensembl Regulation 94
</code></pre>

<p>and:</p>

<pre><code>&gt;listDatasets(ensembl)
...
38 Human genes (GRCh38.p12)
...
</code></pre>

<p>Both are the same version used by biomart online.</p>

<p>What is going on? Is it possible that biomart online is considering <a href="http://geneontology.org/page/ontology-relations" rel="nofollow noreferrer">GO relations</a> that are not specified in the R version?</p>

CC BY-SA 4.0
2018-11-09T08:43:47.247Z
Funny: if I count the result of your query I get that there would be 361 genes. While we have 346 genes (you need to discount the header, and also as a tip `wc -l mart_export.txt` works as well). The difference between 361 and 346 might be duplicated gene, which suggests that they are considering GO child process. But I think that Emily might have a better answer for this. Have you searched online for similar questions?
llrs
CC BY-SA 4.0
2018-11-09T08:49:28.387Z
yes, you're rigth about the header ;-) I forgot about it. also yes I looked for other similar questions and I found the one that suggested me to check the version used by R biomaRt. Another similar question https://www.biostars.org/p/14948/ does not answer. How come that you get 361 lines? I'll try that again, sending another equal query. Lets see
gbt
CC BY-SA 4.0
2018-11-09T08:52:32.273Z
Ok, I tried again and I still got 346 genes! This is weird!
gbt
CC BY-SA 4.0
2018-11-09T09:16:52.047Z
The 361 is using the count feature of the query page. Instead of results I pressed count at the top left header. If you deselect the unique rows you'll get more genes
llrs
CC BY-SA 4.0
2018-11-09T09:47:21.897Z
yes, I tried it but actually I don't know. Hopefully unique genes will be enough!
gbt
<r><biomart><gene-ontology>
different results coming from biomart online and biomaRt R library
# different results coming from biomart online and biomaRt R library

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

I am playing with biomart in order to get the list of genes associated to a specific gene ontology (GO) term.
So, if I use the webservice as in this query:
I get at least 50 genes. If I download the file I can gen an exact count of them:
$ cat mart_export.txt | wc -l
347

Now, I can do the same operation by using the R library biomaRt. Specifically:
> ensembl <- useEnsembl(biomart="ENSEMBL_MART_ENSEMBL", dataset='hsapiens_gene_ensembl')
> gene <- getBM(attributes = c('external_gene_name'), filters = 'go', values = 'GO:0030098', mart = ensembl)
> unique(gene)
  external_gene_name
1               SPI1
2              PRKDC
3                TOX
4               LY6D
5               CBFB
6              IKZF1
7               RELB
8             FLT3LG

By doing so, these are all the genes I retrieve. The two results are totally different and I don't know why it. All these eight genes are found in the biomart file (I grepped it, to be sure).
I believe this is not an issue related to databases versions since I checked:
>listMarts()
               biomart               version
1 ENSEMBL_MART_ENSEMBL      Ensembl Genes 94
2   ENSEMBL_MART_MOUSE      Mouse strains 94
3     ENSEMBL_MART_SNP  Ensembl Variation 94
4 ENSEMBL_MART_FUNCGEN Ensembl Regulation 94

and:
>listDatasets(ensembl)
...
38 Human genes (GRCh38.p12)
...

Both are the same version used by biomart online.
What is going on? Is it possible that biomart online is considering GO relations that are not specified in the R version?

**Tags:** r, biomart, gene-ontology
> **Comments:**
> **username_1**: Funny: if I count the result of your query I get that there would be 361 genes. While we have 346 genes (you need to discount the header, and also as a tip `wc -l mart_export.txt` works as well). The difference between 361 and 346 might be duplicated gene, which suggests that they are considering GO child process. But I think that Emily might have a better answer for this. Have you searched online for similar questions?  
> **username_0**: yes, you're rigth about the header ;-) I forgot about it. also yes I looked for other similar questions and I found the one that suggested me to check the version used by R biomaRt. Another similar question https://www.biostars.org/p/14948/ does not answer. How come that you get 361 lines? I'll try that again, sending another equal query. Lets see  
> **username_0**: Ok, I tried again and I still got 346 genes! This is weird!  
> **username_1**: The 361 is using the count feature of the query page. Instead of results I pressed count at the top left header. If you deselect the unique rows you'll get more genes  
> **username_0**: yes, I tried it but actually I don't know. Hopefully unique genes will be enough!  

---

## 1 answers

### Answer by username_2 on 2018-11-09. Score: 4 | Accepted answer

Sorry, this was my mistake in the last question. To search down the ontology, rather than just for the specific association with a term, biomaRt needs a different filter: 'go_parent_term'.
Try:
gene <- getBM(attributes = c('external_gene_name'), filters = 'go_parent_term', values = 'GO:0030098', mart = ensembl)

> **Comments:**
> **username_0**: ooook, that works perfectly! A small point, though. Is this using only "is_a" relations or is it using any kind of GO relations?  
> **username_2**: These are the mapping we use between parent and child: biological_process = is_a,part_of,regulates,positively_regulates,negatively_regulates; cellular_component = is_a,part_of; molecular_function = is_a,part_of  

---

