<!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>Perform Reductive Late Conservation Test — LateConservationTest • 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="Perform Reductive Late Conservation Test — LateConservationTest"><meta name="description" content="The Reductive Late Conservation Test aims to statistically evaluate the
existence of a monotonically decreasing phylotranscriptomic pattern based on TAI or TDI computations.
The corresponding p-value quantifies the probability that a given TAI or TDI pattern (or any phylotranscriptomics pattern)
does not follow an late conservation like pattern. A p-value &amp;lt; 0.05 indicates that the corresponding phylotranscriptomics pattern does
indeed follow an late conservation (high-high-low) shape."><meta property="og:description" content="The Reductive Late Conservation Test aims to statistically evaluate the
existence of a monotonically decreasing phylotranscriptomic pattern based on TAI or TDI computations.
The corresponding p-value quantifies the probability that a given TAI or TDI pattern (or any phylotranscriptomics pattern)
does not follow an late conservation like pattern. A p-value &amp;lt; 0.05 indicates that the corresponding phylotranscriptomics pattern does
indeed follow an late conservation (high-high-low) shape."><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>Perform Reductive Late Conservation Test</h1>
      <small class="dont-index">Source: <a href="https://github.com/drostlab/myTAI/blob/HEAD/R/LateConservationTest.R" class="external-link"><code>R/LateConservationTest.R</code></a></small>
      <div class="d-none name"><code>LateConservationTest.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>The <em>Reductive Late Conservation Test</em> aims to statistically evaluate the
existence of a monotonically decreasing phylotranscriptomic pattern based on <code><a href="TAI.html">TAI</a></code> or <code><a href="TDI.html">TDI</a></code> computations.
The corresponding p-value quantifies the probability that a given TAI or TDI pattern (or any phylotranscriptomics pattern)
does not follow an late conservation like pattern. A p-value &lt; 0.05 indicates that the corresponding phylotranscriptomics pattern does
indeed follow an late conservation (high-high-low) shape.</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">LateConservationTest</span><span class="op">(</span></span>
<span>  <span class="va">ExpressionSet</span>,</span>
<span>  modules <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  permutations <span class="op">=</span> <span class="fl">1000</span>,</span>
<span>  lillie.test <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  plotHistogram <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  runs <span class="op">=</span> <span class="fl">10</span>,</span>
<span>  parallel <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  gof.warning <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  custom.perm.matrix <span class="op">=</span> <span class="cn">NULL</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-modules">modules<a class="anchor" aria-label="anchor" href="#arg-modules"></a></dt>
<dd><p>a list storing three elements: early, mid, and late. Each element expects a numeric
vector specifying the developmental stages or experiments that correspond to each module.
For example, <code>module</code> = list(early = 1:2, mid = 3:5, late = 6:7) divides a dataset
storing seven developmental stages into 3 modules.</p></dd>


<dt id="arg-permutations">permutations<a class="anchor" aria-label="anchor" href="#arg-permutations"></a></dt>
<dd><p>a numeric value specifying the number of permutations to be performed for the <code>ReductiveHourglassTest</code>.</p></dd>


<dt id="arg-lillie-test">lillie.test<a class="anchor" aria-label="anchor" href="#arg-lillie-test"></a></dt>
<dd><p>a boolean value specifying whether the Lilliefors Kolmogorov-Smirnov Test shall be performed to quantify the goodness of fit.</p></dd>


<dt id="arg-plothistogram">plotHistogram<a class="anchor" aria-label="anchor" href="#arg-plothistogram"></a></dt>
<dd><p>a boolean value specifying whether a <em>Lillifor's Kolmogorov-Smirnov-Test</em>
shall be performed to test the goodness of fit of the approximated distribution, as well as additional plots quantifying the significance
of the observed phylotranscriptomic pattern.</p></dd>


<dt id="arg-runs">runs<a class="anchor" aria-label="anchor" href="#arg-runs"></a></dt>
<dd><p>specify the number of runs to be performed for goodness of fit computations, in case <code>plotHistogram</code> = <code>TRUE</code>.
In most cases <code>runs</code> = 100 is a reasonable choice. Default is <code>runs</code> = 10 (because it takes less computation time for demonstration purposes).</p></dd>


