<!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.0">
<title>Performing Divergence Stratigraphy • orthologr</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">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><meta property="og:title" content="Performing Divergence Stratigraphy">
<meta property="og:description" content="orthologr">
<meta property="og:image" content="/logo.png">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
    

    <div class="container template-article">
      <header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">orthologr</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.4.2</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li>
      <a href="../articles/Install.html">Installing Prerequisite Tools</a>
    </li>
    <li>
      <a href="../articles/blast.html">BLAST searches using orthologr</a>
    </li>
    <li>
      <a href="../articles/dNdS_estimation.html">Orthology inference dNdS estimation of orthologous genes using orthologr</a>
    </li>
    <li>
      <a href="../articles/divergence_stratigraphy.html">Performing Divergence Stratigraphy</a>
    </li>
    <li>
      <a href="../articles/orthology_inference.html">Orthology Inference using orthologr</a>
    </li>
    <li>
      <a href="../articles/sequence_alignments.html">Sequence alignments with orthologr</a>
    </li>
  </ul>
</li>
<li>
  <a href="../news/index.html">Changelog</a>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right">
<li>
  <a href="https://github.com/drostlab/orthologr/" class="external-link">
    <span class="fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
</div>
<!--/.nav-collapse -->
  </div>
<!--/.container -->
</div>
<!--/.navbar -->

      

      </header><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>Performing Divergence Stratigraphy</h1>
            
            <h4 data-toc-skip class="date">2023-10-10</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/drostlab/orthologr/blob/HEAD/vignettes/divergence_stratigraphy.Rmd" class="external-link"><code>vignettes/divergence_stratigraphy.Rmd</code></a></small>
      <div class="hidden name"><code>divergence_stratigraphy.Rmd</code></div>

    </div>

    
    
