<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 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></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>Yu G</strong>, Wang L, Han Y and He Q*. <a 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>OMICS: A Journal of Integrative Biology</strong>. 2012, 16(5):284-287.</p>
<p></p><div></div>