<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Phylostratum or Divergence Stratum Enrichment of a given Gene Set based on Fisher's Test — EnrichmentTest • myTAI</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Phylostratum or Divergence Stratum Enrichment of a given Gene Set based on Fisher's Test — EnrichmentTest"><meta name="description" content="This function computes the significance of enriched (over or underrepresented) Phylostrata or Divergence Strata within an input test.set based on the fisher.test. Please concult PlotEnrichment for details."><meta property="og:description" content="This function computes the significance of enriched (over or underrepresented) Phylostrata or Divergence Strata within an input test.set based on the fisher.test. Please concult PlotEnrichment for details."><meta property="og:image" content="https://drostlab.github.io/myTAI/logo.png"></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>


    <nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">

    <a class="navbar-brand me-2" href="../index.html">myTAI</a>

    <small class="nav-text text-muted me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="">2.0.0</small>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item"><a class="nav-link" href="../reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
  <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
  <ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><a class="dropdown-item" href="../articles/Advanced.html">Advanced Phylotranscriptomics Analyses</a></li>
    <li><a class="dropdown-item" href="../articles/Enrichment.html">Enrichment Analyses</a></li>
    <li><a class="dropdown-item" href="../articles/Expression.html">Gene Expression Analysis with `myTAI`</a></li>
    <li><a class="dropdown-item" href="../articles/Intermediate.html">Intermediate Phylotranscriptomics Analyses</a></li>
    <li><a class="dropdown-item" href="../articles/Introduction.html">Introduction to the myTAI package</a></li>
    <li><a class="dropdown-item" href="../articles/Phylostratigraphy.html">Discussing Genomic Phylostratigraphy</a></li>
  </ul></li>
<li class="nav-item"><a class="nav-link" href="../news/index.html">Changelog</a></li>
      </ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
 <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="../search.json"></form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/drostlab/myTAI/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
      </ul></div>


  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.png" class="logo" alt=""><h1>Phylostratum or Divergence Stratum Enrichment of a given Gene Set based on Fisher's Test</h1>
      <small class="dont-index">Source: <a href="https://github.com/drostlab/myTAI/blob/HEAD/R/EnrichmentTest.R" class="external-link"><code>R/EnrichmentTest.R</code></a></small>
      <div class="d-none name"><code>EnrichmentTest.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>This function computes the significance of enriched (over or underrepresented) Phylostrata or Divergence Strata within an input <code>test.set</code> based on the <code><a href="https://rdrr.io/r/stats/fisher.test.html" class="external-link">fisher.test</a></code>. Please concult <code><a href="PlotEnrichment.html">PlotEnrichment</a></code> for details.</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">EnrichmentTest</span><span class="op">(</span></span>
<span>  <span class="va">ExpressionSet</span>,</span>
<span>  <span class="va">test.set</span>,</span>
<span>  use.only.map <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  measure <span class="op">=</span> <span class="st">"log-foldchange"</span>,</span>
<span>  complete.bg <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  epsilon <span class="op">=</span> <span class="fl">1e-05</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>


<dl><dt id="arg-expressionset">ExpressionSet<a class="anchor" aria-label="anchor" href="#arg-expressionset"></a></dt>
<dd><p>a standard PhyloExpressionSet or DivergenceExpressionSet object.</p></dd>


<dt id="arg-test-set">test.set<a class="anchor" aria-label="anchor" href="#arg-test-set"></a></dt>
<dd><p>a character vector storing the gene ids for which PS/DS enrichment analyses should be performed.</p></dd>


<dt id="arg-use-only-map">use.only.map<a class="anchor" aria-label="anchor" href="#arg-use-only-map"></a></dt>
<dd><p>a logical value indicating whether instead of a standard <code>ExpressionSet</code> only a <code>Phylostratigraphic Map</code> or <code>Divergene Map</code> is passed to this function.</p></dd>


