<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/showcategory-parameter-for-visualizing-comparecluster-output/"></div></div><div><a data-url="https://www.r-bloggers.com/showcategory-parameter-for-visualizing-comparecluster-output/" data-counturl="https://www.r-bloggers.com/showcategory-parameter-for-visualizing-comparecluster-output/" data-count="horizontal" data-text="showCategory parameter for visualizing compareCluster output" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://guangchuangyu.github.io/2016/11/showcategory-parameter-for-visualizing-comparecluster-output"> R on Guangchuang YU</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<blockquote>
<p>I am using dotplot() to visualize results from enrichGO(), enrichDO(), enricher() and compareCluster() in clusterProfiler R package. When specifying showCategory, I get the right number of categories except with the results of compareCluser().</p>
<p>In my case, I use compareCluster() on a list of 3 elements:</p>
<pre><code>str(ClusterList)
List of 3
 $ All : chr [1:1450] &quot;89886&quot; &quot;29923&quot; &quot;100132891&quot; &quot;101410536&quot; ...
 $ g1  : chr [1:858] &quot;89886&quot; &quot;29923&quot; &quot;100132891&quot; &quot;101410536&quot; ...
 $ g2: chr [1:592] &quot;5325&quot; &quot;170691&quot; &quot;29953&quot; &quot;283392&quot; ...
CompareGO_BP=compareCluster(ClusterList, fun=&quot;enrichGO&quot;, pvalueCutoff=0.01, pAdjustMethod=&quot;BH&quot;, OrgDb=org.Hs.eg.db,ont=&quot;BP&quot;,readable=T)

dotplot(CompareGO_BP, showCategory=10, title=&quot;GO - Biological Process&quot;)
</code></pre>
<p>I ask for 10 categories, but I get 15 categories in All, 8 categories in g1 and 12 categories in g2. None of the categories, neither the sum of the categories are 10…</p>
<p>Is the option showCategory working in the case of comparison? Am I missing something here?</p>
<p>And which categories precisely will it plot? the most significant whatever my 3 cases or the most significant of each case?</p>
</blockquote>
<p>The question was <a target="_blank" rel="nofollow" href="https://support.bioconductor.org/p/88965/">posted</a> in Bioconductor support site. It seems quite confusing and I think I need to write a post to clarify it.</p>
<p>In this case, we expect to get <code>&lt;= 10 of most significant categories</code> for each <code>Cluster</code> as the user specify <code>showCategory=10</code>. This is exactly the way of <code>dotplot</code> and <code>barplot</code> methods do for <code>compareClusterResult</code>. <code>8</code> categories for <code>g1</code> is obvious that there are only <code>8</code> enriched terms found for <code>g1</code>.</p>
<p>But why there are <code>15</code> for <code>All</code> and <code>12</code> for <code>g2</code>?</p>
<p><code>dotplot</code> and <code>barplot</code> methods implemented in <code>clusterProfiler</code> try to make the comparison among clusters more informative and reasonable. After extracting e.g. 10 categories for each cluster, <code>clusterProfiler</code> try to collect overlap of these categories among clusters.</p>
<p>For example, <code>term A</code> is enriched in all the clusters (<code>All</code>, <code>g1</code> and <code>g2</code>) and is in the 10 most significant categories for <code>g1</code> but not <code>All</code> and <code>g2</code>. <code>clusterProfiler</code> try to capture these information and include <code>term A</code> in <code>All</code> and <code>g2</code> clusters and making the comparison in <code>dotplot</code>/<code>barplot</code> more reasonable.</p>
<p>If users want to ignore these information, they can use <code>dotplot(..., includeAll=FALSE)</code>, which is actually not recommended.</p>
<p>See the difference to the following example:</p>
<pre><code>library(clusterProfiler)
data(gcSample)
x=compareCluster(gcSample, fun='enrichDO')
dotplot(x, showCategory=5, includeAll=FALSE)
dotplot(x, showCategory=5)
</code></pre>
<p><img alt="" src="https://i2.wp.com/guangchuangyu.github.io/blog_images/Bioconductor/clusterProfiler/Screen%20Shot%202016-11-03%20at%2010.56.46%20AM.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>In the first figure, it seems that all these clusters are very different, with no overlapping terms enriched. This is not true as demonstrated in the second figure.</p>
<h2>Citation</h2>
<p><strong><em>Yu G</em></strong>, Wang L, Han Y and He Q<sup>*</sup>. <a target="_blank" rel="nofollow" href="http://online.liebertpub.com/doi/abs/10.1089/omi.2011.0118">clusterProfiler: an R package for comparing biological themes among gene clusters</a>. <strong><em>OMICS: A Journal of Integrative Biology</em></strong>. 2012, 16(5):284-287.</p>
<p>
<div data-badge-popover="right" data-altmetric-id="681089" data-badge-type="donut"></div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/showcategory-parameter-for-visualizing-comparecluster-output/"></div></div><div><a data-url="https://www.r-bloggers.com/showcategory-parameter-for-visualizing-comparecluster-output/" data-counturl="https://www.r-bloggers.com/showcategory-parameter-for-visualizing-comparecluster-output/" data-count="vertical" data-text="showCategory parameter for visualizing compareCluster output" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://guangchuangyu.github.io/2016/11/showcategory-parameter-for-visualizing-comparecluster-output"> R on Guangchuang YU</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/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=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/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/ekZ4Ffgk_T4"></a></div>