<dt id="arg-parallel">parallel<a class="anchor" aria-label="anchor" href="#arg-parallel"></a></dt>
<dd><p>performing <code>runs</code> in parallel (takes all cores of your multicore machine).</p></dd>


<dt id="arg-gof-warning">gof.warning<a class="anchor" aria-label="anchor" href="#arg-gof-warning"></a></dt>
<dd><p>a logical value indicating whether non significant goodness of fit results should be printed as warning. Default is <code>gof.warning = FALSE</code>.</p></dd>


<dt id="arg-custom-perm-matrix">custom.perm.matrix<a class="anchor" aria-label="anchor" href="#arg-custom-perm-matrix"></a></dt>
<dd><p>a custom <code><a href="bootMatrix.html">bootMatrix</a></code> (permutation matrix) to perform the underlying test statistic. Default is <code>custom.perm.matrix = NULL</code>.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    <p>a list object containing the list elements:</p>
<p><code>p.value</code> : the p-value quantifying the statistical significance (low-high-high pattern) of the given phylotranscriptomics pattern.</p>
<p><code>std.dev</code> : the standard deviation of the N sampled phylotranscriptomics patterns for each developmental stage S.</p>
<p><code>lillie.test</code> : a boolean value specifying whether the <em>Lillifors KS-Test</em> returned a p-value &gt; 0.05,
which indicates that fitting the permuted scores with a normal distribution seems plausible.</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>The <em>reductive late conservation test</em> is a permutation test based on the following test statistic.</p>
<p>(1) A set of developmental stages is partitioned into three modules - early, mid, and late - based on prior biological knowledge.</p>
<p>(2) The mean <code><a href="TAI.html">TAI</a></code> or <code><a href="TDI.html">TDI</a></code> value for each of the three modules T_early, T_mid, and T_late are computed.</p>
<p>(3) The two differences D1 = T_early - T_late and D2 = T_mid - T_late are calculated.</p>
<p>(4) The minimum D_min of D1 and D2 is computed as final test statistic of the reductive hourglass test.</p>

<p>In order to determine the statistical significance of an observed minimum difference D_min
the following permutation test was performed. Based on the <code><a href="bootMatrix.html">bootMatrix</a></code> D_min
is calculated from each of the permuted <code><a href="TAI.html">TAI</a></code> or <code><a href="TDI.html">TDI</a></code> profiles,
approximated by a Gaussian distribution with method of moments estimated parameters returned by <code><a href="https://lbbe-software.github.io/fitdistrplus/reference/fitdist.html" class="external-link">fitdist</a></code>,
and the corresponding p-value is computed by <code><a href="https://rdrr.io/r/stats/Normal.html" class="external-link">pnorm</a></code> given the estimated parameters of the Gaussian distribution.
The <em>goodness of fit</em> for the random vector <em>D_min</em> is statistically quantified by an Lilliefors (Kolmogorov-Smirnov) test
for normality.</p>

<p>In case the parameter <em>plotHistogram = TRUE</em>, a multi-plot is generated showing:</p>
<p>(1) A Cullen and Frey skewness-kurtosis plot generated by <code><a href="https://lbbe-software.github.io/fitdistrplus/reference/descdist.html" class="external-link">descdist</a></code>.
This plot illustrates which distributions seem plausible to fit the resulting permutation vector D_min.
In the case of the <em>reductive late conservation test</em> a normal distribution seemed plausible.</p>
<p>(2) A histogram of D_min combined with the density plot is plotted. D_min is then fitted by a normal distribution.
The corresponding parameters are estimated by <em>moment matching estimation</em> using the <code><a href="https://lbbe-software.github.io/fitdistrplus/reference/fitdist.html" class="external-link">fitdist</a></code> function.</p>
<p>(3) A plot showing the p-values for N independent runs to verify that a specific p-value is biased by a specific permutation order.</p>
<p>(4) A barplot showing the number of cases in which the underlying goodness of fit (returned by Lilliefors (Kolmogorov-Smirnov) test
for normality) has shown to be significant (<code>TRUE</code>) or not significant (<code>FALSE</code>).
This allows to quantify the permutation bias and their implications on the goodness of fit.</p>
    </div>
    <div class="section level2">
    <h2 id="references">References<a class="anchor" aria-label="anchor" href="#references"></a></h2>
    <p>Drost HG et al. (2015) Mol Biol Evol. 32 (5): 1221-1231 doi:10.1093/molbev/msv012</p>