<p>The <code>orthologr</code> package allows users to perform
<strong>Divergence Stratigraphy</strong> for any query and subject
organisms of interest.</p>
<p><strong>Divergence Stratigraphy</strong> is the process of
quantifying the selection pressure (in terms of protein evolutionary
rate) acting on orthologous genes between closely related species. The
resulting sequence divergence map (short divergence map), stores the
divergence stratum in the first column and the <code>query_id</code> of
inferred orthologous genes in the second column ( Quint et al., 2012
<em>Nature</em>; <a href="http://mbe.oxfordjournals.org/content/32/5/1221.full" class="external-link">Drost et
al., 2015 <em>Mol. Biol. Evol.</em></a>; <a href="http://mbe.oxfordjournals.org/content/early/2016/02/23/molbev.msw039.abstract" class="external-link">Drost
et al., 2016 <em>Mol. Biol. Evol.</em></a>; <a href="https://github.com/HajkD/myTAI" class="external-link">Introduction to myTAI</a> ). <a href="https://github.com/HajkD/myTAI/issues/5" class="external-link">Here</a> you can also
find a short example and discussion about the usefulness of
<code>Divergence Strata</code>.</p>
<p>The following Algorithm implemented in
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> defines <strong>Divergence
Stratigraphy</strong> as method (see <a href="http://mbe.oxfordjournals.org/content/32/5/1221.full" class="external-link">Drost et
al., 2015</a>):</p>
<ol style="list-style-type: decimal">
<li><p>Orthology Inference using BLAST best reciprocal hit (“RBH”) based
on blastp</p></li>
<li><p>Pairwise global amino acid alignments of orthologous genes using
the <a href="http://www.sciencedirect.com/science/article/pii/0022283670900574" class="external-link">Needleman-Wunsch
algorithm</a></p></li>
<li><p>Codon alignments of orthologous genes using <a href="http://www.bork.embl.de/pal2nal/" class="external-link">PAL2NAL</a></p></li>
<li><p>dNdS estimation using <a href="http://link.springer.com/article/10.1007/BF00173196" class="external-link">Comeron’s
method (1995)</a></p></li>
<li><p>Categorize estimated dNdS values into
<code>divergence strata</code> (= deciles of all dNdS values)</p></li>
</ol>
<blockquote>
<p>In brief, a Divergence Stratum is defined as a decile (= 10%
quantile) retrieved from all Ka/Ks (or dN/dS) values of all orthologs
returned by the pairwise genome comparison.</p>
</blockquote>
<p>In other words, imagine having 10000 orthologous genes and their
corresponding Ka/Ks values after performing a pairwise genome comparison
using the <code><a href="../reference/dNdS.html">dNdS()</a></code> function. Now, these 10000 Ka/Ks values
follow a distribution between 0 and +Inf, where Ka/Ks &lt; 1 reflects
purifying selection, Ka/Ks = 1 reflects neutral evolution, and Ka/Ks
&gt; 1 reflects positive selection (in reality usually the largest Ka/Ks
values I have seen are e.g. 100). Next, you bin these 10000 Ka/Ks values
according to their 10% quantile (= decile), meaning that the lowest 10%
of Ka/Ks values are in decile one (= Divergence Stratum 1), the lowest
Ka/Ks values between the 11%-20% quantile are in decile two (=
Divergence Stratum 2), …, and the largest Ka/Ks values between the
91-100% quantile are in decile 10 (= Divergence Stratum 10) (This is
what the <code><a href="../reference/divergence_map.html">divergence_map()</a></code> function does). This way, each
Divergence Stratum has (almost) the same number of genes.</p>
<p>In <code>orthologr</code> the <a href="http://www.sciencedirect.com/science/article/pii/0022283670900574" class="external-link">Needleman-Wunsch
algorithm</a>, <a href="http://www.bork.embl.de/pal2nal/" class="external-link">PAL2NAL</a>
and <a href="http://link.springer.com/article/10.1007/BF00173196" class="external-link">Comeron’s
method (1995)</a> are already included in the <code>orthologr</code>
package and do not have to be installed separately. Nevertheless, users
need to make sure <strong>they have BLAST installed on their machine
before using the
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code>function</strong>.</p>
<p><strong>Note</strong>: The following examples assume that the
<strong>BLAST</strong> program is installed and stored in the default
execution path <code>usr/local/bin</code>. In case users do not have
<strong>BLAST</strong> installed yet or the following command in R
produces a different output, please consult the <a href="https://github.com/HajkD/orthologr/blob/master/vignettes/Install.Rmd#orthology-inference-tools" class="external-link">Installation
Vignette</a> to corretly set up the <strong>BLAST</strong> program to
perform <strong>Divergence Stratigraphy</strong>.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/system.html" class="external-link">system</a></span><span class="op">(</span><span class="st">"blastp -version"</span><span class="op">)</span></span></code></pre></div>
<pre><code>blastp: 2.2.30+
Package: blast 2.2.30, build Oct 27 2014 17:10:51</code></pre>
<div class="section level2">
<h2 id="divergence-map-computations">Divergence Map Computations<a class="anchor" aria-label="anchor" href="#divergence-map-computations"></a>
</h2>
<p>In <a href="http://mbe.oxfordjournals.org/content/32/5/1221.full" class="external-link">Drost et
al., 2015 <em>Mol. Biol. Evol.</em></a> we define a
<code>Divergence Map</code> as table storing the degree of selection
pressure (= <code>divergence strata</code>) for each protein coding gene
of a given query organism. In this case selection pressure was
quantified by dNdS estimation (ratio of synonymous versus non-synonymous
<code>codon -&gt; amino acid</code> sequence substitution rates). The
resulting dNdS values for all protein coding genes of the query organism
are then categorized into deciles (10%-quantiles) allowing users to
compare the results obtained from <code>Phylostratigraphy</code> with
results obtained form <code>Divergence Stratigraphy</code>.</p>
<p>To perform <strong>Divergence Stratigraphy</strong> using
<code>orthologr</code> users need to retrieve the following input
files:</p>
<ul>
<li>a CDS file covering all protein coding genes of the query organism
of interest</li>
<li>a CDS file covering all protein coding genes of the subject organism
of interest</li>
</ul>
<div class="section level3">
<h3 id="sequence-data-retrieval">Sequence Data Retrieval<a class="anchor" aria-label="anchor" href="#sequence-data-retrieval"></a>
</h3>
<p>In the following example, we will use <em>Arabidopsis thaliana</em>
as query organism and <em>Arabidopsis lyrata</em> as subject
organism.</p>
<p>First, we need to download the CDS sequences for all protein coding
genes of <em>A. thaliana</em> and <em>A. lyrata</em>.</p>
<div class="section level4">
<h4 id="option-1">Option 1:<a class="anchor" aria-label="anchor" href="#option-1"></a>
</h4>
<p>The CDS retrieval can be done using a <code>Terminal</code> or by
manual downloading the files</p>
<ul>
<li><code>Arabidopsis_thaliana.TAIR10.23.cds.all.fa.gz</code></li>
<li><code>Arabidopsis_lyrata.v.1.0.23.cds.all.fa.gz</code></li>
</ul>
<pre class="shell"><code>
# download CDS file of A. thaliana
curl ftp://ftp.ensemblgenomes.org/pub/plants/release-23/fasta/arabidopsis_thaliana/cds/Arabidopsis_thaliana.TAIR10.23.cds.all.fa.gz -o Arabidopsis_thaliana.TAIR10.23.cds.all.fa.gz

