<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/gene-homology-part-3-visualizing-gene-ontology-of-conserved-genes/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://shiring.github.io/genome/2017/01/05/homologous_genes_part3_post"> Shirin's playgRound</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>Which genes have homologs in many species?</h2>
<p>In <a target="_blank" rel="nofollow" href="https://shiring.github.io/genome/2016/12/11/homologous_genes_post">Part 1</a> and <a target="_blank" rel="nofollow" href="https://shiring.github.io/genome/2016/12/14/homologous_genes_part2_post">Part 2</a> I have already explored gene homology between humans and other species. But there I have only considered how many genes where shared between the species.</p>
<p>In this post I want to have a closer look at genes with homologs in many species. These genes are likely evolutionarily convserved in their biological function. To find out what biological functions these genes have, I am using gene ontology (GO) enrichment analysis.</p>
<p>Because GO categories have a hierarchical parent-children structure, comparing enriched GO terms between groups of genes in a meaningful way isn’t trivial. Simply calculating the overlap between categories will miss the bigger picture when, e.g. two groups are enriched for closely related but not for exactly the same GO categories. Here, I will explore a few options of visualizing GO enrichment with the purpose of comparing enrichments between groups (here: species).</p>
<p>A network of the partial hierarchical structure of enriched GO terms of biological processes encompasses the information of relatedness between GO terms. Custom annotations show GO terms that were common, as well as terms that were unique to species.</p>
<p>Highly conserved biological functions include core regulatory processes that are essential for the cell cycle, energy production and metabolism, nucleoside biogenesis, protein metabolism, etc.</p>
<p><img src="https://i1.wp.com/shiring.github.io/genome/2017/01/05/homologous_genes_part3_post_files/figure-markdown_github/unnamed-chunk-22-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<hr>
<p>I’m starting with the same table as from <a target="_blank" rel="nofollow" href="https://shiring.github.io/genome/2016/12/14/homologous_genes_part2_post">this post</a>, called <em>homologs_table_combined</em>.</p>
<div>
<pre><code><span>head</span><span>(</span><span>homologs_table_combined</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code>##   celegans_gene_ensembl cfamiliaris_gene_ensembl
## 1                    NA                       NA
## 2                    NA                   477699
## 3                    NA                   477023
## 4                173979                   490207
## 5                179795                   607852
## 6                177055                       NA
##   dmelanogaster_gene_ensembl drerio_gene_ensembl ggallus_gene_ensembl
## 1                         NA                  NA                   NA
## 2                      44071                  NA                   NA
## 3                         NA              431754               770094
## 4                      38864              406283                   NA
## 5                      36760              794259               395373
## 6                    3772179              541489               421909
##   hsapiens_gene_ensembl mmusculus_gene_ensembl ptroglodytes_gene_ensembl
## 1                    NA                     NA                        NA
## 2                     2                 232345                    465372
## 3                    30                 235674                    460268
## 4                    34                  11364                    469356
## 5                    47                 104112                    454672
## 6                    52                  11431                    458990
##   rnorvegicus_gene_ensembl scerevisiae_gene_ensembl sscrofa_gene_ensembl
## 1                    24152                       NA                   NA
## 2                    24153                       NA               403166
## 3                    24157                   854646            100515577
## 4                    24158                       NA               397104
## 5                    24159                   854310                   NA
## 6                    24161                   856187            100737301
</code></pre>
</div>
<p>Each row in this table denotes a gene with its Entrez ID and corresponding Entrez IDs for homologs in each of the other 10 species I explored. If a gene doesn’t have homolog the table says “NA”. However, some genes have duplicate entries for a species if there are multiple homologs in different species.</p>
<p>By counting the number of NAs per row, we can identify genes with homologs in all species (sum of NAs = 0) and genes which are specific (sum of NAs = 10).</p>
<div>
<pre><code><span>homologs_na</span><span> </span><span>&lt;-</span><span> </span><span>rowSums</span><span>(</span><span>is.na</span><span>(</span><span>homologs_table_combined</span><span>))</span><span>
</span></code></pre>
</div>
<p>Before I delve deeper into the biology behind these genes, I want to examine the distribution of the NA-counts. To do so, I am plotting a histogram.</p>
<p>But first I’m preparing my custom ggplot2 theme:</p>
<div>
<pre><code><span>library</span><span>(</span><span>ggplot2</span><span>)</span><span>
</span><span>my_theme</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>base_size</span><span> </span><span>=</span><span> </span><span>12</span><span>,</span><span> </span><span>base_family</span><span> </span><span>=</span><span> </span><span>&quot;sans&quot;</span><span>){</span><span>
</span><span>theme_minimal</span><span>(</span><span>base_size</span><span> </span><span>=</span><span> </span><span>base_size</span><span>,</span><span> </span><span>base_family</span><span> </span><span>=</span><span> </span><span>base_family</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>
</span><span>axis.text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>12</span><span>),</span><span>
</span><span>axis.title</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>14</span><span>),</span><span>
</span><span>panel.grid.major</span><span> </span><span>=</span><span> </span><span>element_line</span><span>(</span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;grey&quot;</span><span>),</span><span>
</span><span>panel.grid.minor</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>panel.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;aliceblue&quot;</span><span>),</span><span>
</span><span>strip.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;royalblue&quot;</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;grey&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>1</span><span>),</span><span>
</span><span>strip.text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>face</span><span> </span><span>=</span><span> </span><span>&quot;bold&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>12</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>),</span><span>
</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;bottom&quot;</span><span>,</span><span>
</span><span>legend.justification</span><span> </span><span>=</span><span> </span><span>&quot;top&quot;</span><span>,</span><span> </span><span>legend.box</span><span> </span><span>=</span><span> </span><span>&quot;horizontal&quot;</span><span>,</span><span>
</span><span>legend.box.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;grey50&quot;</span><span>),</span><span>
</span><span>legend.background</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>panel.border</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;grey&quot;</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>NA</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.5</span><span>)</span><span>
</span><span>)</span><span>
</span><span>}</span><span>
</span><span>theme_set</span><span>(</span><span>my_theme</span><span>())</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>ggplot</span><span>()</span><span> </span><span>+</span><span> </span><span>aes</span><span>(</span><span>homologs_na</span><span>)</span><span> </span><span>+</span><span> </span><span>geom_histogram</span><span>(</span><span>binwidth</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;royalblue&quot;</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;royalblue&quot;</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.8</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Number of NAs per row of gene homology table&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Count&quot;</span><span>,</span><span>
</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;How many homologs do genes have?&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Showing all bins from 0 to 10&quot;</span><span>,</span><span>
</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;\nEach row of the gene homology table list a gene and all its homologs in 10 other species.
If a gene doesn't have a homolog, its value in the table is NA. Thus, rows with many NAs refer to a
gene that is specific to one species, while rows with no NAs show genes with homologs in all species -
such genes are said to be highly conserved.&quot;</span><span>
</span><span>)</span><span>
</span></code></pre>
</div>
<p></p>
<p><img src="https://i2.wp.com/shiring.github.io/genome/2017/01/05/homologous_genes_part3_post_files/figure-markdown_github/unnamed-chunk-6-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>Clearly, most genes are specific to a species, they have NAs in all but one column. The rest of the histogram is a bit hard to differentiate with the peak at 10, so let’s look at the same data again with these genes:</p>
<p></p>
<div>
<pre><code><span>ggplot</span><span>()</span><span> </span><span>+</span><span> </span><span>aes</span><span>(</span><span>subset</span><span>(</span><span>homologs_na</span><span>,</span><span> </span><span>homologs_na</span><span> </span><span>&lt;</span><span> </span><span>10</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_histogram</span><span>(</span><span>binwidth</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;royalblue&quot;</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;royalblue&quot;</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.8</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Number of NAs per row of gene homology table&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;Count&quot;</span><span>,</span><span>
</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;How many homologs do genes have?&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Showing bins from 0 to 9&quot;</span><span>,</span><span>
</span><span>caption</span><span> </span><span>=</span><span> </span><span>&quot;\nEach row of the gene homology table list a gene and all its homologs in 10 other species.
If a gene doesn't have a homolog, its value in the table is NA. Thus, rows with many NAs refer to a
gene that is specific to one species, while rows with no NAs show genes with homologs in all species -
such genes are said to be highly conserved.&quot;</span><span>
</span><span>)</span><span>
</span></code></pre>
</div>
<p></p>
<p><img src="https://i0.wp.com/shiring.github.io/genome/2017/01/05/homologous_genes_part3_post_files/figure-markdown_github/unnamed-chunk-7-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>Now we can see that most genes have homologs in 9 species (2 NAs). But there are still quite a few genes with homologs in all species.</p>
<p></p>
<h3>Which genes are highly conserved and what biological functions do they have?</h3>
<p>There are 3461 rows in the original table with no NAs.</p>
<div>
<pre><code><span>genes_homologs_all</span><span> </span><span>&lt;-</span><span> </span><span>homologs_table_combined</span><span>[</span><span>which</span><span>(</span><span>rowSums</span><span>(</span><span>is.na</span><span>(</span><span>homologs_table_combined</span><span>))</span><span> </span><span>==</span><span> </span><span>0</span><span>),</span><span> </span><span>]</span><span>
</span><span>nrow</span><span>(</span><span>genes_homologs_all</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## [1] 3461
</code></pre>
</div>
<p>Looking at all of these genes by hand wouldn’t be feasible. So, to find out what biological functions these genes have, I am using gene ontology (GO-term) enrichment analysis as implemented in <a target="_blank" rel="nofollow" href="https://bioconductor.org/packages/release/bioc/html/clusterProfiler.html">clusterProfiler</a>.</p>
<ul>
<li>Biological processes (BP): Collections of molecular events and functions contributing to a biological process</li>
<li>Cellular component (CC): (sub-) cellular structures and locations, macromolecular complexes</li>
<li>Molecular functions (MF): Molecular functions like catalytic or binding activity</li>
</ul>
<div>
<pre><code><span>library</span><span>(</span><span>clusterProfiler</span><span>)</span><span>
</span><span>library</span><span>(</span><span>DOSE</span><span>)</span><span>
</span><span>for</span><span> </span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>nrow</span><span>(</span><span>datasets</span><span>))</span><span> </span><span>{</span><span>
</span><span>species</span><span> </span><span>&lt;-</span><span> </span><span>datasets</span><span>$</span><span>dataset</span><span>[</span><span>i</span><span>]</span><span>
</span><span>genes</span><span> </span><span>&lt;-</span><span> </span><span>as.character</span><span>(</span><span>unique</span><span>(</span><span>genes_homologs_all</span><span>[,</span><span> </span><span>species</span><span>]))</span><span>
</span><span>universe</span><span> </span><span>&lt;-</span><span> </span><span>as.character</span><span>(</span><span>unique</span><span>(</span><span>na.omit</span><span>(</span><span>homologs_table_combined</span><span>[,</span><span> </span><span>species</span><span>])))</span><span>
</span><span>cat</span><span>(</span><span>&quot;\nSpecies&quot;</span><span>,</span><span> </span><span>datasets</span><span>$</span><span>description</span><span>[</span><span>i</span><span>],</span><span> </span><span>&quot;has&quot;</span><span>,</span><span> </span><span>length</span><span>(</span><span>universe</span><span>),</span><span> </span><span>&quot;unique Entrez IDs, of which&quot;</span><span>,</span><span> </span><span>length</span><span>(</span><span>genes</span><span>),</span><span> </span><span>&quot;have homologs in all species.\n&quot;</span><span>)</span><span>
</span><span>try</span><span>(</span><span>go_enrich_BP</span><span> </span><span>&lt;-</span><span> </span><span>enrichGO</span><span>(</span><span>gene</span><span> </span><span>=</span><span> </span><span>genes</span><span>,</span><span> </span><span>keytype</span><span> </span><span>=</span><span> </span><span>&quot;ENTREZID&quot;</span><span>,</span><span>
</span><span>OrgDb</span><span> </span><span>=</span><span> </span><span>get</span><span>(</span><span>datasets</span><span>$</span><span>orgDb</span><span>[</span><span>i</span><span>]),</span><span>
</span><span>ont</span><span> </span><span>=</span><span> </span><span>&quot;BP&quot;</span><span>,</span><span>
</span><span>qvalueCutoff</span><span> </span><span>=</span><span> </span><span>0.05</span><span>,</span><span>
</span><span>universe</span><span> </span><span>=</span><span> </span><span>universe</span><span>,</span><span>
</span><span>readable</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span><span>try</span><span>(</span><span>go_enrich_MF</span><span> </span><span>&lt;-</span><span> </span><span>enrichGO</span><span>(</span><span>gene</span><span> </span><span>=</span><span> </span><span>genes</span><span>,</span><span> </span><span>keytype</span><span> </span><span>=</span><span> </span><span>&quot;ENTREZID&quot;</span><span>,</span><span>
</span><span>OrgDb</span><span> </span><span>=</span><span> </span><span>get</span><span>(</span><span>datasets</span><span>$</span><span>orgDb</span><span>[</span><span>i</span><span>]),</span><span>
</span><span>ont</span><span> </span><span>=</span><span> </span><span>&quot;MF&quot;</span><span>,</span><span>
</span><span>qvalueCutoff</span><span> </span><span>=</span><span> </span><span>0.05</span><span>,</span><span>
</span><span>universe</span><span> </span><span>=</span><span> </span><span>universe</span><span>,</span><span>
</span><span>readable</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span><span>try</span><span>(</span><span>go_enrich_CC</span><span> </span><span>&lt;-</span><span> </span><span>enrichGO</span><span>(</span><span>gene</span><span> </span><span>=</span><span> </span><span>genes</span><span>,</span><span> </span><span>keytype</span><span> </span><span>=</span><span> </span><span>&quot;ENTREZID&quot;</span><span>,</span><span>
</span><span>OrgDb</span><span> </span><span>=</span><span> </span><span>get</span><span>(</span><span>datasets</span><span>$</span><span>orgDb</span><span>[</span><span>i</span><span>]),</span><span>
</span><span>ont</span><span> </span><span>=</span><span> </span><span>&quot;CC&quot;</span><span>,</span><span>
</span><span>qvalueCutoff</span><span> </span><span>=</span><span> </span><span>0.05</span><span>,</span><span>
</span><span>universe</span><span> </span><span>=</span><span> </span><span>universe</span><span>,</span><span>
</span><span>readable</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span><span>try</span><span>(</span><span>assign</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_BP&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>),</span><span> </span><span>go_enrich_BP</span><span>))</span><span>
</span><span>try</span><span>(</span><span>assign</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_MF&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>),</span><span> </span><span>go_enrich_MF</span><span>))</span><span>
</span><span>try</span><span>(</span><span>assign</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_CC&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>),</span><span> </span><span>go_enrich_CC</span><span>))</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## 
## Species Rat has 47989 unique Entrez IDs, of which 1796 have homologs in all species.
## 
## Species Yeast has 6350 unique Entrez IDs, of which 1363 have homologs in all species.
## 
## Error in .testForValidCols(x, cols) : 
##   Invalid columns: SYMBOL. Please use the columns method to see a listing of valid arguments.
## Error in .testForValidCols(x, cols) : 
##   Invalid columns: SYMBOL. Please use the columns method to see a listing of valid arguments.
## Error in .testForValidCols(x, cols) : 
##   Invalid columns: SYMBOL. Please use the columns method to see a listing of valid arguments.
## 
## Species C. elegans has 46727 unique Entrez IDs, of which 1758 have homologs in all species.
## 
## Species Chimpanzee has 40540 unique Entrez IDs, of which 1704 have homologs in all species.
## 
## Species Pig has 54622 unique Entrez IDs, of which 1708 have homologs in all species.
## 
## Species Human has 60136 unique Entrez IDs, of which 1757 have homologs in all species.
## 
## Species Chicken has 34668 unique Entrez IDs, of which 1684 have homologs in all species.
## 
## Species Zebrafish has 47900 unique Entrez IDs, of which 1910 have homologs in all species.
## 
## Species Fruitfly has 25038 unique Entrez IDs, of which 1805 have homologs in all species.
## 
## Species Mouse has 68603 unique Entrez IDs, of which 1761 have homologs in all species.
## 
## Species Dog has 31376 unique Entrez IDs, of which 1716 have homologs in all species.
</code></pre>
</div>
<p>I’m not sure why yeast throws an error but since all other species worked I will ignore yeast genes for now…</p>
<p></p>
<h4>Visualizing enriched GO categories</h4>
<p>A heatmap of gene enrichment ratios shows enriched GO categories and their enrichment strength and allows us to capture comparable information for all species.</p>
<p>To generate this heatmap, I am using the output tables from clusterProfiler, which tell us the enrichment p-value (before and after correction for multiple testing, aka False Discovery Rate or FDR), the proportion of genes belonging to each GO category in the background versus all background genes and in our gene list compared to all genes in our list. To keep the graph reasonably small, I’m subsetting only the top 10 enriched genes with lowest adjusted p-values for biological processes (BP), molecular functions (MF) and cellular components (CC).</p>
<div>
<pre><code><span># removing yeast
</span><span>datasets_2</span><span> </span><span>&lt;-</span><span> </span><span>datasets</span><span>[</span><span>-</span><span>grep</span><span>(</span><span>&quot;scerevisiae_gene_ensembl&quot;</span><span>,</span><span> </span><span>datasets</span><span>$</span><span>dataset</span><span>),</span><span> </span><span>]</span><span>
</span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span>
</span><span>cutoff</span><span> </span><span>=</span><span> </span><span>10</span><span>
</span><span>for</span><span> </span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>nrow</span><span>(</span><span>datasets_2</span><span>))</span><span> </span><span>{</span><span>
</span><span>species</span><span> </span><span>&lt;-</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>[</span><span>i</span><span>]</span><span>
</span><span>go_enrich_BP_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_BP&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>GR</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>Count</span><span>)</span><span> </span><span>/</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;.*/&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>GeneRatio</span><span>)),</span><span>
</span><span>Category</span><span> </span><span>=</span><span> </span><span>&quot;BP&quot;</span><span>)</span><span>
</span><span>plot_BP</span><span> </span><span>&lt;-</span><span> </span><span>go_enrich_BP_df</span><span>[</span><span>1</span><span>:</span><span>cutoff</span><span>,</span><span> </span><span>]</span><span>
</span><span>plot_BP</span><span>$</span><span>Description</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>plot_BP</span><span>$</span><span>Description</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>plot_BP</span><span>$</span><span>Description</span><span>[</span><span>order</span><span>(</span><span>plot_BP</span><span>$</span><span>GR</span><span>)])</span><span>
</span><span>go_enrich_MF_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_MF&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>GR</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>Count</span><span>)</span><span> </span><span>/</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;.*/&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>GeneRatio</span><span>)),</span><span>
</span><span>Category</span><span> </span><span>=</span><span> </span><span>&quot;MF&quot;</span><span>)</span><span>
</span><span>plot_MF</span><span> </span><span>&lt;-</span><span> </span><span>go_enrich_MF_df</span><span>[</span><span>1</span><span>:</span><span>cutoff</span><span>,</span><span> </span><span>]</span><span>
</span><span>plot_MF</span><span>$</span><span>Description</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>plot_MF</span><span>$</span><span>Description</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>plot_MF</span><span>$</span><span>Description</span><span>[</span><span>order</span><span>(</span><span>plot_MF</span><span>$</span><span>GR</span><span>)])</span><span>
</span><span>go_enrich_CC_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_CC&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>GR</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>Count</span><span>)</span><span> </span><span>/</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;.*/&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>GeneRatio</span><span>)),</span><span>
</span><span>Category</span><span> </span><span>=</span><span> </span><span>&quot;CC&quot;</span><span>)</span><span>
</span><span>plot_CC</span><span> </span><span>&lt;-</span><span> </span><span>go_enrich_CC_df</span><span>[</span><span>1</span><span>:</span><span>cutoff</span><span>,</span><span> </span><span>]</span><span>
</span><span>plot_CC</span><span>$</span><span>Description</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>plot_CC</span><span>$</span><span>Description</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>plot_CC</span><span>$</span><span>Description</span><span>[</span><span>order</span><span>(</span><span>plot_CC</span><span>$</span><span>GR</span><span>)])</span><span>
</span><span>plot</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>plot_BP</span><span>,</span><span> </span><span>plot_MF</span><span>,</span><span> </span><span>plot_CC</span><span>)</span><span>
</span><span>plot</span><span>$</span><span>Species</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>datasets_2</span><span>$</span><span>description</span><span>[</span><span>i</span><span>])</span><span>
</span><span>if</span><span> </span><span>(</span><span>i</span><span> </span><span>==</span><span> </span><span>1</span><span>)</span><span> </span><span>{</span><span>
</span><span>plot_df</span><span> </span><span>&lt;-</span><span> </span><span>plot</span><span>
</span><span>}</span><span> </span><span>else</span><span> </span><span>{</span><span>
</span><span>plot_df</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>plot_df</span><span>,</span><span> </span><span>plot</span><span>)</span><span>
</span><span>}</span><span>
</span><span>}</span><span>
</span><span>length</span><span>(</span><span>unique</span><span>(</span><span>plot_df</span><span>$</span><span>ID</span><span>))</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## [1] 123
</code></pre>
</div>
<div>
<pre><code><span>ggplot</span><span>(</span><span>plot_df</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>Species</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>Description</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>GR</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_tile</span><span>(</span><span>width</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>height</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_fill_gradient2</span><span>(</span><span>low</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>,</span><span> </span><span>mid</span><span> </span><span>=</span><span> </span><span>&quot;blue&quot;</span><span>,</span><span> </span><span>high</span><span> </span><span>=</span><span> </span><span>&quot;red&quot;</span><span>,</span><span> </span><span>space</span><span> </span><span>=</span><span> </span><span>&quot;Lab&quot;</span><span>,</span><span> </span><span>name</span><span> </span><span>=</span><span> </span><span>&quot;Gene Ratio&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>facet_grid</span><span>(</span><span>Category</span><span> </span><span>~</span><span> </span><span>.</span><span>,</span><span> </span><span>scales</span><span> </span><span>=</span><span> </span><span>&quot;free_y&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>scale_x_discrete</span><span>(</span><span>position</span><span> </span><span>=</span><span> </span><span>&quot;top&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>
</span><span>title</span><span> </span><span>=</span><span> </span><span>paste</span><span>(</span><span>&quot;Top&quot;</span><span>,</span><span> </span><span>cutoff</span><span>,</span><span> </span><span>&quot;enriched GO terms&quot;</span><span>),</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>
</span><span>)</span><span>
</span></code></pre>
</div>
<p></p>
<p><img src="https://i0.wp.com/shiring.github.io/genome/2017/01/05/homologous_genes_part3_post_files/figure-markdown_github/unnamed-chunk-12-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<h4>Word clouds</h4>
<p>Another way to capture information about GO terms is to use the GO description texts as basis for wordclouds. I’m using the general method described <a target="_blank" rel="nofollow" href="https://shiring.github.io/text_analysis/2016/11/06/sysk_earwax">here</a>. I’m also included a list of words to remove, like process, activity, etc. These words occur often and on their own don’t tell us much about the GO term.</p>
<div>
<pre><code><span>library</span><span>(</span><span>tm</span><span>)</span><span>
</span><span>library</span><span>(</span><span>SnowballC</span><span>)</span><span>
</span><span>library</span><span>(</span><span>wordcloud</span><span>)</span><span>
</span><span>library</span><span>(</span><span>RColorBrewer</span><span>)</span><span>
</span><span>wordcloud_function</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>data</span><span>,</span><span>
</span><span>removewords</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;process&quot;</span><span>,</span><span> </span><span>&quot;activity&quot;</span><span>,</span><span> </span><span>&quot;positive&quot;</span><span>,</span><span> </span><span>&quot;negative&quot;</span><span>,</span><span> </span><span>&quot;response&quot;</span><span>,</span><span> </span><span>&quot;regulation&quot;</span><span>),</span><span>
</span><span>min.freq</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span>
</span><span>max.words</span><span>=</span><span>Inf</span><span>,</span><span>
</span><span>random.order</span><span>=</span><span>TRUE</span><span>){</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>Corpus</span><span>(</span><span>VectorSource</span><span>(</span><span>data</span><span>))</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>content_transformer</span><span>(</span><span>tolower</span><span>))</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>content_transformer</span><span>(</span><span>removePunctuation</span><span>))</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>removeNumbers</span><span>)</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>stripWhitespace</span><span>)</span><span>
</span><span>toSpace</span><span> </span><span>&lt;-</span><span> </span><span>content_transformer</span><span>(</span><span>function</span><span>(</span><span>x</span><span> </span><span>,</span><span> </span><span>pattern</span><span> </span><span>)</span><span> </span><span>gsub</span><span>(</span><span>pattern</span><span>,</span><span> </span><span>&quot; &quot;</span><span>,</span><span> </span><span>x</span><span>))</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>toSpace</span><span>,</span><span> </span><span>&quot;/&quot;</span><span>)</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>toSpace</span><span>,</span><span> </span><span>&quot;@&quot;</span><span>)</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>toSpace</span><span>,</span><span> </span><span>&quot;\\|&quot;</span><span>)</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span> </span><span>removeWords</span><span>(</span><span>x</span><span>,</span><span> </span><span>stopwords</span><span>(</span><span>&quot;english&quot;</span><span>)))</span><span>
</span><span># specify your stopwords as a character vector
</span><span> </span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>tm_map</span><span>(</span><span>input</span><span>,</span><span> </span><span>removeWords</span><span>,</span><span> </span><span>removewords</span><span>)</span><span>
</span><span>tdm</span><span> </span><span>&lt;-</span><span> </span><span>TermDocumentMatrix</span><span>(</span><span>input</span><span>)</span><span>
</span><span>m</span><span> </span><span>&lt;-</span><span> </span><span>as.matrix</span><span>(</span><span>tdm</span><span>)</span><span>
</span><span>v</span><span> </span><span>&lt;-</span><span> </span><span>sort</span><span>(</span><span>rowSums</span><span>(</span><span>m</span><span>),</span><span>decreasing</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>d</span><span> </span><span>&lt;-</span><span> </span><span>data.frame</span><span>(</span><span>word</span><span> </span><span>=</span><span> </span><span>names</span><span>(</span><span>v</span><span>),</span><span>freq</span><span> </span><span>=</span><span> </span><span>v</span><span>)</span><span>
</span><span>set.seed</span><span>(</span><span>1234</span><span>)</span><span>
</span><span>wordcloud</span><span>(</span><span>words</span><span> </span><span>=</span><span> </span><span>d</span><span>$</span><span>word</span><span>,</span><span> </span><span>freq</span><span> </span><span>=</span><span> </span><span>d</span><span>$</span><span>freq</span><span>,</span><span> </span><span>min.freq</span><span> </span><span>=</span><span> </span><span>min.freq</span><span>,</span><span> </span><span>scale</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>8</span><span>,</span><span>.2</span><span>),</span><span>
</span><span>max.words</span><span> </span><span>=</span><span> </span><span>max.words</span><span>,</span><span> </span><span>random.order</span><span> </span><span>=</span><span> </span><span>random.order</span><span>,</span><span> </span><span>rot.per</span><span> </span><span>=</span><span> </span><span>0.15</span><span>,</span><span>
</span><span>colors</span><span> </span><span>=</span><span> </span><span>brewer.pal</span><span>(</span><span>8</span><span>,</span><span> </span><span>&quot;Dark2&quot;</span><span>))</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>layout</span><span>(</span><span>matrix</span><span>(</span><span>c</span><span>(</span><span>1</span><span>:</span><span>80</span><span>),</span><span> </span><span>nrow</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span>byrow</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>),</span><span> </span><span>heights</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>0.1</span><span>,</span><span> </span><span>1</span><span>))</span><span>
</span><span>for</span><span> </span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>nrow</span><span>(</span><span>datasets_2</span><span>))</span><span> </span><span>{</span><span>
</span><span>species</span><span> </span><span>&lt;-</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>[</span><span>i</span><span>]</span><span>
</span><span>df_BP</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_BP&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>df_MF</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_MF&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>df_CC</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_CC&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>par</span><span>(</span><span>mar</span><span> </span><span>=</span><span> </span><span>rep</span><span>(</span><span>0</span><span>,</span><span> </span><span>4</span><span>))</span><span>
</span><span>plot.new</span><span>()</span><span>
</span><span>text</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>paste0</span><span>(</span><span>datasets_2</span><span>$</span><span>description</span><span>[</span><span>i</span><span>]),</span><span> </span><span>cex</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span><span>wordcloud_function</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>df_BP</span><span>$</span><span>Description</span><span>)</span><span>
</span><span>wordcloud_function</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>df_MF</span><span>$</span><span>Description</span><span>)</span><span>
</span><span>wordcloud_function</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>df_CC</span><span>$</span><span>Description</span><span>)</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<p><img src="https://i2.wp.com/shiring.github.io/genome/2017/01/05/homologous_genes_part3_post_files/figure-markdown_github/unnamed-chunk-14-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<h4>Which GO terms are enriched in all species?</h4>
<p>I also want to know which specific GO categories are enriched in all species. Even though we might miss related terms, this will give us a first idea about the biological functions that are highly conserved between species.</p>
<p>I’m creating a list of enriched GO categories of all species and ask for common elements using the <strong>list.common</strong> function of the <a target="_blank" rel="nofollow" href="https://cran.r-project.org/web/packages/rlist/index.html">rlist</a> package.</p>
<div>
<pre><code><span># create empty list to populate with a loop
</span><span>go_list_BP</span><span> </span><span>&lt;-</span><span> </span><span>lapply</span><span>(</span><span>datasets_2</span><span>$</span><span>dataset</span><span>,</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span> </span><span>NULL</span><span>)</span><span>
</span><span>names</span><span>(</span><span>go_list_BP</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>datasets_2</span><span>$</span><span>dataset</span><span>)</span><span>
</span><span>for</span><span> </span><span>(</span><span>species</span><span> </span><span>in</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>)</span><span> </span><span>{</span><span>
</span><span>df_BP</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_BP&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>go_list_BP</span><span>[[</span><span>species</span><span>]]</span><span> </span><span>&lt;-</span><span> </span><span>df_BP</span><span>$</span><span>ID</span><span>
</span><span>}</span><span>
</span><span># Now I know which GO IDs are common but I want to know the description as well.
# Because they are in all go_enrich tables, I'm chosen one to subset
</span><span>
</span><span>library</span><span>(</span><span>rlist</span><span>)</span><span>
</span><span>common_gos_BP</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>go_enrich_BP_cfamiliaris_gene_ensembl</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>ID</span><span> </span><span>%in%</span><span> </span><span>list.common</span><span>(</span><span>go_list_BP</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>ID</span><span>,</span><span> </span><span>Description</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>Description</span><span>)</span><span>
</span><span>go_list_MF</span><span> </span><span>&lt;-</span><span> </span><span>lapply</span><span>(</span><span>datasets_2</span><span>$</span><span>dataset</span><span>,</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span> </span><span>NULL</span><span>)</span><span>
</span><span>names</span><span>(</span><span>go_list_MF</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>datasets_2</span><span>$</span><span>dataset</span><span>)</span><span>
</span><span>for</span><span> </span><span>(</span><span>species</span><span> </span><span>in</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>)</span><span> </span><span>{</span><span>
</span><span>df_MF</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_MF&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>go_list_MF</span><span>[[</span><span>species</span><span>]]</span><span> </span><span>&lt;-</span><span> </span><span>df_MF</span><span>$</span><span>ID</span><span>
</span><span>}</span><span>
</span><span>library</span><span>(</span><span>rlist</span><span>)</span><span>
</span><span>common_gos_MF</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>go_enrich_MF_cfamiliaris_gene_ensembl</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>ID</span><span> </span><span>%in%</span><span> </span><span>list.common</span><span>(</span><span>go_list_MF</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>ID</span><span>,</span><span> </span><span>Description</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>Description</span><span>)</span><span>
</span><span>go_list_CC</span><span> </span><span>&lt;-</span><span> </span><span>lapply</span><span>(</span><span>datasets_2</span><span>$</span><span>dataset</span><span>,</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span> </span><span>NULL</span><span>)</span><span>
</span><span>names</span><span>(</span><span>go_list_CC</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>datasets_2</span><span>$</span><span>dataset</span><span>)</span><span>
</span><span>for</span><span> </span><span>(</span><span>species</span><span> </span><span>in</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>)</span><span> </span><span>{</span><span>
</span><span>df_CC</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_CC&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>go_list_CC</span><span>[[</span><span>species</span><span>]]</span><span> </span><span>&lt;-</span><span> </span><span>df_CC</span><span>$</span><span>ID</span><span>
</span><span>}</span><span>
</span><span>library</span><span>(</span><span>rlist</span><span>)</span><span>
</span><span>common_gos_CC</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>go_enrich_CC_cfamiliaris_gene_ensembl</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>ID</span><span> </span><span>%in%</span><span> </span><span>list.common</span><span>(</span><span>go_list_CC</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>ID</span><span>,</span><span> </span><span>Description</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>Description</span><span>)</span><span>
</span></code></pre>
</div>
<p>To visualize these common GO categories, I’m going back to the clusterProfiler output tables. This time I’m not using a heatmap, but a point plot to show enrichment statistics for all species.</p>
<div>
<pre><code><span>for</span><span> </span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>nrow</span><span>(</span><span>datasets_2</span><span>))</span><span> </span><span>{</span><span>
</span><span>species</span><span> </span><span>&lt;-</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>[</span><span>i</span><span>]</span><span>
</span><span>go_enrich_BP_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_BP&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>ID</span><span> </span><span>%in%</span><span> </span><span>list.common</span><span>(</span><span>go_list_BP</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>GR</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>Count</span><span>)</span><span> </span><span>/</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;.*/&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>GeneRatio</span><span>)),</span><span>
</span><span>Category</span><span> </span><span>=</span><span> </span><span>&quot;BP&quot;</span><span>)</span><span>
</span><span>go_enrich_BP_df</span><span>$</span><span>Description</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>go_enrich_BP_df</span><span>$</span><span>Description</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>go_enrich_BP_df</span><span>$</span><span>Description</span><span>[</span><span>order</span><span>(</span><span>go_enrich_BP_df</span><span>$</span><span>GR</span><span>)])</span><span>
</span><span>go_enrich_MF_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_MF&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>ID</span><span> </span><span>%in%</span><span> </span><span>list.common</span><span>(</span><span>go_list_MF</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>GR</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>Count</span><span>)</span><span> </span><span>/</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;.*/&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>GeneRatio</span><span>)),</span><span>
</span><span>Category</span><span> </span><span>=</span><span> </span><span>&quot;MF&quot;</span><span>)</span><span>
</span><span>go_enrich_MF_df</span><span>$</span><span>Description</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>go_enrich_MF_df</span><span>$</span><span>Description</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>go_enrich_MF_df</span><span>$</span><span>Description</span><span>[</span><span>order</span><span>(</span><span>go_enrich_MF_df</span><span>$</span><span>GR</span><span>)])</span><span>
</span><span>go_enrich_CC_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_CC&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>ID</span><span> </span><span>%in%</span><span> </span><span>list.common</span><span>(</span><span>go_list_CC</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>GR</span><span> </span><span>=</span><span> </span><span>as.numeric</span><span>(</span><span>Count</span><span>)</span><span> </span><span>/</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;.*/&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>GeneRatio</span><span>)),</span><span>
</span><span>Category</span><span> </span><span>=</span><span> </span><span>&quot;CC&quot;</span><span>)</span><span>
</span><span>go_enrich_CC_df</span><span>$</span><span>Description</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>go_enrich_CC_df</span><span>$</span><span>Description</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>go_enrich_CC_df</span><span>$</span><span>Description</span><span>[</span><span>order</span><span>(</span><span>go_enrich_CC_df</span><span>$</span><span>GR</span><span>)])</span><span>
</span><span>plot</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>go_enrich_BP_df</span><span>,</span><span> </span><span>go_enrich_MF_df</span><span>,</span><span> </span><span>go_enrich_CC_df</span><span>)</span><span>
</span><span>plot</span><span>$</span><span>Species</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>datasets_2</span><span>$</span><span>description</span><span>[</span><span>i</span><span>])</span><span>
</span><span>if</span><span> </span><span>(</span><span>i</span><span> </span><span>==</span><span> </span><span>1</span><span>)</span><span> </span><span>{</span><span>
</span><span>plot_df</span><span> </span><span>&lt;-</span><span> </span><span>plot</span><span>
</span><span>}</span><span> </span><span>else</span><span> </span><span>{</span><span>
</span><span>plot_df</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>plot_df</span><span>,</span><span> </span><span>plot</span><span>)</span><span>
</span><span>}</span><span>
</span><span>}</span><span>
</span><span>ggplot</span><span>(</span><span>plot_df</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>GR</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>Description</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>Count</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>p.adjust</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>()</span><span> </span><span>+</span><span>
</span><span>labs</span><span>(</span><span>
</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;Common enriched GO terms&quot;</span><span>,</span><span>
</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Gene Ratio&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>
</span><span>)</span><span> </span><span>+</span><span>
</span><span>facet_grid</span><span>(</span><span>Category</span><span> </span><span>~</span><span> </span><span>Species</span><span>,</span><span> </span><span>scales</span><span> </span><span>=</span><span> </span><span>&quot;free_y&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p></p>
<p><img src="https://i2.wp.com/shiring.github.io/genome/2017/01/05/homologous_genes_part3_post_files/figure-markdown_github/unnamed-chunk-16-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>Gene Ratio is shown on the x-axis, point size shows the gene counts and point color shows the adjusted p-value.</p>
<p></p>
<h4>GO hierachical structure</h4>
<p>The package <a target="_blank" rel="nofollow" href="https://bioconductor.org/packages/release/bioc/html/RamiGO.html">RamiGO</a> can be used to plot all parents of the 10 common GO categories:</p>
<div>
<pre><code><span>library</span><span>(</span><span>RamiGO</span><span>)</span><span>
</span><span>library</span><span>(</span><span>RColorBrewer</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>set3</span><span> </span><span>&lt;-</span><span> </span><span>brewer.pal</span><span>(</span><span>10</span><span>,</span><span> </span><span>&quot;Set3&quot;</span><span>)</span><span>
</span><span>goIDs</span><span> </span><span>&lt;-</span><span> </span><span>list.common</span><span>(</span><span>go_list_BP</span><span>)</span><span>
</span><span>getAmigoTree</span><span>(</span><span>goIDs</span><span>,</span><span> </span><span>set3</span><span>,</span><span> </span><span>filename</span><span> </span><span>=</span><span> </span><span>&quot;common_gos_BP&quot;</span><span>,</span><span> </span><span>picType</span><span> </span><span>=</span><span> </span><span>&quot;png&quot;</span><span>,</span><span> </span><span>modeType</span><span> </span><span>=</span><span> </span><span>&quot;amigo&quot;</span><span>,</span><span> </span><span>saveResult</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>set3</span><span> </span><span>&lt;-</span><span> </span><span>brewer.pal</span><span>(</span><span>8</span><span>,</span><span> </span><span>&quot;Set3&quot;</span><span>)</span><span>
</span><span>goIDs</span><span> </span><span>&lt;-</span><span> </span><span>list.common</span><span>(</span><span>go_list_MF</span><span>)</span><span>
</span><span>getAmigoTree</span><span>(</span><span>goIDs</span><span>,</span><span> </span><span>set3</span><span>,</span><span> </span><span>filename</span><span> </span><span>=</span><span> </span><span>&quot;common_gos_MF&quot;</span><span>,</span><span> </span><span>picType</span><span> </span><span>=</span><span> </span><span>&quot;png&quot;</span><span>,</span><span> </span><span>modeType</span><span> </span><span>=</span><span> </span><span>&quot;amigo&quot;</span><span>,</span><span> </span><span>saveResult</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>goIDs</span><span> </span><span>&lt;-</span><span> </span><span>list.common</span><span>(</span><span>go_list_CC</span><span>)</span><span>
</span><span>getAmigoTree</span><span>(</span><span>goIDs</span><span>,</span><span> </span><span>set3</span><span>,</span><span> </span><span>filename</span><span> </span><span>=</span><span> </span><span>&quot;common_gos_CC&quot;</span><span>,</span><span> </span><span>picType</span><span> </span><span>=</span><span> </span><span>&quot;png&quot;</span><span>,</span><span> </span><span>modeType</span><span> </span><span>=</span><span> </span><span>&quot;amigo&quot;</span><span>,</span><span> </span><span>saveResult</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span></code></pre>
</div>
<ul>
<li>Common GOs BP</li>
</ul>
<p><img alt="" src="https://i1.wp.com/shiring.github.io/genome/2017/01/05/common_gos_BP.png?w=456&ssl=1" data-recalc-dims="1"></p>
<ul>
<li>Common GOs MF</li>
</ul>
<p><img alt="" src="https://i0.wp.com/shiring.github.io/genome/2017/01/05/common_gos_MF.png?w=456&ssl=1" data-recalc-dims="1"></p>
<ul>
<li>Common GOs CC</li>
</ul>
<p><img alt="" src="https://i2.wp.com/shiring.github.io/genome/2017/01/05/common_gos_CC.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<h4>GO network</h4>
<p>To visualize clusters of species-specific and common enriched GO categories within their hierachical structure, I’m creating a network of the top 15 enriched biological process categories of each species with two levels of parent terms.</p>
<div>
<pre><code><span>for</span><span> </span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>1</span><span>:</span><span>nrow</span><span>(</span><span>datasets_2</span><span>))</span><span> </span><span>{</span><span>
</span><span>species</span><span> </span><span>&lt;-</span><span> </span><span>datasets_2</span><span>$</span><span>dataset</span><span>[</span><span>i</span><span>]</span><span>
</span><span>df_BP</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>get</span><span>(</span><span>paste</span><span>(</span><span>&quot;go_enrich_BP&quot;</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;_&quot;</span><span>)))</span><span>
</span><span>df_BP</span><span> </span><span>&lt;-</span><span> </span><span>df_BP</span><span>[</span><span>1</span><span>:</span><span>15</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>]</span><span>
</span><span>df_BP</span><span>$</span><span>species</span><span> </span><span>&lt;-</span><span> </span><span>datasets_2</span><span>$</span><span>description</span><span>[</span><span>i</span><span>]</span><span>
</span><span>if</span><span> </span><span>(</span><span>i</span><span> </span><span>==</span><span> </span><span>1</span><span>)</span><span> </span><span>{</span><span>
</span><span>df_BP_all</span><span> </span><span>&lt;-</span><span> </span><span>df_BP</span><span>
</span><span>}</span><span> </span><span>else</span><span> </span><span>{</span><span>
</span><span>df_BP_all</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>df_BP_all</span><span>,</span><span> </span><span>df_BP</span><span>)</span><span>
</span><span>}</span><span>
</span><span>}</span><span>
</span><span>length</span><span>(</span><span>unique</span><span>(</span><span>df_BP_all</span><span>$</span><span>ID</span><span>))</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## [1] 69
</code></pre>
</div>
<p>Of these top GO categories most are not unique to individual species.</p>
<p>In the network I want to show GO categories that are species-specific and those that are common among all species. To create the annotation data with this information I’m creating a dataframe with the names of the species along with their specific GO term and combine this with the common GO terms from above.</p>
<div>
<pre><code><span>library</span><span>(</span><span>tidyr</span><span>)</span><span>
</span><span>df_BP_all</span><span>$</span><span>value</span><span> </span><span>&lt;-</span><span> </span><span>1</span><span>
</span><span>df_BP_all</span><span> </span><span>&lt;-</span><span> </span><span>spread</span><span>(</span><span>df_BP_all</span><span>,</span><span> </span><span>species</span><span>,</span><span> </span><span>value</span><span>)</span><span>
</span><span>go_sums</span><span> </span><span>&lt;-</span><span> </span><span>data.frame</span><span>(</span><span>ID</span><span> </span><span>=</span><span> </span><span>df_BP_all</span><span>$</span><span>ID</span><span>,</span><span>
</span><span>sum</span><span> </span><span>=</span><span> </span><span>rowSums</span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>df_BP_all</span><span>[,</span><span> </span><span>-1</span><span>])))</span><span>
</span><span># GO in all species
</span><span>go_anno</span><span> </span><span>&lt;-</span><span> </span><span>data.frame</span><span>(</span><span>ID</span><span> </span><span>=</span><span> </span><span>go_sums</span><span>$</span><span>ID</span><span>)</span><span>
</span><span>go_anno</span><span>$</span><span>group</span><span> </span><span>&lt;-</span><span> </span><span>ifelse</span><span>(</span><span>go_sums</span><span>$</span><span>sum</span><span> </span><span>==</span><span> </span><span>10</span><span>,</span><span> </span><span>&quot;common_all&quot;</span><span>,</span><span> </span><span>NA</span><span>)</span><span>
</span><span>x</span><span> </span><span>&lt;-</span><span> </span><span>subset</span><span>(</span><span>go_sums</span><span>,</span><span> </span><span>sum</span><span> </span><span>==</span><span> </span><span>1</span><span>)</span><span>
</span><span>xx</span><span> </span><span>&lt;-</span><span> </span><span>subset</span><span>(</span><span>df_BP_all</span><span>,</span><span> </span><span>ID</span><span> </span><span>%in%</span><span> </span><span>x</span><span>$</span><span>ID</span><span>)</span><span>
</span><span>for</span><span> </span><span>(</span><span>i</span><span> </span><span>in</span><span> </span><span>2</span><span>:</span><span>11</span><span>)</span><span> </span><span>{</span><span>
</span><span>xxx</span><span> </span><span>&lt;-</span><span> </span><span>xx</span><span>[,</span><span> </span><span>i</span><span>]</span><span>
</span><span>xxx</span><span>[</span><span>which</span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>xxx</span><span>))]</span><span> </span><span>&lt;-</span><span> </span><span>colnames</span><span>(</span><span>xx</span><span>[,</span><span> </span><span>i</span><span>,</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>])</span><span>
</span><span>unique</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>cbind</span><span>(</span><span>xx</span><span>[,</span><span> </span><span>1</span><span>],</span><span> </span><span>xxx</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>subset</span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>xxx</span><span>))</span><span>
</span><span>if</span><span> </span><span>(</span><span>i</span><span> </span><span>==</span><span> </span><span>2</span><span>)</span><span> </span><span>{</span><span>
</span><span>unique_all</span><span> </span><span>&lt;-</span><span> </span><span>unique</span><span>
</span><span>}</span><span> </span><span>else</span><span> </span><span>{</span><span>
</span><span>unique_all</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>unique_all</span><span>,</span><span> </span><span>unique</span><span>)</span><span>
</span><span>}</span><span>
</span><span>}</span><span>
</span><span># Common GOs
</span><span>unique_common_all</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>unique_all</span><span>,</span><span> </span><span>data.frame</span><span>(</span><span>V</span><span>1</span><span> </span><span>=</span><span> </span><span>list.common</span><span>(</span><span>go_list_BP</span><span>),</span><span> </span><span>xxx</span><span> </span><span>=</span><span> </span><span>&quot;common&quot;</span><span>))</span><span>
</span></code></pre>
</div>
<p>To identify the parent GO terms, I’m using the <a target="_blank" rel="nofollow" href="http://bioconductor.org/packages/release/data/annotation/html/GO.db.html">GO.db</a> package. I’m adding two levels of parental structure for each GO term.</p>
<div>
<pre><code><span>library</span><span>(</span><span>GO.db</span><span>)</span><span>
</span><span># GO parents list
</span><span>ontology</span><span> </span><span>&lt;-</span><span> </span><span>as.list</span><span>(</span><span>GOBPPARENTS</span><span>)</span><span>
</span><span>goChilds</span><span> </span><span>&lt;-</span><span> </span><span>unique</span><span>(</span><span>df_BP_all</span><span>$</span><span>ID</span><span>)</span><span>
</span><span>goChilds</span><span> </span><span>&lt;-</span><span> </span><span>goChilds</span><span>[</span><span>goChilds</span><span> </span><span>%in%</span><span> </span><span>names</span><span>(</span><span>ontology</span><span>)]</span><span>
</span><span>adjList</span><span> </span><span>&lt;-</span><span> </span><span>matrix</span><span>(</span><span>nrow</span><span> </span><span>=</span><span> </span><span>0</span><span>,</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>3</span><span>)</span><span>
</span><span>colnames</span><span>(</span><span>adjList</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>&quot;parent&quot;</span><span>,</span><span> </span><span>&quot;rel&quot;</span><span>,</span><span> </span><span>&quot;child&quot;</span><span>)</span><span>
</span><span># Find parents
</span><span>goChilds</span><span> </span><span>&lt;-</span><span> </span><span>goChilds</span><span>[</span><span>which</span><span>(</span><span>goChilds</span><span> </span><span>!=</span><span> </span><span>&quot;all&quot;</span><span>)]</span><span>
</span><span>goFamilyList</span><span> </span><span>&lt;-</span><span> </span><span>lapply</span><span>(</span><span>ontology</span><span>[</span><span>goChilds</span><span>],</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span> </span><span>data.frame</span><span>(</span><span>parent</span><span> </span><span>=</span><span> </span><span>x</span><span>,</span><span> </span><span>rel</span><span> </span><span>=</span><span> </span><span>names</span><span>(</span><span>x</span><span>)))</span><span>
</span><span>adjList</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>adjList</span><span>,</span><span> </span><span>as.matrix</span><span>(</span><span>cbind</span><span>(</span><span>do.call</span><span>(</span><span>rbind</span><span>,</span><span> </span><span>goFamilyList</span><span>),</span><span> </span><span>child</span><span> </span><span>=</span><span> </span><span>rep</span><span>(</span><span>names</span><span>(</span><span>goFamilyList</span><span>),</span><span> </span><span>sapply</span><span>(</span><span>goFamilyList</span><span>,</span><span> </span><span>nrow</span><span>)))))</span><span>
</span><span># Next parents
</span><span>goParents</span><span> </span><span>&lt;-</span><span> </span><span>unique</span><span>(</span><span>as.character</span><span>(</span><span>adjList</span><span>[</span><span>which</span><span>(</span><span>!</span><span>adjList</span><span>[,</span><span>&quot;parent&quot;</span><span>]</span><span> </span><span>%in%</span><span> </span><span>adjList</span><span>[,</span><span>&quot;child&quot;</span><span>]),</span><span> </span><span>&quot;parent&quot;</span><span>]))</span><span> </span><span>goFamilyList_2</span><span> </span><span>&lt;-</span><span> </span><span>lapply</span><span>(</span><span>ontology</span><span>[</span><span>goParents</span><span>],</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span> </span><span>data.frame</span><span>(</span><span>parent</span><span> </span><span>=</span><span> </span><span>x</span><span>,</span><span> </span><span>rel</span><span> </span><span>=</span><span> </span><span>names</span><span>(</span><span>x</span><span>)))</span><span>
</span><span>adjList</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>adjList</span><span>,</span><span> </span><span>as.matrix</span><span>(</span><span>cbind</span><span>(</span><span>do.call</span><span>(</span><span>rbind</span><span>,</span><span> </span><span>goFamilyList_2</span><span>),</span><span> </span><span>child</span><span> </span><span>=</span><span> </span><span>rep</span><span>(</span><span>names</span><span>(</span><span>goFamilyList_2</span><span>),</span><span> </span><span>sapply</span><span>(</span><span>goFamilyList_2</span><span>,</span><span> </span><span>nrow</span><span>)))))</span><span>
</span><span>adjList</span><span> </span><span>&lt;-</span><span> </span><span>adjList</span><span>[</span><span>which</span><span>(</span><span>adjList</span><span>[,</span><span>1</span><span>]</span><span> </span><span>!=</span><span> </span><span>&quot;all&quot;</span><span>),</span><span> </span><span>,</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>]</span><span>
</span><span>adjList</span><span> </span><span>&lt;-</span><span> </span><span>adjList</span><span>[,</span><span> </span><span>c</span><span>(</span><span>&quot;child&quot;</span><span>,</span><span>&quot;parent&quot;</span><span>,</span><span> </span><span>&quot;rel&quot;</span><span>),</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>]</span><span>
</span></code></pre>
</div>
<p>The graph is then prodcued with <a target="_blank" rel="nofollow" href="http://igraph.org/redirect.html">igraph</a> as a directed network. Colors show species-specific, common and remaining enriched GO categories. Parents are shown in light blue.</p>
<div>
<pre><code><span>library</span><span>(</span><span>igraph</span><span>)</span><span>
</span><span>goGraph</span><span> </span><span>&lt;-</span><span> </span><span>graph.edgelist</span><span>(</span><span>adjList</span><span>[,</span><span> </span><span>c</span><span>(</span><span>&quot;parent&quot;</span><span>,</span><span> </span><span>&quot;child&quot;</span><span>),</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>],</span><span> </span><span>directed</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>goGraph</span><span> </span><span>&lt;-</span><span> </span><span>set.edge.attribute</span><span>(</span><span>goGraph</span><span>,</span><span> </span><span>&quot;type&quot;</span><span>,</span><span> </span><span>value</span><span> </span><span>=</span><span> </span><span>adjList</span><span>[,</span><span>&quot;rel&quot;</span><span>])</span><span>
</span><span>goTerms</span><span> </span><span>&lt;-</span><span> </span><span>sapply</span><span>(</span><span>V</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>name</span><span>,</span><span> </span><span>function</span><span>(</span><span>x</span><span>)</span><span>
</span><span>{</span><span>
</span><span>term</span><span> </span><span>&lt;-</span><span> </span><span>GOTERM</span><span>[[</span><span>x</span><span>]]</span><span>@</span><span>Term</span><span>
</span><span>term</span><span> </span><span>&lt;-</span><span> </span><span>gsub</span><span>(</span><span>&quot;( process)$&quot;</span><span>,</span><span> </span><span>&quot; pr.&quot;</span><span>,</span><span> </span><span>term</span><span>)</span><span>
</span><span>term</span><span> </span><span>&lt;-</span><span> </span><span>gsub</span><span>(</span><span>&quot; development &quot;</span><span>,</span><span> </span><span>&quot; dev. &quot;</span><span>,</span><span> </span><span>term</span><span>)</span><span>
</span><span>term</span><span> </span><span>&lt;-</span><span> </span><span>gsub</span><span>(</span><span>&quot;( development)$&quot;</span><span>,</span><span> </span><span>&quot; dev.&quot;</span><span>,</span><span> </span><span>term</span><span>,</span><span> </span><span>perl</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>term</span><span> </span><span>&lt;-</span><span> </span><span>gsub</span><span>(</span><span>&quot;Development &quot;</span><span>,</span><span> </span><span>&quot;Dev. &quot;</span><span>,</span><span> </span><span>term</span><span>)</span><span>
</span><span># split in two lines
</span><span> </span><span>spaceLoc</span><span> </span><span>&lt;-</span><span> </span><span>gregexpr</span><span>(</span><span>&quot; &quot;</span><span>,</span><span> </span><span>term</span><span>,</span><span> </span><span>fixed</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)[[</span><span>1</span><span>]]</span><span>
</span><span>if</span><span> </span><span>((</span><span>spaceLoc</span><span>[</span><span>1</span><span>]</span><span> </span><span>!=</span><span> </span><span>-1</span><span>)</span><span> </span><span>&amp;&amp;</span><span> </span><span>(</span><span>length</span><span>(</span><span>spaceLoc</span><span>)</span><span> </span><span>></span><span> </span><span>1</span><span>))</span><span>
</span><span>{</span><span>
</span><span>spaceLoc</span><span> </span><span>&lt;-</span><span> </span><span>spaceLoc</span><span>[</span><span>ceiling</span><span>(</span><span>length</span><span>(</span><span>spaceLoc</span><span>)</span><span>/</span><span>2</span><span>)]</span><span>
</span><span>term</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>substr</span><span>(</span><span>term</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>spaceLoc</span><span> </span><span>-</span><span> </span><span>1</span><span>),</span><span> </span><span>substr</span><span>(</span><span>term</span><span>,</span><span> </span><span>spaceLoc</span><span> </span><span>+</span><span> </span><span>1</span><span>,</span><span> </span><span>nchar</span><span>(</span><span>term</span><span>)),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;\n&quot;</span><span>)</span><span>
</span><span>}</span><span>
</span><span>term</span><span>
</span><span>})</span><span>
</span><span>goTerms_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>goTerms</span><span>)</span><span>
</span><span>goTerms_df</span><span>$</span><span>color</span><span> </span><span>&lt;-</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;C. elegans&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;green&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Chicken&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;yellowgreen&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Chimpanzee&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;violetred&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Dog&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;turquoise&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Fruitfly&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;violet&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Human&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;thistle&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Mouse&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;tan1&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Pig&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;steelblue&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Rat&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;orangered&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;Zebrafish&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;olivedrab&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>unique_common_all</span><span>[</span><span>which</span><span>(</span><span>unique_common_all</span><span>$</span><span>xxx</span><span> </span><span>==</span><span> </span><span>&quot;common&quot;</span><span>),</span><span> </span><span>1</span><span>],</span><span> </span><span>&quot;cyan&quot;</span><span>,</span><span> </span><span>ifelse</span><span>(</span><span>rownames</span><span>(</span><span>goTerms_df</span><span>)</span><span> </span><span>%in%</span><span> </span><span>goChilds</span><span>,</span><span> </span><span>&quot;red&quot;</span><span>,</span><span> </span><span>&quot;skyblue2&quot;</span><span>))))))))))))</span><span>
</span><span>V</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>color</span><span> </span><span>&lt;-</span><span> </span><span>adjustcolor</span><span>(</span><span>goTerms_df</span><span>$</span><span>color</span><span>,</span><span> </span><span>alpha.f</span><span> </span><span>=</span><span> </span><span>0.8</span><span>)</span><span>
</span><span>V</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>label</span><span> </span><span>&lt;-</span><span> </span><span>goTerms</span><span>
</span><span>Ecolor</span><span> </span><span>&lt;-</span><span> </span><span>ifelse</span><span>(</span><span>E</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>type</span><span> </span><span>==</span><span> </span><span>&quot;is_a&quot;</span><span>,</span><span> </span><span>&quot;slategrey&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>E</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>type</span><span> </span><span>==</span><span> </span><span>&quot;part_of&quot;</span><span>,</span><span> </span><span>&quot;springgreen4&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>E</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>type</span><span> </span><span>==</span><span> </span><span>&quot;regulates&quot;</span><span>,</span><span> </span><span>&quot;tomato&quot;</span><span>,</span><span>
</span><span>ifelse</span><span>(</span><span>E</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>type</span><span> </span><span>==</span><span> </span><span>&quot;negatively_regulates&quot;</span><span>,</span><span> </span><span>&quot;orange&quot;</span><span>,</span><span> </span><span>&quot;greenyellow&quot;</span><span>))))</span><span>
</span><span>E</span><span>(</span><span>goGraph</span><span>)</span><span>$</span><span>color</span><span> </span><span>&lt;-</span><span> </span><span>Ecolor</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>plot</span><span>(</span><span>goGraph</span><span>,</span><span>
</span><span>vertex.label.color</span><span> </span><span>=</span><span> </span><span>&quot;black&quot;</span><span>,</span><span>
</span><span>vertex.label.cex</span><span> </span><span>=</span><span> </span><span>0.8</span><span>,</span><span>
</span><span>vertex.size</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span>
</span><span>margin</span><span> </span><span>=</span><span> </span><span>0</span><span>)</span><span>
</span><span>labels</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>&quot;C. elegans&quot;</span><span>,</span><span> </span><span>&quot;Chicken&quot;</span><span>,</span><span> </span><span>&quot;Chimpanzee&quot;</span><span>,</span><span> </span><span>&quot;Dog&quot;</span><span>,</span><span> </span><span>&quot;Fruitfly&quot;</span><span>,</span><span> </span><span>&quot;Human&quot;</span><span>,</span><span> </span><span>&quot;Mouse&quot;</span><span>,</span><span> </span><span>&quot;Pig&quot;</span><span>,</span><span> </span><span>&quot;Rat&quot;</span><span>,</span><span> </span><span>&quot;Zebrafish&quot;</span><span>,</span><span> </span><span>&quot;common&quot;</span><span>,</span><span> </span><span>&quot;other enriched GO&quot;</span><span>,</span><span> </span><span>&quot;parent&quot;</span><span>)</span><span>
</span><span>colors</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>&quot;green&quot;</span><span>,</span><span> </span><span>&quot;yellowgreen&quot;</span><span>,</span><span> </span><span>&quot;violetred&quot;</span><span>,</span><span> </span><span>&quot;turquoise&quot;</span><span>,</span><span> </span><span>&quot;violet&quot;</span><span>,</span><span> </span><span>&quot;thistle&quot;</span><span>,</span><span> </span><span>&quot;tan1&quot;</span><span>,</span><span> </span><span>&quot;steelblue&quot;</span><span>,</span><span> </span><span>&quot;orangered&quot;</span><span>,</span><span> </span><span>&quot;olivedrab&quot;</span><span>,</span><span> </span><span>&quot;cyan&quot;</span><span>,</span><span> </span><span>&quot;red&quot;</span><span>,</span><span> </span><span>&quot;skyblue2&quot;</span><span>)</span><span>
</span><span>legend</span><span>(</span><span>&quot;topleft&quot;</span><span>,</span><span> </span><span>labels</span><span>,</span><span> </span><span>pch</span><span> </span><span>=</span><span> </span><span>19</span><span>,</span><span>
</span><span>col</span><span> </span><span>=</span><span> </span><span>colors</span><span>,</span><span> </span><span>pt.cex</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>cex</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>bty</span><span> </span><span>=</span><span> </span><span>&quot;n&quot;</span><span>,</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span></code></pre>
</div>
<p>For the output network graph, see summary at the beginning of this post.</p>
<hr>
<p></p>
<div>
<pre><code><span>sessionInfo</span><span>()</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## R version 3.3.2 (2016-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] igraph_1.0.1          GO.db_3.4.0           tidyr_0.6.0          
##  [4] RamiGO_1.20.0         gsubfn_0.6-6          proto_1.0.0          
##  [7] rlist_0.4.6.1         wordcloud_2.5         RColorBrewer_1.1-2   
## [10] SnowballC_0.5.1       tm_0.6-2              NLP_0.1-9            
## [13] dplyr_0.5.0           clusterProfiler_3.2.9 DOSE_3.0.9           
## [16] ggplot2_2.2.1         org.Cf.eg.db_3.4.0    org.Mm.eg.db_3.4.0   
## [19] org.Dm.eg.db_3.4.0    org.Dr.eg.db_3.4.0    org.Gg.eg.db_3.4.0   
## [22] org.Hs.eg.db_3.4.0    org.Ss.eg.db_3.4.0    org.Pt.eg.db_3.4.0   
## [25] org.Ce.eg.db_3.4.0    org.Sc.sgd.db_3.4.0   org.Rn.eg.db_3.4.0   
## [28] AnnotationDbi_1.36.0  IRanges_2.8.1         S4Vectors_0.12.1     
## [31] Biobase_2.34.0        BiocGenerics_0.20.0   biomaRt_2.30.0       
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.8        png_0.1-7          assertthat_0.1    
##  [4] rprojroot_1.1      digest_0.6.11      slam_0.1-40       
##  [7] R6_2.2.0           plyr_1.8.4         backports_1.0.4   
## [10] RSQLite_1.1-1      evaluate_0.10      lazyeval_0.2.0    
## [13] data.table_1.10.0  qvalue_2.6.0       rmarkdown_1.3     
## [16] labeling_0.3       splines_3.3.2      BiocParallel_1.8.1
## [19] RCytoscape_1.24.1  stringr_1.1.0      RCurl_1.95-4.8    
## [22] munsell_0.4.3      fgsea_1.0.2        htmltools_0.3.5   
## [25] tcltk_3.3.2        tibble_1.2         gridExtra_2.2.1   
## [28] codetools_0.2-15   XML_3.98-1.5       bitops_1.0-6      
## [31] grid_3.3.2         gtable_0.2.0       DBI_0.5-1         
## [34] magrittr_1.5       scales_0.4.1       graph_1.52.0      
## [37] stringi_1.1.2      GOSemSim_2.0.3     reshape2_1.4.2    
## [40] DO.db_2.9          fastmatch_1.0-4    tools_3.3.2       
## [43] yaml_2.1.14        colorspace_1.3-2   memoise_1.0.0     
## [46] knitr_1.15.1       XMLRPC_0.3-0
</code></pre>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://shiring.github.io/genome/2017/01/05/homologous_genes_part3_post"> Shirin's playgRound</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/wXy4Bex-uGY"></a></div>