<p>Quint M et al. (2012). <em>A transcriptomic hourglass in plant embryogenesis</em>. Nature (490): 98-101.</p>
<p>Piasecka B, Lichocki P, Moretti S, et al. (2013) <em>The hourglass and the early conservation models co-existing
patterns of developmental constraints in vertebrates</em>. PLoS Genet. 9(4): e1003476.</p>
    </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="lcScore.html">lcScore</a></code>, <code><a href="bootMatrix.html">bootMatrix</a></code>, <code><a href="FlatLineTest.html">FlatLineTest</a></code>,<code><a href="ReductiveHourglassTest.html">ReductiveHourglassTest</a></code>, <code><a href="ReverseHourglassTest.html">ReverseHourglassTest</a></code>, <code><a href="PlotSignature.html">PlotSignature</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 and Jaruwatana Sodai Lotharukpong</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="co"># perform the late conservation test for a PhyloExpressionSet</span></span></span>
<span class="r-in"><span><span class="co"># here the prior biological knowledge is that stages 1-2 correspond to module 1 = early,</span></span></span>
<span class="r-in"><span><span class="co"># stages 3-5 to module 2 = mid (phylotypic module), and stages 6-7 correspond to</span></span></span>
<span class="r-in"><span><span class="co"># module 3 = late</span></span></span>
<span class="r-in"><span><span class="fu">LateConservationTest</span><span class="op">(</span><span class="va">PhyloExpressionSetExample</span>,</span></span>
<span class="r-in"><span>                       modules <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>early <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">2</span>, mid <span class="op">=</span> <span class="fl">3</span><span class="op">:</span><span class="fl">5</span>, late <span class="op">=</span> <span class="fl">6</span><span class="op">:</span><span class="fl">7</span><span class="op">)</span>, </span></span>
<span class="r-in"><span>                       permutations <span class="op">=</span> <span class="fl">1000</span><span class="op">)</span></span></span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> The phylotranscriptomic pattern may not follow a late conservation pattern (high-mid-low or high-high-low).</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [ Number of Eigen threads that are employed on your machine: 12 ]</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [ Computing age assignment permutations for test statistic ... ]</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 
[=========================================] 100%   </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [ Computing variances of permuted transcriptome signatures ... ]</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $p.value</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] 0.9999991</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $std.dev</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] 0.05343829 0.05299432 0.05104522 0.04950552 0.04919799 0.05051301 0.05572345</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $lillie.test</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] NA</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># use your own permutation matrix based on which p-values (LateConservationTest)</span></span></span>
<span class="r-in"><span><span class="co"># shall be computed</span></span></span>
<span class="r-in"><span><span class="va">custom_perm_matrix</span> <span class="op">&lt;-</span> <span class="fu"><a href="bootMatrix.html">bootMatrix</a></span><span class="op">(</span><span class="va">PhyloExpressionSetExample</span>,<span class="fl">100</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [ Number of Eigen threads that are employed on your machine: 12 ]</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [ Computing age assignment permutations for test statistic ... ]</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 
[=========================================] 100%   </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [ Computing variances of permuted transcriptome signatures ... ]</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu">LateConservationTest</span><span class="op">(</span><span class="va">PhyloExpressionSetExample</span>,</span></span>
<span class="r-in"><span>                       modules <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>early <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">2</span>, mid <span class="op">=</span> <span class="fl">3</span><span class="op">:</span><span class="fl">5</span>, late <span class="op">=</span> <span class="fl">6</span><span class="op">:</span><span class="fl">7</span><span class="op">)</span>, </span></span>
<span class="r-in"><span>                       custom.perm.matrix <span class="op">=</span> <span class="va">custom_perm_matrix</span><span class="op">)</span></span></span>
<span class="r-msg co"><span class="r-pr">#&gt;</span> The phylotranscriptomic pattern may not follow a late conservation pattern (high-mid-low or high-high-low).</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $p.value</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] 0.9999949</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $std.dev</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>     Zygote   Quadrant   Globular      Heart    Torpedo       Bent     Mature </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 0.05747708 0.05585285 0.05300770 0.05001848 0.04777103 0.04897164 0.05483565 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $lillie.test</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> [1] NA</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </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>