# unzip the fasta file
gunzip -d Arabidopsis_thaliana.TAIR10.23.cds.all.fa.gz

# download CDS file of A. lyrata

curl ftp://ftp.ensemblgenomes.org/pub/plants/release-23/fasta/arabidopsis_lyrata/cds/Arabidopsis_lyrata.v.1.0.23.cds.all.fa.gz -o Arabidopsis_lyrata.v.1.0.23.cds.all.fa.gz

# unzip the fasta file
gunzip -d Arabidopsis_lyrata.v.1.0.23.cds.all.fa.gz
</code></pre>
<p>When the download is finished you need to unzip the files.</p>
</div>
<div class="section level4">
<h4 id="option-2">Option 2:<a class="anchor" aria-label="anchor" href="#option-2"></a>
</h4>
<p>We implemented the <a href="https://github.com/HajkD/biomartr" class="external-link">biomartr</a> package to
automate the process of performing biological data retrieval. The <a href="https://github.com/HajkD/biomartr/blob/master/vignettes/Sequence_Retrieval.Rmd" class="external-link">Sequence
Retrieval Vignette</a> stored in <code>biomartr</code> provides detailed
use cases for the automation of biological sequence retrieval.</p>
<p><strong>Note</strong>: Users need to make sure they have <a href="https://github.com/HajkD/biomartr#fast-installation-guide" class="external-link">biomartr</a>
installed before running any <code>biomartr</code> functions.</p>
</div>
</div>
<div class="section level3">
<h3 id="computation-time">Computation Time<a class="anchor" aria-label="anchor" href="#computation-time"></a>
</h3>
<p><strong>Please note that</strong> performing <strong>Divergence
Stratigraphy</strong> with two large genomes can take (even on a
multicore machine) some time -&gt; <strong>up to several hours</strong>.
On a 4 core machine with 3.4 GHz i7 processors the computation time of
generating a divergence map between <em>A. thaliana</em> and <em>A.
lyrata</em> was <strong>2.5-3 hours</strong>.</p>
<p>The <code>comp_cores</code> argument implemented in the
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> function allows users to specify
the number of cores they would like to use on their machine. The default
value is <code>comp_cores = 1</code> which might take
<strong>10-12h</strong> to execute. So users need to make sure that they
use all cores available on their machine to speed up the computation
time.</p>
</div>
</div>
<div class="section level2">
<h2 id="running-divergence_stratigraphy">Running <code>divergence_stratigraphy()</code><a class="anchor" aria-label="anchor" href="#running-divergence_stratigraphy"></a>
</h2>
<p>As mentioned earlier the <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code>
function is the main function to perform the <strong>Divergence
Stratigraphy</strong> algorithm.</p>
<p>In <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> the <code>query_file</code>
and <code>subject_file</code> arguments take an character string storing
the path to the corresponding <strong>fasta</strong> files containing
the CDS sequences of these organisms. Here the previously downloaded CDS
sequence files of <em>A. thaliana</em> (= <code>query_file</code>) and
<em>A. lyrata</em> (= <code>subject_file</code>) need to be specified.
The <code>eval</code> is set to <code>1E-5</code> (default ; see Quint
et al., 2012 <em>Nature</em>) and <code>BLAST best reciprocal hit</code>
is used for orthology inference (see <a href="http://mbe.oxfordjournals.org/content/32/5/1221.full" class="external-link">Drost et
al., 2015</a>). In case `<code>orthologr</code> is running on a
multicore machine, users can set the <code>comp_cores</code> argument to
any number of cores supported by their machine. The
<code>clean_folders</code> argument indicates whether or not the
internal folder structure should be deleted (cleaned) after processing
is finished. In this case all output files generated by
<code>divergence_stratigraphy</code> (stored in <code><a href="https://rdrr.io/r/base/tempfile.html" class="external-link">tempdir()</a></code>)
will be removed after the <code>Divergence Map</code> was returned. The
<code>quiet</code> argument indicates whether or not a successful
interface call should be printed out to the console
(<code>quiet = FALSE</code>) or not (<code>quiet = TRUE</code>).</p>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/drostlab/orthologr" class="external-link">orthologr</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># compute the divergence map of A. thaliana</span></span>
<span><span class="va">Athaliana_DM</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>                         query_file      <span class="op">=</span> <span class="st">"path/to/Arabidopsis_thaliana.TAIR10.23.cds.all.fa"</span>,</span>
<span>                         subject_file    <span class="op">=</span> <span class="st">"path/to/Arabidopsis_lyrata.v.1.0.23.cds.all.fa"</span>,</span>
<span>                         eval            <span class="op">=</span> <span class="st">"1E-5"</span>, </span>
<span>                         ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>,</span>
<span>                         comp_cores      <span class="op">=</span> <span class="fl">1</span>, </span>
<span>                         quiet           <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>                         clean_folders   <span class="op">=</span> <span class="cn">TRUE</span> <span class="op">)</span></span></code></pre></div>
<p>Before running <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> with two
complete genomes, users can first run a test <strong>Divergence
Stratigraphy</strong> with 20 example genes that are stored in the
<code>orthologr</code> package:</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/drostlab/orthologr" class="external-link">orthologr</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># performing standard divergence stratigraphy</span></span>
<span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>, </span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>, </span>
<span>      dnds.threshold  <span class="op">=</span> <span class="fl">2</span>,</span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>, </span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code>
   divergence_strata    query_id
1                 10 AT1G01010.1
2                  9 AT1G01020.1
3                  5 AT1G01030.1
4                  4 AT1G01040.1
5                  1 AT1G01050.1
6                  9 AT1G01060.3
7                  6 AT1G01070.1
8                  8 AT1G01080.1
9                  2 AT1G01090.1
10                 7 AT1G01110.2
11                 2 AT1G01120.1
12                 3 AT1G01140.3
13                10 AT1G01150.1
14                 8 AT1G01160.1
15                 1 AT1G01170.2
16                 6 AT1G01180.1
17                 7 AT1G01190.1
18                 4 AT1G01200.1
19                 5 AT1G01210.1
20                 3 AT1G01220.1
</code></pre>
<p>The resulting output is a <code>Divergence Map</code> of the 20
example genes.</p>
<p>To save corresponding <code>Divergenec Maps</code> to a hard drive
users can pass the resulting <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code>
output to a variable and then use the <code><a href="https://rdrr.io/r/utils/write.table.html" class="external-link">write.table()</a></code>
function implemented in R to store the <code>Divergenec Map</code> as
<code>*.csv</code> file.</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">Athaliana_DM</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span> <span class="va">...</span> <span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/utils/write.table.html" class="external-link">write.table</a></span><span class="op">(</span>x         <span class="op">=</span> <span class="va">Athaliana_DM</span>, </span>
<span>            file      <span class="op">=</span> <span class="st">"Ath_Aly_DivergenceMap.csv"</span>, </span>
<span>            sep       <span class="op">=</span> <span class="st">";"</span>, </span>
<span>            col.names <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>            row.names <span class="op">=</span> <span class="cn">FALSE</span>, </span>
<span>            quote     <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code></pre></div>
<p>This way <code><a href="https://rdrr.io/r/utils/write.table.html" class="external-link">write.table()</a></code> will store the
<code>Divergence Map</code> to the users current working directory (=
<code><a href="https://rdrr.io/r/base/getwd.html" class="external-link">getwd()</a></code>).</p>
<div class="section level3">
<h3 id="specifying-the-arguments-in-divergence_stratigraphy">Specifying the arguments in
<code>divergence_stratigraphy()</code><a class="anchor" aria-label="anchor" href="#specifying-the-arguments-in-divergence_stratigraphy"></a>
</h3>
<p>Several argument combinations can be specified in
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> (see <code>Arguments</code> in
<code><a href="../reference/divergence_stratigraphy.html">?divergence_stratigraphy</a></code>). This section introduces
additional output options of <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code>.</p>
<div class="section level4">
<h4 id="example-blast_path">Example: <code>blast_path</code><a class="anchor" aria-label="anchor" href="#example-blast_path"></a>
</h4>
<p>Sometimes the machine users are working on does not allow them to
install <strong>BLAST</strong> in the default execution path
<code>usr/local/bin</code>. For this purpose the <code>blast_path</code>
argument is implemented in <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code>. This
argument takes an character string specifying the <code>PATH</code> to
the user’s <code>blastp</code> execution file that is stored in a
different place than <code>usr/local/bin</code>.</p>
<p>The following example shows a possible specification of
<code>blast_path</code>.</p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/drostlab/orthologr" class="external-link">orthologr</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># performing standard divergence stratigraphy</span></span>
<span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      blast_path      <span class="op">=</span> <span class="st">"here/the/path/to/blastp"</span>, </span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>, </span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>, </span>
<span>      dnds.threshold  <span class="op">=</span> <span class="fl">2</span>, </span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>, </span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code>
   divergence_strata    query_id
1                 10 AT1G01010.1
2                  9 AT1G01020.1
3                  5 AT1G01030.1
4                  4 AT1G01040.1
5                  1 AT1G01050.1
6                  9 AT1G01060.3
7                  6 AT1G01070.1
8                  8 AT1G01080.1
9                  2 AT1G01090.1
10                 7 AT1G01110.2
11                 2 AT1G01120.1
12                 3 AT1G01140.3
13                10 AT1G01150.1
14                 8 AT1G01160.1
15                 1 AT1G01170.2
16                 6 AT1G01180.1
17                 7 AT1G01190.1
18                 4 AT1G01200.1
19                 5 AT1G01210.1
20                 3 AT1G01220.1
</code></pre>
</div>
<div class="section level4">
<h4 id="example-ds-values">Example: <code>ds.values</code><a class="anchor" aria-label="anchor" href="#example-ds-values"></a>
</h4>
<p>As defined earlier, a <code>Divergence Map</code> stores the
<code>divergence strata</code> for protein coding genes of a
<code>query</code> organism. However, <code>divergence strata</code> are
based on <code>dNdS</code> values that were categorized into deciles.
For this reason it is not possible to map a
<code>divergence stratum</code> value to the exact initial
<code>dNdS</code> value. So in case users are interested in the the
exact <code>dNdS</code> value of protein coding genes, they can specify
the <code>ds.values</code> argument in
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> allowing them to retrieve a
<code>dNdS Map</code> instead of a <code>Divergence Map</code>. For this
purpose users need to set <code>ds.values = FALSE</code>.</p>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/drostlab/orthologr" class="external-link">orthologr</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># performing standard divergence stratigraphy</span></span>
<span><span class="co"># but receive a dNdS Map instead of a Divergence Map</span></span>
<span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>, </span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>,</span>
<span>      ds.values       <span class="op">=</span> <span class="cn">FALSE</span>, </span>
<span>      dnds.threshold  <span class="op">=</span> <span class="fl">2</span>,</span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>, </span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code>      dNdS    query_id
1  0.41950 AT1G01010.1
2  0.38790 AT1G01020.1
3  0.11850 AT1G01030.1
4  0.11560 AT1G01040.1
5  0.00000 AT1G01050.1
6  0.39670 AT1G01060.3
7  0.17280 AT1G01070.1
8  0.32170 AT1G01080.1
9  0.04174 AT1G01090.1
10 0.26620 AT1G01110.2
11 0.02317 AT1G01120.1
12 0.04324 AT1G01140.3
13 0.64120 AT1G01150.1
14 0.37310 AT1G01160.1
15 0.00000 AT1G01170.2
16 0.16830 AT1G01180.1
17 0.17730 AT1G01190.1
18 0.11370 AT1G01200.1
19 0.13420 AT1G01210.1
20 0.10230 AT1G01220.1
</code></pre>
<p>The corresponding output now stores <code>dNdS</code> values instead
of <code>DS</code> values in the first column.</p>
</div>
<div class="section level4">
<h4 id="example-subject-id">Example: <code>subject.id</code><a class="anchor" aria-label="anchor" href="#example-subject-id"></a>
</h4>
<p>Although the <code>Divergence Map</code> <a href="https://github.com/HajkD/myTAI/blob/master/vignettes/Introduction.Rmd#getting-started" class="external-link">standard</a>
is specified as storing <code>DS</code> values in the first column and
<code>GeneIDs</code> in the second column, in some cases it is important
to store the GeneIDs of orthologous genes in the <code>subject</code>
organism. The <code>subject.id</code> argument implemented in
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> allows users to retrieve the
GeneIDs of the orthologous genes of the <code>subject</code> organism.
For this purpose users need to specify
<code>subject.id = TRUE</code>.</p>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># receive a Divergence Map with DS | query GeneID | orthologous subject GeneID </span></span>
<span><span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>,</span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>,</span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>,</span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>      subject.id      <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code>   DS    query_id            subject_id
1  10 AT1G01010.1 333554|PACid:16033839
2   9 AT1G01020.1 470181|PACid:16064328
3   5 AT1G01030.1 470180|PACid:16054974
4   4 AT1G01040.1 333551|PACid:16057793
5   1 AT1G01050.1 909874|PACid:16064489
6   9 AT1G01060.3 470177|PACid:16043374
7   6 AT1G01070.1 918864|PACid:16052578
8   8 AT1G01080.1 909871|PACid:16053217
9   2 AT1G01090.1 470171|PACid:16052860
10  7 AT1G01110.2 333544|PACid:16034284
11  2 AT1G01120.1 918858|PACid:16049140
12  3 AT1G01140.3 470161|PACid:16036015
13 10 AT1G01150.1 918855|PACid:16037307
14  8 AT1G01160.1 918854|PACid:16044153
15  1 AT1G01170.2 311317|PACid:16052302
16  6 AT1G01180.1 909860|PACid:16056125
17  7 AT1G01190.1 311315|PACid:16059488
18  4 AT1G01200.1 470156|PACid:16041002
19  5 AT1G01210.1 311313|PACid:16057125
20  3 AT1G01220.1 470155|PACid:16047984</code></pre>
<p>The resulting output now shows DS values, query GeneIDs, and
orthologous subject GeneIDs.</p>
<p>A similar output can be generated for <code>dNdS</code> values
instead of <code>DS</code> values by specifying
<code>ds.values = FALSE</code> and <code>subject.id = TRUE</code>.</p>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># receive a dNdS Map with dNdS | query GeneID | orthologous subject GeneID </span></span>
<span><span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>,</span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>,</span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>,</span>
<span>      ds.values       <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>      subject.id      <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code>      dNdS    query_id            subject_id
1  0.41950 AT1G01010.1 333554|PACid:16033839
2  0.38790 AT1G01020.1 470181|PACid:16064328
3  0.11850 AT1G01030.1 470180|PACid:16054974
4  0.11560 AT1G01040.1 333551|PACid:16057793
5  0.00000 AT1G01050.1 909874|PACid:16064489
6  0.39670 AT1G01060.3 470177|PACid:16043374
7  0.17280 AT1G01070.1 918864|PACid:16052578
8  0.32170 AT1G01080.1 909871|PACid:16053217
9  0.04174 AT1G01090.1 470171|PACid:16052860
10 0.26620 AT1G01110.2 333544|PACid:16034284
11 0.02317 AT1G01120.1 918858|PACid:16049140
12 0.04324 AT1G01140.3 470161|PACid:16036015
13 0.64120 AT1G01150.1 918855|PACid:16037307
14 0.37310 AT1G01160.1 918854|PACid:16044153
15 0.00000 AT1G01170.2 311317|PACid:16052302
16 0.16830 AT1G01180.1 909860|PACid:16056125
17 0.17730 AT1G01190.1 311315|PACid:16059488
18 0.11370 AT1G01200.1 470156|PACid:16041002
19 0.13420 AT1G01210.1 311313|PACid:16057125
20 0.10230 AT1G01220.1 470155|PACid:16047984</code></pre>
</div>
<div class="section level4">
<h4 id="example-dnds-threshold">Example: <code>dnds.threshold</code><a class="anchor" aria-label="anchor" href="#example-dnds-threshold"></a>
</h4>
<p><code>Divergence Strata</code> are obtained by categorizing dNdS
values into deciles. For decilation the range of dNdS values is
important. The <code>dnds.threshold</code> defines the upper level cut
off of dNdS values. Since dNdS values are in the range [0, +Inf] a upper
threshold needs to be specified. The default value for
<code>dnds.threshold</code> in <code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code> is
<code>dnds.threshold = 2</code> due to the interpretation of dNdS values
for predicting sequence evolution (dNdS &lt; 1 -&gt; negative selection;
dNdS = 1 -&gt; neutral selection; dNdS &gt; 1 -&gt; positive selection).
Hence, all dNdS values <code>&gt; 1</code> predict positive selection.
In my experience of computing dNdS values between hundreds of pairwise
species comparisons covering all evolutionary distances, dNdS values of
orthologous genes rarely take values &gt; 2. Nevertheless, in case you
wish to extend or reduce the upper threshold for dNdS values, you can
specify the <code>dnds.threshold</code> in
<code><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy()</a></code>.</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># upper threshold for dNdS: dnds.threshold = 5</span></span>
<span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>, </span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"RBH"</span>,</span>
<span>      ds.values       <span class="op">=</span> <span class="cn">FALSE</span>, </span>
<span>      dnds.threshold  <span class="op">=</span> <span class="fl">5</span>,</span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>, </span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level4">
<h4 id="example-ortho_detection">Example: <code>ortho_detection</code><a class="anchor" aria-label="anchor" href="#example-ortho_detection"></a>
</h4>
<p>According to <a href="http://mbe.oxfordjournals.org/content/32/5/1221.full" class="external-link">Drost et
al., 2015 <em>Mol. Biol. Evol.</em></a> the <strong>Divergence
Stratigraphy</strong> algorithm performs <strong>BLAST</strong> best
reciprocal hit (RBH) as orthology inference method. Despite this
convention, the <code>ortho_detection</code> argument allows users to
perform orthology inference within the <strong>Divergence
Stratigraphy</strong> algorithm that is based on any orthology inference
method implemented in <code>orthologr</code> (see
<code><a href="../reference/orthologs.html">?orthologs</a></code> or <a href="https://github.com/HajkD/orthologr/blob/master/vignettes/orthology_inference.Rmd" class="external-link">Orthology
Inference Vignette</a> for details). For example in Quint et al., 2012
<em>Nature</em> instead of using <strong>BLAST</strong> best reciprocal
hit, the method <strong>BLAST</strong> best hit (BH) was used to perform
orthology inference within the <strong>Divergence Stratigraphy</strong>
algorithm.</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># orthology inference method: ortho_detection = "BH"</span></span>
<span> <span class="fu"><a href="../reference/divergence_stratigraphy.html">divergence_stratigraphy</a></span><span class="op">(</span></span>
<span>      query_file      <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_thal_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      subject_file    <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/system.file.html" class="external-link">system.file</a></span><span class="op">(</span><span class="st">'seqs/ortho_lyra_cds.fasta'</span>, package <span class="op">=</span> <span class="st">'orthologr'</span><span class="op">)</span>,</span>
<span>      eval            <span class="op">=</span> <span class="st">"1E-5"</span>, </span>
<span>      ortho_detection <span class="op">=</span> <span class="st">"BH"</span>,</span>
<span>      ds.values       <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>      dnds.threshold  <span class="op">=</span> <span class="fl">2</span>,</span>
<span>      comp_cores      <span class="op">=</span> <span class="fl">1</span>, </span>
<span>      quiet           <span class="op">=</span> <span class="cn">TRUE</span>, </span>
<span>      clean_folders   <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
<pre><code>   DS    query_id
1  10 AT1G01010.1
2   9 AT1G01020.1
3   5 AT1G01030.1
4   4 AT1G01040.1
5   1 AT1G01050.1
6   9 AT1G01060.3
7   6 AT1G01070.1
8   8 AT1G01080.1
9   2 AT1G01090.1
10  7 AT1G01110.2
11  2 AT1G01120.1
12  3 AT1G01140.3
13 10 AT1G01150.1
14  8 AT1G01160.1
15  1 AT1G01170.2
16  6 AT1G01180.1
17  7 AT1G01190.1
18  4 AT1G01200.1
19  5 AT1G01210.1
20  3 AT1G01220.1</code></pre>
</div>
</div>
</div>
<div class="section level2">
<h2 id="skip-divergence-stratigraphy-and-download-already-published-divergence-maps">Skip <code>Divergence Stratigraphy</code> and Download Already
Published <code>Divergence Maps</code><a class="anchor" aria-label="anchor" href="#skip-divergence-stratigraphy-and-download-already-published-divergence-maps"></a>
</h2>
<p>Users can find a detailed list of <a href="https://github.com/HajkD/published_phylomaps" class="external-link">published
Phylostratigraphic Maps and Divergence Maps</a> by following the link.
This way the computation time of 3-4 h on a local machine for 2 genome
comparisions can be skipped.</p>
</div>
<div class="section level2">
<h2 id="combine-a-divergence-map-with-gene-expression-data">Combine a Divergence Map with Gene Expression Data<a class="anchor" aria-label="anchor" href="#combine-a-divergence-map-with-gene-expression-data"></a>
</h2>
<p><code>Divergence Maps</code> can be used for a wide range of
analyses. One example is to combine <code>Divergence Maps</code> with
gene expression data to capture evolutionary signals in developmental
transcriptomes (= <code>Phylotranscriptomics</code>; see <a href="http://mbe.oxfordjournals.org/content/32/5/1221.full" class="external-link">Drost et
al., 2015 <em>Mol. Biol. Evol.</em></a>). Performing phylotranscriptomic
analyses based on an existing <code>Divergence Map</code> can easily be
done by using the <code>myTAI</code> package. You can consult the <a href="https://github.com/HajkD/myTAI/blob/master/vignettes/Introduction.Rmd" class="external-link">Introduction
to the myTAI package Vignette</a> for more details.</p>
</div>
  </div>

  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

        <nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
    </nav>
</div>

</div>



      <footer><div class="copyright">
  <p></p>
<p>Developed by Hajk-Georg Drost.</p>
</div>

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

      </footer>
</div>

  


  

  </body>
</html>