<dt id="arg-measure">measure<a class="anchor" aria-label="anchor" href="#arg-measure"></a></dt>
<dd><p>a character string specifying the measure that should be used to quantify over and under representation of PS/DS. Measures can either be <code>measure = "foldchange"</code> (odds) or <code>measure = "log-foldchange"</code> (log-odds).</p></dd>


<dt id="arg-complete-bg">complete.bg<a class="anchor" aria-label="anchor" href="#arg-complete-bg"></a></dt>
<dd><p>a logical value indicating whether the entire background set of the input ExpressionSet should be considered when performing Fisher's exact test (<code>complete.bg = TRUE</code>) or whether genes that are stored in test.set should be excluded from the background set before performing Fisher's exact test (<code>complete.bg = FALSE</code>).</p></dd>


<dt id="arg-epsilon">epsilon<a class="anchor" aria-label="anchor" href="#arg-epsilon"></a></dt>
<dd><p>a small value to shift values by epsilon to avoid log(0) computations.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p><code><a href="PlotEnrichment.html">PlotEnrichment</a></code>, <code><a href="https://rdrr.io/r/stats/fisher.test.html" class="external-link">fisher.test</a></code></p></div>
    </div>
    <div class="section level2">
    <h2 id="author">Author<a class="anchor" aria-label="anchor" href="#author"></a></h2>
    <p>Hajk-Georg Drost</p>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/utils/data.html" class="external-link">data</a></span><span class="op">(</span><span class="va">PhyloExpressionSetExample</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/Random.html" class="external-link">set.seed</a></span><span class="op">(</span><span class="fl">123</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="va">test_set</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/sample.html" class="external-link">sample</a></span><span class="op">(</span><span class="va">PhyloExpressionSetExample</span><span class="op">[</span> , <span class="fl">2</span><span class="op">]</span>,<span class="fl">1000</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">E.Result</span> <span class="op">&lt;-</span> <span class="fu">EnrichmentTest</span><span class="op">(</span>ExpressionSet <span class="op">=</span> <span class="va">PhyloExpressionSetExample</span>,</span></span>
<span class="r-in"><span>                           test.set      <span class="op">=</span> <span class="va">test_set</span> ,</span></span>
<span class="r-in"><span>                           measure       <span class="op">=</span> <span class="st">"log-foldchange"</span><span class="op">)</span></span></span>
<span class="r-in"><span>                           </span></span>
<span class="r-in"><span><span class="co"># get the log-fold change table</span></span></span>
<span class="r-in"><span><span class="va">E.Result</span><span class="op">$</span><span class="va">enrichment.matrix</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>           BG_Set     Test_Set</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1  -0.0004337003  0.010481817</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   0.0017181154 -0.042321022</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3   0.0056691770 -0.144837926</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 4  -0.0021020073  0.050078271</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 5   0.0044161681 -0.111500196</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 6  -0.0113320413  0.250731629</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 7   0.0167409104 -0.480258084</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8  -0.0004004521  0.009681065</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 9   0.0166840812 -0.478313742</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 10  0.0021668586 -0.053590619</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 11  0.0114655330 -0.310378255</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 12 -0.0039843952  0.093435996</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># get P-values for the enrichment significance for each Phylostratum</span></span></span>
<span class="r-in"><span><span class="va">E.Result</span><span class="op">$</span><span class="va">p.values</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>         1         2         3         4         5         6         7         8 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 0.8665888 0.6054816 0.6418368 0.6730864 0.7200825 0.1238752 0.4403599 0.8772462 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>         9        10        11        12 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 0.3351155 0.9329851 0.7095475 0.5673222 </span>
<span class="r-in"><span></span></span>
</code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p>Developed by Hajk-Georg Drost, Jaruwatana Sodai Lotharukpong, Nikola Kalábová, Kristian K Ullrich.</p>
</div>

<div class="pkgdown-footer-right">
  <p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.0.</p>
</div>

    </footer></div>





  </body></html>

