<!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>Comparisons of Fst computations • assigner</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="Comparisons of Fst computations">
<meta property="og:description" content="assigner">
<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">assigner</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.8</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../../index.html">Installation</a>
</li>
<li>
  <a href="../../FEATURES.html">Features</a>
</li>
<li>
  <a href="../../articles/get_started.html">Get started</a>
</li>
<li>
  <a href="../../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li>
      <a href="../../articles/get_started.html">Get started</a>
    </li>
    <li>
      <a href="../../articles/fst_confidence_intervals.html">Fst analysis</a>
    </li>
    <li>
      <a href="../../articles/web_only/fst_comparisons.html">Comparisons of Fst in 8 packages/software</a>
    </li>
    <li>
      <a href="../../articles/assignment.whitelists.html">Using whitelists in assignment</a>
    </li>
    <li>
      <a href="../../articles/rad_genomics_computer_setup.html">Computer setup - Installation - Troubleshooting</a>
    </li>
    <li>
      <a href="../../articles/life_cycle.html">Life cycle</a>
    </li>
  </ul>
</li>
<li>
  <a href="../../news/index.html">News</a>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right">
<li>
  <a href="https://github.com/thierrygosselin/assigner">
    <span class="fa fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
</div>
<!--/.nav-collapse -->
  </div>
<!--/.container -->
</div>
<!--/.navbar -->

      

      </header><script src="fst_comparisons_files/accessible-code-block-0.0.1/empty-anchor.js"></script><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>Comparisons of Fst computations</h1>
            <h3 class="subtitle">
<code>assigner</code>, <code>diveRsity</code>, <code>GenoDive</code>, <code>hierfstat</code>, <code>SNPRelate</code>, <code>stAMPP</code>, <code>strataG</code>, <code>VCFtools.</code>
</h3>
                        <h4 class="author">Thierry Gosselin</h4>
            
            <h4 class="date">2020-10-26</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/thierrygosselin/assigner/blob/master/vignettes/web_only/fst_comparisons.Rmd"><code>vignettes/web_only/fst_comparisons.Rmd</code></a></small>
      <div class="hidden name"><code>fst_comparisons.Rmd</code></div>

    </div>

    
    
<div id="prepare-your-r-session" class="section level1">
<h1 class="hasAnchor">
<a href="#prepare-your-r-session" class="anchor"></a>Prepare your R session</h1>
<div class="sourceCode" id="cb1"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/base/rm.html">rm</a></span><span class="op">(</span>list <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/ls.html">ls</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="co"># clean workspace</span>
<span class="co"># install required packages</span>
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st">"diveRsity"</span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"diveRsity"</span><span class="op">)</span>
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st"><a href="https://www.r-project.org">"hierfstat"</a></span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"hierfstat"</span><span class="op">)</span>
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st">"StAMPP"</span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"StAMPP"</span><span class="op">)</span>
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st"><a href="https://github.com/EricArcher/strataG">"strataG"</a></span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"strataG"</span><span class="op">)</span>
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st"><a href="http://github.com/zhengxwen/SNPRelate">"SNPRelate"</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span>
  <span class="kw">if</span><span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st">"BiocManager"</span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"BiocManager"</span><span class="op">)</span>
  <span class="fu">BiocManager</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/BiocManager/man/install.html">install</a></span><span class="op">(</span><span class="st">"SNPRelate"</span><span class="op">)</span>
<span class="op">}</span>
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st">"ggcorrplot"</span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"ggcorrplot"</span><span class="op">)</span></pre></div>
<div class="sourceCode" id="cb2"><pre class="downlit">
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st"><a href="https://remotes.r-lib.org">"remotes"</a></span><span class="op">)</span><span class="op">)</span> <span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span><span class="op">(</span><span class="st">"remotes"</span><span class="op">)</span></pre></div>
<pre><code>## Loading required package: remotes</code></pre>
<div class="sourceCode" id="cb4"><pre class="downlit">
<span class="kw">if</span> <span class="op">(</span><span class="op">!</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="st"><a href="http://thierrygosselin.github.io/assigner/">"assigner"</a></span><span class="op">)</span><span class="op">)</span> <span class="fu">remotes</span><span class="fu">::</span><span class="fu"><a href="https://remotes.r-lib.org/reference/install_github.html">install_github</a></span><span class="op">(</span><span class="st">"thierrygosselin/assigner"</span><span class="op">)</span></pre></div>
<pre><code>## Loading required package: assigner</code></pre>
<pre><code>## Registered S3 method overwritten by 'spdep':
##   method   from
##   plot.mst ape</code></pre>
<p>For macOS: <a href="http://www.bentleydrummer.nl/software/software/GenoDive.html">GenoDive</a>.</p>
<p>VCFtools: <a href="https://vcftools.github.io">install instructions</a> or <a href="https://gbs-cloud-tutorial.readthedocs.io/en/latest/07_start_from_new_image.html#install-gbs-radseq-software-time-required-30min">here</a></p>
<p><strong>Versions of packages and software:</strong></p>
<div class="sourceCode" id="cb7"><pre class="downlit">
<span class="co"># Check packages versions</span>
<span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html">packageVersion</a></span><span class="op">(</span><span class="st">'assigner'</span><span class="op">)</span> <span class="co"># 0.5.6.</span>
<span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html">packageVersion</a></span><span class="op">(</span><span class="st">'diveRsity'</span><span class="op">)</span> <span class="co"># 1.9.90</span>
<span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html">packageVersion</a></span><span class="op">(</span><span class="st">'hierfstat'</span><span class="op">)</span> <span class="co"># 0.4.22</span>
<span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html">packageVersion</a></span><span class="op">(</span><span class="st">'stAMPP'</span><span class="op">)</span> <span class="co"># 1.5.1</span>
<span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html">packageVersion</a></span><span class="op">(</span><span class="st">'strataG'</span><span class="op">)</span> <span class="co"># 2.0.2</span>
<span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html">packageVersion</a></span><span class="op">(</span><span class="st">'SNPRelate'</span><span class="op">)</span> <span class="co"># 1.18.0</span>
<span class="co">#GenoDive: 2.27</span>
<span class="co"># VCFtools.: 0.1.17</span></pre></div>
<p>Put this <strong>Rmd notebook</strong> in the same directory as the data or use <code><a href="https://rdrr.io/r/base/getwd.html">setwd("/YOUR/NEW/PATH/HERE/")</a></code>, to change the working directory.</p>
</div>
<div id="goal-of-this-exercise" class="section level1">
<h1 class="hasAnchor">
<a href="#goal-of-this-exercise" class="anchor"></a>Goal of this exercise</h1>
<p>Let’s see how <code>assigner's</code> Fst calculations (using Weir and Cockerham, 1984) compares with alternatives. To make differences and bottlenecks really stand out we will use a RADseq dataset with <strong>thousands of markers</strong>.</p>
</div>
<div id="datasets" class="section level1">
<h1 class="hasAnchor">
<a href="#datasets" class="anchor"></a>Datasets</h1>
<div id="empirical-dataset" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset" class="anchor"></a>Empirical dataset</h2>
<p>We’re going to use the unfiltered vcf sunflower dataset from Owens et al. 2016, kindly provided by Gregory Owens. This dataset as missing data.</p>
<p>Owens GL, Baute GJ, Rieseberg LH. Revisiting a classic case of introgression: hybridization and gene flow in Californian sunflowers. Abbott RJ, Barton NH, Good JM, editors. Molecular Ecology. 2016;25: 2630–2643. <a href="doi:10.1111/mec.13569" class="uri">doi:10.1111/mec.13569</a></p>
<p><strong>Download the files:</strong></p>
<ul>
<li><a href="https://www.dropbox.com/s/3kfx351ijeaa1wr/sunflower.vcf?dl=0">vcf</a></li>
<li>
<a href="https://www.dropbox.com/s/406jleg3imwfaup/sunflower.strata.tsv?dl=0">strata</a>. What’s a strata file ? Read the <a href="https://thierrygosselin.github.io/radiator/reference/read_strata.html">doc</a>.</li>
</ul>
</div>
<div id="simulated-datasets" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets" class="anchor"></a>Simulated datasets</h2>
<p>After running this vignette once, I saw something strange in the results. To explore this further, this second grind of testing add 2 additional datasets: <a href="http://thierrygosselin.github.io/assigner/reference/data_assigner_sim_01.html">data_assigner_sim_01</a> and <a href="http://thierrygosselin.github.io/assigner/reference/data_assigner_sim_02.html">data_assigner_sim_02</a>. The documentation explains how these simulated data were produced. They differ mainly in migration rate which resulted in contrastingly different Fst, admixture/membership probability.</p>
</div>
</div>
<div id="generate-the-output-files" class="section level1">
<h1 class="hasAnchor">
<a href="#generate-the-output-files" class="anchor"></a>Generate the output files</h1>
<p>We use <a href="https://thierrygosselin.github.io/radiator/reference/genomic_converter.html">radiator::genomic_converter</a> to produce the required files or R objects:</p>
<div id="empirical-dataset-1" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-1" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb8"><pre class="downlit">
<span class="co"># radiator is installed automatically with assigner</span>
<span class="va">sunflower.filtered</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/genomic_converter.html">genomic_converter</a></span><span class="op">(</span>
  data <span class="op">=</span> <span class="st">"sunflower.vcf"</span>, 
  strata <span class="op">=</span> <span class="st">"sunflower.strata.tsv"</span>, 
  output <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>
    <span class="st">"genepop"</span>, <span class="co"># for GenoDive and diveRsity</span>
    <span class="st">"gtypes"</span>, <span class="co"># for strataG</span>
    <span class="st">"genlight"</span>, <span class="co"># for StAMPP</span>
    <span class="st">"hierfstat"</span>, <span class="co"># for Hierfstat</span>
    <span class="st">"snprelate"</span> <span class="co"># for SNPRelate</span>
  <span class="op">)</span>
<span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://tibble.tidyverse.org/reference/glimpse.html">glimpse</a></span><span class="op">(</span><span class="op">)</span></pre></div>
<p>VCF stats:</p>
<ul>
<li>the original number of markers is 34258.</li>
<li>by default, <code><a href="https://thierrygosselin.github.io/radiator/reference/genomic_converter.html">radiator::genomic_converter</a></code> will only keep polymorphic markers in common between the strata.</li>
<li>15973 biallelic markers are recovered.</li>
<li>Number of populations: 9</li>
<li>Number of individuals: 88</li>
</ul>
<p>The <code>sunflower.filtered</code> object is a list with several objects inside:</p>
<div class="sourceCode" id="cb9"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">sunflower.filtered</span><span class="op">)</span>
<span class="co">#&gt; [1] "hierfstat" "gtypes"    "genlight"  "snprelate" "tidy.data"</span>
<span class="co"># the tidy dataset is used by assigner</span></pre></div>
<p>The function also produced a folder with several files, including:</p>
<ul>
<li>the genepop file</li>
<li>the SNPRelate GDS file</li>
<li>the hierfstat file</li>
<li>the gtypes file</li>
<li>the genlight file</li>
<li>the tidy data file</li>
</ul>
<p>To learn more about the output folders and files: <a href="https://thierrygosselin.github.io/radiator/reference/genomic_converter.html">radiator::genomic_converter</a></p>
<p><em>Note on timing</em></p>
<p>I could use fancy timing packages (<a href="https://github.com/joshuaulrich/microbenchmark">microbenchmark</a>, <a href="http://bench.r-lib.org">bench</a>), but for simplicity we’re just going to use <code>system.time</code>.</p>
</div>
<div id="simulated-datasets-1" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-1" class="anchor"></a>Simulated datasets</h2>
<div id="sim_01" class="section level3">
<h3 class="hasAnchor">
<a href="#sim_01" class="anchor"></a>sim_01</h3>
<div class="sourceCode" id="cb10"><pre class="downlit">
<span class="va">data_assigner_sim_01</span> <span class="op">%&lt;&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>POP_ID <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">POP_ID</span>, levels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP_1"</span>, <span class="st">"POP_2"</span>, <span class="st">"POP_3"</span>, <span class="st">"POP_4"</span>, <span class="st">"POP_5"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP_ID</span><span class="op">)</span>

<span class="va">sim.data1</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/genomic_converter.html">genomic_converter</a></span><span class="op">(</span>
  data <span class="op">=</span> <span class="va">data_assigner_sim_01</span>, 
  output <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>
    <span class="st">"genepop"</span>, <span class="co"># for GenoDive and diveRsity</span>
    <span class="st">"gtypes"</span>, <span class="co"># for strataG</span>
    <span class="st">"genlight"</span>, <span class="co"># for StAMPP</span>
    <span class="st">"hierfstat"</span>, <span class="co"># for Hierfstat</span>
    <span class="st">"snprelate"</span> <span class="co"># for SNPRelate</span>
  <span class="op">)</span>,
  filename <span class="op">=</span> <span class="st">"sim01"</span>,
  path.folder <span class="op">=</span> <span class="st">"fst_sim01"</span>,
  internal <span class="op">=</span> <span class="cn">TRUE</span>,
  verbose <span class="op">=</span> <span class="cn">FALSE</span>
<span class="op">)</span>
<span class="va">sim.data1</span><span class="op">$</span><span class="va">tidy.data</span> <span class="op">%&lt;&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP_ID</span><span class="op">)</span></pre></div>
</div>
<div id="sim_02" class="section level3">
<h3 class="hasAnchor">
<a href="#sim_02" class="anchor"></a>sim_02</h3>
<div class="sourceCode" id="cb11"><pre class="downlit">
<span class="va">data_assigner_sim_02</span> <span class="op">%&lt;&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>POP_ID <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">POP_ID</span>, levels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP_1"</span>, <span class="st">"POP_2"</span>, <span class="st">"POP_3"</span>, <span class="st">"POP_4"</span>, <span class="st">"POP_5"</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP_ID</span><span class="op">)</span>

<span class="va">sim.data2</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/genomic_converter.html">genomic_converter</a></span><span class="op">(</span>
  data <span class="op">=</span> <span class="va">data_assigner_sim_02</span>, 
  output <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>
    <span class="st">"genepop"</span>, <span class="co"># for GenoDive and diveRsity</span>
    <span class="st">"gtypes"</span>, <span class="co"># for strataG</span>
    <span class="st">"genlight"</span>, <span class="co"># for StAMPP</span>
    <span class="st">"hierfstat"</span>, <span class="co"># for Hierfstat</span>
    <span class="st">"snprelate"</span> <span class="co"># for SNPRelate</span>
  <span class="op">)</span>,
  filename <span class="op">=</span> <span class="st">"sim02"</span>,
  path.folder <span class="op">=</span> <span class="st">"fst_sim02"</span>,
  internal <span class="op">=</span> <span class="cn">TRUE</span>,
  verbose <span class="op">=</span> <span class="cn">FALSE</span>
<span class="op">)</span>
<span class="va">sim.data2</span><span class="op">$</span><span class="va">tidy.data</span> <span class="op">%&lt;&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP_ID</span><span class="op">)</span></pre></div>
</div>
</div>
</div>
<div id="hierfstat" class="section level1">
<h1 class="hasAnchor">
<a href="#hierfstat" class="anchor"></a>hierfstat</h1>
<p>Let’s start with the Gold Standard, Jérôme Goudet’s <a href="https://github.com/jgx65/hierfstat">hierfstat</a> package.</p>
<div id="empirical-dataset-2" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-2" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb12"><pre class="downlit">
<span class="co"># ETA ~ 30 min on my MBP, so yes, you have time for coffee...</span>
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span><span class="co"># pop string</span>

<span class="fu"><a href="https://rdrr.io/r/base/system.time.html">system.time</a></span><span class="op">(</span>
  <span class="va">hierfstat.fst</span> <span class="op">&lt;-</span> <span class="fu">hierfstat</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/hierfstat/man/pairwise.WCfst.html">pairwise.WCfst</a></span><span class="op">(</span>
    dat <span class="op">=</span> <span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">hierfstat</span>, 
    diploid <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># The result need some work</span>
    <span class="co"># We transform the matrix into a useful tibble:</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, remove.lower <span class="op">=</span> <span class="cn">TRUE</span>, na.diag <span class="op">=</span> <span class="cn">TRUE</span>, relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span>, <span class="st">"HIERFSTAT"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP1</span>, <span class="va">POP2</span><span class="op">)</span>
<span class="op">)</span>
<span class="co">#&gt; 1233.880sec ~20 min</span>
<span class="va">hierfstat.fst</span></pre></div>
</div>
<div id="simulated-datasets-2" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-2" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb13"><pre class="downlit">
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sim.data1</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span><span class="co"># pop string</span>
<span class="va">hierfstat.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">hierfstat</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/hierfstat/man/pairwise.WCfst.html">pairwise.WCfst</a></span><span class="op">(</span>
    dat <span class="op">=</span> <span class="va">sim.data1</span><span class="op">$</span><span class="va">hierfstat</span>, 
    diploid <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># The result need some work</span>
    <span class="co"># We transform the matrix into a useful tibble:</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, remove.lower <span class="op">=</span> <span class="cn">TRUE</span>, na.diag <span class="op">=</span> <span class="cn">TRUE</span>, relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span>, <span class="st">"HIERFSTAT_SIM01"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP1</span>, <span class="va">POP2</span><span class="op">)</span>
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sim.data2</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span><span class="co"># pop string</span>
  <span class="va">hierfstat.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">hierfstat</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/hierfstat/man/pairwise.WCfst.html">pairwise.WCfst</a></span><span class="op">(</span>
    dat <span class="op">=</span> <span class="va">sim.data2</span><span class="op">$</span><span class="va">hierfstat</span>, 
    diploid <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># The result need some work</span>
    <span class="co"># We transform the matrix into a useful tibble:</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, remove.lower <span class="op">=</span> <span class="cn">TRUE</span>, na.diag <span class="op">=</span> <span class="cn">TRUE</span>, relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span>, <span class="st">"HIERFSTAT_SIM02"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP1</span>, <span class="va">POP2</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="stratag" class="section level1">
<h1 class="hasAnchor">
<a href="#stratag" class="anchor"></a>strataG</h1>
<p>This is Eric Archer’s <a href="https://github.com/EricArcher/strataG">strataG</a> package.</p>
<div id="empirical-dataset-3" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-3" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb14"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/base/system.time.html">system.time</a></span><span class="op">(</span>
  <span class="va">stratag.fst</span> <span class="op">&lt;-</span> <span class="fu">strataG</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/strataG/man/popStructTest.html">popStructTest</a></span><span class="op">(</span>
    g <span class="op">=</span> <span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">gtypes</span>, 
    stats <span class="op">=</span> <span class="st">"fst"</span>, 
    type <span class="op">=</span> <span class="st">"both"</span>, 
    quietly <span class="op">=</span> <span class="cn">TRUE</span>, 
    max.cores <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>, 
    nrep <span class="op">=</span> <span class="fl">0</span>, 
    keep.null <span class="op">=</span> <span class="cn">FALSE</span>, 
    write.output <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span> <span class="op">%$%</span>
    <span class="va">pairwise</span><span class="op">$</span><span class="va">result</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span>POP1 <span class="op">=</span> <span class="va">strata.1</span>, POP2 <span class="op">=</span> <span class="va">strata.2</span>, STRATAG <span class="op">=</span> <span class="va">Fst</span><span class="op">)</span>
<span class="op">)</span>
<span class="va">stratag.fst</span>
<span class="co">#&gt;657.377sec ~ 11 min</span></pre></div>
</div>
<div id="simulated-datasets-3" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-3" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb15"><pre class="downlit">
<span class="va">stratag.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">strataG</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/strataG/man/popStructTest.html">popStructTest</a></span><span class="op">(</span>
    g <span class="op">=</span> <span class="va">sim.data1</span><span class="op">$</span><span class="va">gtypes</span>, 
    stats <span class="op">=</span> <span class="st">"fst"</span>, 
    type <span class="op">=</span> <span class="st">"both"</span>, 
    quietly <span class="op">=</span> <span class="cn">TRUE</span>, 
    max.cores <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>, 
    nrep <span class="op">=</span> <span class="fl">0</span>, 
    keep.null <span class="op">=</span> <span class="cn">FALSE</span>, 
    write.output <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span> <span class="op">%$%</span>
    <span class="va">pairwise</span><span class="op">$</span><span class="va">result</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span>POP1 <span class="op">=</span> <span class="va">strata.1</span>, POP2 <span class="op">=</span> <span class="va">strata.2</span>, STRATAG_SIM01 <span class="op">=</span> <span class="va">Fst</span><span class="op">)</span>
<span class="va">stratag.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">strataG</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/strataG/man/popStructTest.html">popStructTest</a></span><span class="op">(</span>
    g <span class="op">=</span> <span class="va">sim.data2</span><span class="op">$</span><span class="va">gtypes</span>, 
    stats <span class="op">=</span> <span class="st">"fst"</span>, 
    type <span class="op">=</span> <span class="st">"both"</span>, 
    quietly <span class="op">=</span> <span class="cn">TRUE</span>, 
    max.cores <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>, 
    nrep <span class="op">=</span> <span class="fl">0</span>, 
    keep.null <span class="op">=</span> <span class="cn">FALSE</span>, 
    write.output <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span> <span class="op">%$%</span>
    <span class="va">pairwise</span><span class="op">$</span><span class="va">result</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span>POP1 <span class="op">=</span> <span class="va">strata.1</span>, POP2 <span class="op">=</span> <span class="va">strata.2</span>, STRATAG_SIM02 <span class="op">=</span> <span class="va">Fst</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="diversity" class="section level1">
<h1 class="hasAnchor">
<a href="#diversity" class="anchor"></a>diveRsity</h1>
<ul>
<li>Kevin Keenan’s <a href="http://diversityinlife.weebly.com/software.html">diveRsity</a> package requires the <code>genepop</code> file.</li>
<li>the function is optimized with C++, so no need for a coffee (&lt; 1 min on my MBP)</li>
</ul>
<div id="empirical-dataset-4" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-4" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb16"><pre class="downlit">
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span> <span class="co"># pop string</span>
<span class="fu"><a href="https://rdrr.io/r/base/system.time.html">system.time</a></span><span class="op">(</span>
  <span class="va">diversity.fst</span> <span class="op">&lt;-</span> <span class="fu">diveRsity</span><span class="fu">::</span><span class="fu">diffCalc</span><span class="op">(</span>
    infile <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.files.html">list.files</a></span><span class="op">(</span>
      path <span class="op">=</span> <span class="st">"."</span>, 
      pattern <span class="op">=</span> <span class="st">"_genepop.gen"</span>, 
      full.names <span class="op">=</span> <span class="cn">TRUE</span>,
      recursive <span class="op">=</span> <span class="cn">TRUE</span>
    <span class="op">)</span>, 
    outfile <span class="op">=</span> <span class="st">"sunflower_diversity_output"</span>, 
    fst <span class="op">=</span> <span class="cn">TRUE</span>,
    pairwise <span class="op">=</span> <span class="cn">TRUE</span>,
    para <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span> <span class="op">%$%</span>
    <span class="va">pairwise</span> <span class="op">%$%</span>
    <span class="va">Fst</span> <span class="op">%&gt;%</span> 
    <span class="co"># The result need some work</span>
    <span class="co"># We transform the matrix into a useful tibble:</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, 
      remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      remove.lower <span class="op">=</span> <span class="cn">FALSE</span>, <span class="co"># FALSE because their's only the lower diag</span>
      na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># we switch the POP id column here to match the others</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP2"</span>, <span class="st">"POP1"</span>, <span class="st">"DIVERSITY"</span><span class="op">)</span><span class="op">)</span>
<span class="op">)</span>
<span class="co">#&gt; 42.711 sec Wow! this is very fast, plus other distances are automatically generated!</span>
<span class="va">diversity.fst</span></pre></div>
</div>
<div id="simulated-datasets-4" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-4" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb17"><pre class="downlit">
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sim.data1</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span> <span class="co"># pop string</span>
<span class="va">diversity.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">diveRsity</span><span class="fu">::</span><span class="fu">diffCalc</span><span class="op">(</span>
  infile <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.files.html">list.files</a></span><span class="op">(</span>
    path <span class="op">=</span> <span class="st">"."</span>, 
    pattern <span class="op">=</span> <span class="st">"sim01_genepop.gen"</span>, 
    full.names <span class="op">=</span> <span class="cn">TRUE</span>,
    recursive <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span>, 
  outfile <span class="op">=</span> <span class="st">"sim_data1_diversity_output"</span>, 
  fst <span class="op">=</span> <span class="cn">TRUE</span>,
  pairwise <span class="op">=</span> <span class="cn">TRUE</span>,
  para <span class="op">=</span> <span class="cn">TRUE</span>
<span class="op">)</span> <span class="op">%$%</span>
  <span class="va">pairwise</span> <span class="op">%$%</span>
  <span class="va">Fst</span> <span class="op">%&gt;%</span> 
  <span class="co"># The result need some work</span>
  <span class="co"># We transform the matrix into a useful tibble:</span>
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
    x <span class="op">=</span> <span class="va">.</span>, 
    remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    remove.lower <span class="op">=</span> <span class="cn">FALSE</span>, <span class="co"># FALSE because their's only the lower diag</span>
    na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    relative <span class="op">=</span> <span class="cn">FALSE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="co"># we switch the POP id column here to match the others</span>
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP2"</span>, <span class="st">"POP1"</span>, <span class="st">"DIVERSITY_SIM01"</span><span class="op">)</span><span class="op">)</span>
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sim.data2</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span> <span class="co"># pop string</span>
<span class="va">diversity.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">diveRsity</span><span class="fu">::</span><span class="fu">diffCalc</span><span class="op">(</span>
  infile <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.files.html">list.files</a></span><span class="op">(</span>
    path <span class="op">=</span> <span class="st">"."</span>, 
    pattern <span class="op">=</span> <span class="st">"sim02_genepop.gen"</span>, 
    full.names <span class="op">=</span> <span class="cn">TRUE</span>,
    recursive <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span>,  
  outfile <span class="op">=</span> <span class="st">"sim_data2_diversity_output"</span>, 
  fst <span class="op">=</span> <span class="cn">TRUE</span>,
  pairwise <span class="op">=</span> <span class="cn">TRUE</span>,
  para <span class="op">=</span> <span class="cn">TRUE</span>
<span class="op">)</span> <span class="op">%$%</span>
  <span class="va">pairwise</span> <span class="op">%$%</span>
  <span class="va">Fst</span> <span class="op">%&gt;%</span> 
  <span class="co"># The result need some work</span>
  <span class="co"># We transform the matrix into a useful tibble:</span>
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
    x <span class="op">=</span> <span class="va">.</span>, 
    remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    remove.lower <span class="op">=</span> <span class="cn">FALSE</span>, <span class="co"># FALSE because their's only the lower diag</span>
    na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    relative <span class="op">=</span> <span class="cn">FALSE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="co"># we switch the POP id column here to match the others</span>
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP2"</span>, <span class="st">"POP1"</span>, <span class="st">"DIVERSITY_SIM02"</span><span class="op">)</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="snprelate" class="section level1">
<h1 class="hasAnchor">
<a href="#snprelate" class="anchor"></a>SNPRelate</h1>
<ul>
<li>Xiuwen Zheng’s <a href="https://github.com/zhengxwen/SNPRelate">SNPRelate</a> package is very fast.</li>
<li>No out-of-the-box pairwise Fst analysis. So I implemented my own below.</li>
</ul>
<div id="empirical-dataset-5" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-5" class="anchor"></a>Empirical dataset</h2>
<p>We need the strata</p>
<div class="sourceCode" id="cb18"><pre class="downlit">
<span class="va">strata</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/read_strata.html">read_strata</a></span><span class="op">(</span>strata <span class="op">=</span> <span class="st">"sunflower.strata.tsv"</span><span class="op">)</span> <span class="op">%$%</span> <span class="va">strata</span></pre></div>
<p>Showing off the global Fst only:</p>
<div class="sourceCode" id="cb19"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/base/system.time.html">system.time</a></span><span class="op">(</span>
  <span class="va">snprelate.fst</span> <span class="op">&lt;-</span> <span class="fu">SNPRelate</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/SNPRelate/man/snpgdsFst.html">snpgdsFst</a></span><span class="op">(</span>
    gdsobj <span class="op">=</span> <span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">snprelate</span>,
    population <span class="op">=</span> <span class="va">strata</span><span class="op">$</span><span class="va">STRATA</span>, <span class="co"># factors required</span>
    sample.id <span class="op">=</span> <span class="va">strata</span><span class="op">$</span><span class="va">INDIVIDUALS</span>,
    snp.id <span class="op">=</span> <span class="cn">NULL</span>,
    method <span class="op">=</span> <span class="st">"W&amp;C84"</span>,
    remove.monosnp <span class="op">=</span> <span class="cn">TRUE</span>,
    maf <span class="op">=</span> <span class="cn">NaN</span>,
    missing.rate <span class="op">=</span> <span class="cn">NaN</span>,
    autosome.only <span class="op">=</span> <span class="cn">FALSE</span>,
    with.id <span class="op">=</span> <span class="cn">FALSE</span>,
    verbose <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span>
<span class="op">)</span>
<span class="co">#&gt; 0.029sec wo!</span>

<span class="fu"><a href="https://rdrr.io/r/base/names.html">names</a></span><span class="op">(</span><span class="va">snprelate.fst</span><span class="op">)</span>
<span class="co">#&gt; snprelate.fst$Fst: weighted Fst estimate</span>
<span class="co">#&gt; snprelate.fst$MeanFst: the average of Fst estimates across SNPs</span>
<span class="co">#&gt; snprelate.fst$FstSNP: a vector of Fst for each SNP</span></pre></div>
<p>Build a function to conduct pairwise Fst with SNPRelate:</p>
<div class="sourceCode" id="cb20"><pre class="downlit">
<span class="va">pairwise_fst_snprelate</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">pop.pairwise</span>, <span class="va">data</span>, <span class="va">strata</span><span class="op">)</span> <span class="op">{</span>
  <span class="va">strata.temp</span> <span class="op">&lt;-</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span>.data <span class="op">=</span> <span class="va">strata</span>, <span class="va">STRATA</span> <span class="op">%in%</span> <span class="va">pop.pairwise</span><span class="op">)</span> <span class="op">%&gt;%</span>
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>STRATA <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/droplevels.html">droplevels</a></span><span class="op">(</span><span class="va">STRATA</span><span class="op">)</span><span class="op">)</span>
  
  <span class="va">fst</span> <span class="op">&lt;-</span> <span class="fu">SNPRelate</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/SNPRelate/man/snpgdsFst.html">snpgdsFst</a></span><span class="op">(</span>
    gdsobj <span class="op">=</span> <span class="va">data</span>,
    population <span class="op">=</span> <span class="va">strata.temp</span><span class="op">$</span><span class="va">STRATA</span>, <span class="co"># factors required</span>
    sample.id <span class="op">=</span> <span class="va">strata.temp</span><span class="op">$</span><span class="va">INDIVIDUALS</span>,
    snp.id <span class="op">=</span> <span class="cn">NULL</span>,
    method <span class="op">=</span> <span class="st">"W&amp;C84"</span>,
    remove.monosnp <span class="op">=</span> <span class="cn">TRUE</span>,
    maf <span class="op">=</span> <span class="cn">NaN</span>,
    missing.rate <span class="op">=</span> <span class="cn">NaN</span>,
    autosome.only <span class="op">=</span> <span class="cn">FALSE</span>,
    with.id <span class="op">=</span> <span class="cn">FALSE</span>,
    verbose <span class="op">=</span> <span class="cn">TRUE</span>
  <span class="op">)</span>
  <span class="co">#prepare the results into a tibble:</span>
  <span class="va">fst</span> <span class="op">&lt;-</span> <span class="fu">tibble</span><span class="fu">::</span><span class="fu"><a href="https://tibble.tidyverse.org/reference/tibble.html">tibble</a></span><span class="op">(</span>
    POP1 <span class="op">=</span> <span class="va">pop.pairwise</span><span class="op">[</span><span class="fl">1</span><span class="op">]</span>, 
    POP2 <span class="op">=</span> <span class="va">pop.pairwise</span><span class="op">[</span><span class="fl">2</span><span class="op">]</span>, 
    SNPRELATE_MEAN <span class="op">=</span> <span class="va">fst</span><span class="op">$</span><span class="va">MeanFst</span>,
    SNPRELATE_WEIGHTED <span class="op">=</span> <span class="va">fst</span><span class="op">$</span><span class="va">Fst</span>
  <span class="op">)</span>
  <span class="kw"><a href="https://rdrr.io/r/base/function.html">return</a></span><span class="op">(</span><span class="va">fst</span><span class="op">)</span>
<span class="op">}</span></pre></div>
<p>To run we need all combination of populations:</p>
<div class="sourceCode" id="cb21"><pre class="downlit">
<span class="va">pop.pairwise</span> <span class="op">&lt;-</span> <span class="fu">utils</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/utils/combn.html">combn</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">strata</span><span class="op">$</span><span class="va">STRATA</span><span class="op">)</span><span class="op">)</span>, <span class="fl">2</span>, simplify <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
<p>Run the pairwise implementation:</p>
<div class="sourceCode" id="cb22"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/base/system.time.html">system.time</a></span><span class="op">(</span>
  <span class="va">snprelate.fst</span> <span class="op">&lt;-</span> <span class="fu">purrr</span><span class="fu">::</span><span class="fu"><a href="https://purrr.tidyverse.org/reference/map.html">map_dfr</a></span><span class="op">(</span>
    .x <span class="op">=</span> <span class="va">pop.pairwise</span>,
    .f <span class="op">=</span> <span class="va">pairwise_fst_snprelate</span>,
    data <span class="op">=</span> <span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">snprelate</span>,
    strata <span class="op">=</span> <span class="va">strata</span>
  <span class="op">)</span>
<span class="op">)</span>
<span class="co">#&gt; 0.245 sec that's the fastest so far!</span></pre></div>
</div>
<div id="simulated-datasets-5" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-5" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb23"><pre class="downlit">
<span class="va">strata</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/generate_strata.html">generate_strata</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">sim.data1</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>STRATA <span class="op">=</span> <span class="va">POP_ID</span><span class="op">)</span>
<span class="va">pop.pairwise</span> <span class="op">&lt;-</span> <span class="fu">utils</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/utils/combn.html">combn</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">strata</span><span class="op">$</span><span class="va">STRATA</span><span class="op">)</span><span class="op">)</span>, <span class="fl">2</span>, simplify <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
<span class="va">snprelate.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">purrr</span><span class="fu">::</span><span class="fu"><a href="https://purrr.tidyverse.org/reference/map.html">map_dfr</a></span><span class="op">(</span>
  .x <span class="op">=</span> <span class="va">pop.pairwise</span>,
  .f <span class="op">=</span> <span class="va">pairwise_fst_snprelate</span>,
  data <span class="op">=</span> <span class="va">sim.data1</span><span class="op">$</span><span class="va">snprelate</span>,
  strata <span class="op">=</span> <span class="va">strata</span>
<span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>SNPRELATE_MEAN_SIM01 <span class="op">=</span> <span class="va">SNPRELATE_MEAN</span>, SNPRELATE_WEIGHTED_SIM01 <span class="op">=</span> <span class="va">SNPRELATE_WEIGHTED</span><span class="op">)</span>

<span class="va">strata</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/generate_strata.html">generate_strata</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">sim.data2</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>STRATA <span class="op">=</span> <span class="va">POP_ID</span><span class="op">)</span>
<span class="va">pop.pairwise</span> <span class="op">&lt;-</span> <span class="fu">utils</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/utils/combn.html">combn</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">strata</span><span class="op">$</span><span class="va">STRATA</span><span class="op">)</span><span class="op">)</span>, <span class="fl">2</span>, simplify <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
<span class="va">snprelate.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">purrr</span><span class="fu">::</span><span class="fu"><a href="https://purrr.tidyverse.org/reference/map.html">map_dfr</a></span><span class="op">(</span>
  .x <span class="op">=</span> <span class="va">pop.pairwise</span>,
  .f <span class="op">=</span> <span class="va">pairwise_fst_snprelate</span>,
  data <span class="op">=</span> <span class="va">sim.data2</span><span class="op">$</span><span class="va">snprelate</span>,
  strata <span class="op">=</span> <span class="va">strata</span>
<span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>SNPRELATE_MEAN_SIM02 <span class="op">=</span> <span class="va">SNPRELATE_MEAN</span>, SNPRELATE_WEIGHTED_SIM02 <span class="op">=</span> <span class="va">SNPRELATE_WEIGHTED</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="genodive" class="section level1">
<h1 class="hasAnchor">
<a href="#genodive" class="anchor"></a>GenoDive</h1>
<ul>
<li>Inside Patrick Meirmans’s <a href="http://www.bentleydrummer.nl/software/software/GenoDive.html">GenoDive</a> software, <em>import</em> or <em>drag</em> the <code>genepop</code> file</li>
<li>Run: <code>Analysis -&gt; Pairwise Differentiation -&gt; F_st</code>, choose <code>1 permutations</code>.</li>
<li>Save the results or copy/paste in MS Excel or text editor: <strong>genodive.fst.tsv</strong>.</li>
<li>no need for a coffee, <code>GenoDive</code> is coded in Objective-C (~ &lt; 3 sec on my MBP)</li>
</ul>
<div id="empirical-dataset-6" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-6" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb24"><pre class="downlit">
<span class="co"># Import in R</span>
<span class="co"># Add the proper columns and rows names</span>
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span> <span class="co"># pop string</span>
<span class="va">genodive.fst</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>
  file <span class="op">=</span> <span class="st">"genodive.fst.tsv"</span>,
  col_names <span class="op">=</span> <span class="va">pops</span>
<span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu"><a href="https://rdrr.io/pkg/strataG/man/as.data.frame.gtypes.html">as.matrix</a></span><span class="op">(</span><span class="va">.</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
    x <span class="op">=</span> <span class="va">.</span>, 
    remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    remove.lower <span class="op">=</span> <span class="cn">TRUE</span>, <span class="co"># FALSE because their's only the lower diag</span>
    na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    relative <span class="op">=</span> <span class="cn">FALSE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span>, <span class="st">"GENODIVE"</span><span class="op">)</span><span class="op">)</span>
<span class="va">genodive.fst</span></pre></div>
<p>Obviously, here the timing gets doesn’t reflect the whole process:</p>
<ul>
<li>the data as to be imported in GenoDive</li>
<li>several manipulations of the results are required to get from GenoDive to R</li>
</ul>
</div>
<div id="simulated-datasets-6" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-6" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb25"><pre class="downlit">
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sim.data1</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span> <span class="co"># pop string</span>
<span class="va">genodive.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>
  file <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.files.html">list.files</a></span><span class="op">(</span>
      path <span class="op">=</span> <span class="st">"."</span>, 
      pattern <span class="op">=</span> <span class="st">"genodive.sim01.fst.tsv"</span>, 
      full.names <span class="op">=</span> <span class="cn">TRUE</span>,
      recursive <span class="op">=</span> <span class="cn">TRUE</span>
    <span class="op">)</span>,
  col_names <span class="op">=</span> <span class="va">pops</span>
<span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu"><a href="https://rdrr.io/pkg/strataG/man/as.data.frame.gtypes.html">as.matrix</a></span><span class="op">(</span><span class="va">.</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
    x <span class="op">=</span> <span class="va">.</span>, 
    remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    remove.lower <span class="op">=</span> <span class="cn">TRUE</span>, <span class="co"># FALSE because their's only the lower diag</span>
    na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    relative <span class="op">=</span> <span class="cn">FALSE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span>, <span class="st">"GENODIVE_SIM01"</span><span class="op">)</span><span class="op">)</span>
<span class="va">pops</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/character.html">as.character</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="va">sim.data2</span><span class="op">$</span><span class="va">tidy.data</span><span class="op">$</span><span class="va">POP_ID</span><span class="op">)</span><span class="op">)</span> <span class="co"># pop string</span>
<span class="va">genodive.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>
  file <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.files.html">list.files</a></span><span class="op">(</span>
      path <span class="op">=</span> <span class="st">"."</span>, 
      pattern <span class="op">=</span> <span class="st">"genodive.sim02.fst.tsv"</span>, 
      full.names <span class="op">=</span> <span class="cn">TRUE</span>,
      recursive <span class="op">=</span> <span class="cn">TRUE</span>
    <span class="op">)</span>,
  col_names <span class="op">=</span> <span class="va">pops</span>
<span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu"><a href="https://rdrr.io/pkg/strataG/man/as.data.frame.gtypes.html">as.matrix</a></span><span class="op">(</span><span class="va">.</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_rownames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="va">pops</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
    x <span class="op">=</span> <span class="va">.</span>, 
    remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    remove.lower <span class="op">=</span> <span class="cn">TRUE</span>, <span class="co"># FALSE because their's only the lower diag</span>
    na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    relative <span class="op">=</span> <span class="cn">FALSE</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span>, <span class="st">"GENODIVE_SIM02"</span><span class="op">)</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="stampp" class="section level1">
<h1 class="hasAnchor">
<a href="#stampp" class="anchor"></a>StAMPP</h1>
<p>Luke Pembleton’s <code>StAMPP</code> package use <code>genlight</code> object as input:</p>
<div id="empirical-dataset-7" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-7" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb26"><pre class="downlit">
<span class="fu"><a href="https://rdrr.io/r/base/system.time.html">system.time</a></span><span class="op">(</span>
  <span class="va">stampp.fst</span> <span class="op">&lt;-</span> <span class="fu">StAMPP</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/StAMPP/man/stamppFst.html">stamppFst</a></span><span class="op">(</span>
    geno <span class="op">=</span> <span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">genlight</span>, 
    nboots <span class="op">=</span> <span class="fl">1</span>, 
    percent <span class="op">=</span> <span class="fl">95</span>, 
    nclusters <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># The distance matrix need some love</span>
    <span class="co"># if we want to compare it with the others:</span>
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, 
      remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      remove.lower <span class="op">=</span> <span class="cn">FALSE</span>, 
      na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># we switch the POP id column here to match the others</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP2"</span>, <span class="st">"POP1"</span>, <span class="st">"STAMPP"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP1</span>, <span class="va">POP2</span><span class="op">)</span>
<span class="op">)</span>
<span class="co">#&gt; 39.281 sec!</span></pre></div>
</div>
<div id="simulated-datasets-7" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-7" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb27"><pre class="downlit">
<span class="va">stampp.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">StAMPP</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/StAMPP/man/stamppFst.html">stamppFst</a></span><span class="op">(</span>
    geno <span class="op">=</span> <span class="va">sim.data1</span><span class="op">$</span><span class="va">genlight</span>, 
    nboots <span class="op">=</span> <span class="fl">1</span>, 
    percent <span class="op">=</span> <span class="fl">95</span>, 
    nclusters <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># The distance matrix need some love</span>
    <span class="co"># if we want to compare it with the others:</span>
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, 
      remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      remove.lower <span class="op">=</span> <span class="cn">FALSE</span>, 
      na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># we switch the POP id column here to match the others</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP2"</span>, <span class="st">"POP1"</span>, <span class="st">"STAMPP_SIM01"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP1</span>, <span class="va">POP2</span><span class="op">)</span>

<span class="va">stampp.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">StAMPP</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/StAMPP/man/stamppFst.html">stamppFst</a></span><span class="op">(</span>
    geno <span class="op">=</span> <span class="va">sim.data2</span><span class="op">$</span><span class="va">genlight</span>, 
    nboots <span class="op">=</span> <span class="fl">1</span>, 
    percent <span class="op">=</span> <span class="fl">95</span>, 
    nclusters <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>
  <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># The distance matrix need some love</span>
    <span class="co"># if we want to compare it with the others:</span>
    <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">.</span>, 
      remove.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      remove.lower <span class="op">=</span> <span class="cn">FALSE</span>, 
      na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
      relative <span class="op">=</span> <span class="cn">FALSE</span>
    <span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="co"># we switch the POP id column here to match the others</span>
    <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP2"</span>, <span class="st">"POP1"</span>, <span class="st">"STAMPP_SIM02"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">POP1</span>, <span class="va">POP2</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="vcftools" class="section level1">
<h1 class="hasAnchor">
<a href="#vcftools" class="anchor"></a>VCFtools</h1>
<p>I’m not particularly fond of VCFtools for Fst. Too much manipulation of files. For the sake of the exercise I’m going to compare it quickly with 2 populations for the empirical dataset only.</p>
<div id="empirical-dataset-8" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-8" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb28"><pre class="downlit">
<span class="va">pop1</span> <span class="op">&lt;-</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">strata</span>, <span class="va">STRATA</span> <span class="op">==</span> <span class="st">"G100"</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">INDIVIDUALS</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/write_delim.html">write_tsv</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, path <span class="op">=</span> <span class="st">"pop1.txt"</span>, col_names <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
<span class="va">pop2</span> <span class="op">&lt;-</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">strata</span>, <span class="va">STRATA</span> <span class="op">==</span> <span class="st">"G102"</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">INDIVIDUALS</span><span class="op">)</span> <span class="op">%&gt;%</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/write_delim.html">write_tsv</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, path <span class="op">=</span> <span class="st">"pop2.txt"</span>, col_names <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
<p>the command used:</p>
<div class="sourceCode" id="cb29"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb29-1"><a href="#cb29-1"></a><span class="ex">vcftools</span> --vcf sunflower.vcf --weir-fst-pop pop1.txt --weir-fst-pop pop2.txt --out pop1_vs_pop2 </span>
<span id="cb29-2"><a href="#cb29-2"></a><span class="co">#&gt; Fst between G100 and G102:</span></span>
<span id="cb29-3"><a href="#cb29-3"></a><span class="co">#&gt; Weir and Cockerham mean Fst estimate: 0.036903</span></span>
<span id="cb29-4"><a href="#cb29-4"></a><span class="co">#&gt; Weir and Cockerham weighted Fst estimate: 0.16222</span></span></code></pre></div>
<p>PLINK users, note that the <code>--fst</code> option in <a href="https://www.cog-genomics.org/plink/1.9/basic_stats#fst">PLINK v.1.9</a> is actually a port of VCFtools..</p>
<p>For me, comparison with VCFtools stops here, too painfull to conduct more pairwise, getting the ouput ready for R, etc. This is prone to human error and too much work to automate for no benefit (below you’ll understand how those VCFtools results compares with the other packages).</p>
</div>
<div id="simulated-datasets-8" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-8" class="anchor"></a>Simulated datasets</h2>
<p><em>not conducted</em></p>
</div>
</div>
<div id="assigner" class="section level1">
<h1 class="hasAnchor">
<a href="#assigner" class="anchor"></a>assigner</h1>
<div id="empirical-dataset-9" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-9" class="anchor"></a>Empirical dataset</h2>
<div class="sourceCode" id="cb30"><pre class="downlit">
<span class="va">assigner.fst</span> <span class="op">&lt;-</span> <span class="fu">assigner</span><span class="fu">::</span><span class="fu"><a href="../../reference/fst_WC84.html">fst_WC84</a></span><span class="op">(</span>
  data <span class="op">=</span> <span class="va">sunflower.filtered</span><span class="op">$</span><span class="va">tidy.data</span>, 
  pairwise <span class="op">=</span> <span class="cn">TRUE</span>,
  parallel.core <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>,
  verbose <span class="op">=</span> <span class="cn">TRUE</span>
<span class="op">)</span> <span class="op">%$%</span>
  <span class="va">pairwise.fst</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>ASSIGNER <span class="op">=</span> <span class="va">FST</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">N_MARKERS</span><span class="op">)</span>
<span class="co">#&gt; 49 sec</span>
<span class="va">assigner.fst</span></pre></div>
<p>Learn more about <code><a href="../../reference/fst_WC84.html">assigner::fst_WC84</a></code> with the dedicated <a href="http://thierrygosselin.github.io/assigner/articles/fst_confidence_intervals.html">vignette</a>.</p>
</div>
<div id="simulated-datasets-9" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-9" class="anchor"></a>Simulated datasets</h2>
<div class="sourceCode" id="cb31"><pre class="downlit">
<span class="va">assigner.sim01.fst</span> <span class="op">&lt;-</span> <span class="fu">assigner</span><span class="fu">::</span><span class="fu"><a href="../../reference/fst_WC84.html">fst_WC84</a></span><span class="op">(</span>
  data <span class="op">=</span> <span class="va">sim.data1</span><span class="op">$</span><span class="va">tidy.data</span>, 
  pairwise <span class="op">=</span> <span class="cn">TRUE</span>,
  parallel.core <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>,
  verbose <span class="op">=</span> <span class="cn">TRUE</span>
<span class="op">)</span> <span class="op">%$%</span>
  <span class="va">pairwise.fst</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>ASSIGNER_SIM01 <span class="op">=</span> <span class="va">FST</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">N_MARKERS</span><span class="op">)</span>

<span class="va">assigner.sim02.fst</span> <span class="op">&lt;-</span> <span class="fu">assigner</span><span class="fu">::</span><span class="fu"><a href="../../reference/fst_WC84.html">fst_WC84</a></span><span class="op">(</span>
  data <span class="op">=</span> <span class="va">sim.data2</span><span class="op">$</span><span class="va">tidy.data</span>, 
  pairwise <span class="op">=</span> <span class="cn">TRUE</span>,
  parallel.core <span class="op">=</span> <span class="fu">parallel</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/r/parallel/detectCores.html">detectCores</a></span><span class="op">(</span><span class="op">)</span> <span class="op">-</span> <span class="fl">1</span>,
  verbose <span class="op">=</span> <span class="cn">TRUE</span>
<span class="op">)</span> <span class="op">%$%</span>
  <span class="va">pairwise.fst</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/rename.html">rename</a></span><span class="op">(</span>ASSIGNER_SIM02 <span class="op">=</span> <span class="va">FST</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="op">-</span><span class="va">N_MARKERS</span><span class="op">)</span></pre></div>
</div>
</div>
<div id="comparisons" class="section level1">
<h1 class="hasAnchor">
<a href="#comparisons" class="anchor"></a>Comparisons</h1>
<div id="empirical-dataset-10" class="section level2">
<h2 class="hasAnchor">
<a href="#empirical-dataset-10" class="anchor"></a>Empirical dataset</h2>
<div id="generate-a-summary-tibble" class="section level3">
<h3 class="hasAnchor">
<a href="#generate-a-summary-tibble" class="anchor"></a>Generate a summary tibble</h3>
<div class="sourceCode" id="cb32"><pre class="downlit">
<span class="va">fst.summary</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/warning.html">suppressWarnings</a></span><span class="op">(</span>
  <span class="va">assigner.fst</span> <span class="op">%&gt;%</span>
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">diversity.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">genodive.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">hierfstat.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">stampp.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">stratag.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">snprelate.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span>
<span class="op">)</span></pre></div>
<p>If you haven’t run the codes above:</p>
<div class="sourceCode" id="cb33"><pre class="downlit">
<span class="va">fst.summary</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"fst.summary.tsv"</span>, col_types <span class="op">=</span> <span class="st">"ccnnnnnnnn"</span><span class="op">)</span>
<span class="va">fst.summary</span></pre></div>
<pre><code>## # A tibble: 36 x 10
##    POP1  POP2  ASSIGNER DIVERSITY GENODIVE HIERFSTAT STAMPP STRATAG
##    &lt;chr&gt; &lt;chr&gt;    &lt;dbl&gt;     &lt;dbl&gt;    &lt;dbl&gt;     &lt;dbl&gt;  &lt;dbl&gt;   &lt;dbl&gt;
##  1 G100  G102     0.123     0.123    0.115     0.123  0.123   0.123
##  2 G100  G103     0.210     0.210    0.215     0.210  0.211   0.211
##  3 G100  G108     0.394     0.395    0.39      0.394  0.394   0.394
##  4 G100  G109     0.299     0.299    0.287     0.299  0.299   0.299
##  5 G100  G111     0.369     0.370    0.356     0.369  0.369   0.369
##  6 G100  G118     0.169     0.169    0.156     0.169  0.169   0.169
##  7 G100  G122     0.269     0.270    0.255     0.269  0.269   0.269
##  8 G100  G124     0.366     0.366    0.362     0.366  0.366   0.366
##  9 G102  G103     0.118     0.118    0.115     0.118  0.119   0.119
## 10 G102  G108     0.322     0.323    0.319     0.322  0.322   0.322
## # … with 26 more rows, and 2 more variables: SNPRELATE_MEAN &lt;dbl&gt;,
## #   SNPRELATE_WEIGHTED &lt;dbl&gt;</code></pre>
<p>If we highlight the first line, pops G100 and G102:</p>
<div class="sourceCode" id="cb35"><pre class="downlit">
<span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span><span class="op">(</span><span class="va">fst.summary</span>, <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/ranking.html">row_number</a></span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="fl">1L</span><span class="op">)</span></pre></div>
<pre><code>## # A tibble: 1 x 10
##   POP1  POP2  ASSIGNER DIVERSITY GENODIVE HIERFSTAT STAMPP STRATAG
##   &lt;chr&gt; &lt;chr&gt;    &lt;dbl&gt;     &lt;dbl&gt;    &lt;dbl&gt;     &lt;dbl&gt;  &lt;dbl&gt;   &lt;dbl&gt;
## 1 G100  G102     0.123     0.123    0.115     0.123  0.123   0.123
## # … with 2 more variables: SNPRELATE_MEAN &lt;dbl&gt;, SNPRELATE_WEIGHTED &lt;dbl&gt;</code></pre>
<p><strong>Gold Standard</strong>: HIERFSTAT 0.12</p>
<ul>
<li>min value: SNPRELATE_MEAN 0.08</li>
<li>max value: SNPRELATE_WEIGHTED 0.14</li>
<li>Weir and Cockerham mean Fst estimate: 0.036903 !!!</li>
<li>Weir and Cockerham weighted Fst estimate: 0.16222 !!!</li>
<li>that’s a bit scary…</li>
</ul>
</div>
<div id="generate-a-correlation-matrix" class="section level3">
<h3 class="hasAnchor">
<a href="#generate-a-correlation-matrix" class="anchor"></a>Generate a correlation matrix</h3>
<p>There’s obviously differences when we look at the pairwise comparisons separately. The difference between the approaches taken in the packages/software probably depends on numerous things:</p>
<ul>
<li>how common polymorphic markers are handle</li>
<li>how sample size differences are managed</li>
<li>missing data</li>
<li>rouding during steps of the codes</li>
</ul>
<p>Let’s look at it globally with a correlation matrix:</p>
<div class="sourceCode" id="cb37"><pre class="downlit">
<span class="va">fst.corr</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span><span class="op">(</span>x <span class="op">=</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">fst.summary</span>, <span class="op">-</span><span class="va">POP1</span>, <span class="op">-</span><span class="va">POP2</span><span class="op">)</span><span class="op">)</span>, <span class="fl">6</span><span class="op">)</span>
<span class="va">fst.corr</span></pre></div>
<pre><code>##                    ASSIGNER DIVERSITY GENODIVE HIERFSTAT   STAMPP  STRATAG
## ASSIGNER           1.000000  0.999998 0.997723  1.000000 0.999996 0.999996
## DIVERSITY          0.999998  1.000000 0.997635  0.999998 0.999995 0.999995
## GENODIVE           0.997723  0.997635 1.000000  0.997723 0.997702 0.997702
## HIERFSTAT          1.000000  0.999998 0.997723  1.000000 0.999996 0.999996
## STAMPP             0.999996  0.999995 0.997702  0.999996 1.000000 1.000000
## STRATAG            0.999996  0.999995 0.997702  0.999996 1.000000 1.000000
## SNPRELATE_MEAN     0.973732  0.974023 0.965324  0.973732 0.973953 0.973953
## SNPRELATE_WEIGHTED 0.996752  0.996691 0.998345  0.996752 0.996729 0.996729
##                    SNPRELATE_MEAN SNPRELATE_WEIGHTED
## ASSIGNER                 0.973732           0.996752
## DIVERSITY                0.974023           0.996691
## GENODIVE                 0.965324           0.998345
## HIERFSTAT                0.973732           0.996752
## STAMPP                   0.973953           0.996729
## STRATAG                  0.973953           0.996729
## SNPRELATE_MEAN           1.000000           0.962916
## SNPRELATE_WEIGHTED       0.962916           1.000000</code></pre>
<p>I prefer to look at it in a tibble…</p>
</div>
<div id="generate-a-tibble-for-correlation-results" class="section level3">
<h3 class="hasAnchor">
<a href="#generate-a-tibble-for-correlation-results" class="anchor"></a>Generate a tibble for correlation results</h3>
<div class="sourceCode" id="cb39"><pre class="downlit">
<span class="va">fst.corr.tibble</span> <span class="op">&lt;-</span> <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
    x <span class="op">=</span> <span class="va">fst.corr</span>, 
    na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
    relative <span class="op">=</span> <span class="cn">FALSE</span>, 
    pop.levels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"HIERFSTAT"</span>, <span class="st">"STRATAG"</span>, <span class="st">"ASSIGNER"</span>, <span class="st">"DIVERSITY"</span>, <span class="st">"STAMPP"</span>, <span class="st">"GENODIVE"</span>, <span class="st">"SNPRELATE_MEAN"</span>, <span class="st">"SNPRELATE_WEIGHTED"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span>
      <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ID1"</span>, <span class="st">"ID2"</span>, <span class="st">"CORRELATION"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/desc.html">desc</a></span><span class="op">(</span><span class="va">CORRELATION</span><span class="op">)</span><span class="op">)</span>
<span class="va">fst.corr.tibble</span></pre></div>
<pre><code>## # A tibble: 28 x 3
##    ID1       ID2       CORRELATION
##    &lt;ord&gt;     &lt;ord&gt;           &lt;dbl&gt;
##  1 ASSIGNER  HIERFSTAT        1   
##  2 STAMPP    STRATAG          1   
##  3 ASSIGNER  DIVERSITY        1.00
##  4 DIVERSITY HIERFSTAT        1.00
##  5 ASSIGNER  STAMPP           1.00
##  6 HIERFSTAT STAMPP           1.00
##  7 ASSIGNER  STRATAG          1.00
##  8 HIERFSTAT STRATAG          1.00
##  9 DIVERSITY STAMPP           1.00
## 10 DIVERSITY STRATAG          1.00
## # … with 18 more rows</code></pre>
<p>Very interesting results!</p>
</div>
<div id="figure-of-results" class="section level3">
<h3 class="hasAnchor">
<a href="#figure-of-results" class="anchor"></a>Figure of results</h3>
<p>Let’s plot the results:</p>
<div class="sourceCode" id="cb41"><pre class="downlit">
<span class="va">plot.fst</span> <span class="op">&lt;-</span> <span class="va">fst.summary</span> <span class="op">%&gt;%</span> 
  <span class="fu">tidyr</span><span class="fu">::</span><span class="fu"><a href="https://tidyr.tidyverse.org/reference/unite.html">unite</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">.</span>, col <span class="op">=</span> <span class="va">PAIRS</span>, <span class="va">POP1</span>, <span class="va">POP2</span>, sep <span class="op">=</span> <span class="st">"-"</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">tidyr</span><span class="fu">::</span><span class="fu"><a href="https://tidyr.tidyverse.org/reference/gather.html">gather</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">.</span>, key <span class="op">=</span> <span class="va">SOFTWARE</span>, value <span class="op">=</span> <span class="va">FST</span>, <span class="op">-</span><span class="va">PAIRS</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>
    SOFTWARE <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span>
      x <span class="op">=</span> <span class="va">SOFTWARE</span>, 
      levels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"HIERFSTAT"</span>, <span class="st">"ASSIGNER"</span>, <span class="st">"STAMPP"</span>, <span class="st">"STRATAG"</span>, <span class="st">"DIVERSITY"</span>, <span class="st">"GENODIVE"</span>, <span class="st">"SNPRELATE_WEIGHTED"</span>, <span class="st">"SNPRELATE_MEAN"</span><span class="op">)</span>, ordered <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span>

<span class="va">pairs.levels</span> <span class="op">&lt;-</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span><span class="op">(</span><span class="va">plot.fst</span>, <span class="va">PAIRS</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span><span class="op">(</span>FST <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/mean.html">mean</a></span><span class="op">(</span><span class="va">FST</span>, na.rm <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="va">FST</span><span class="op">)</span> <span class="op">%$%</span> 
  <span class="va">PAIRS</span></pre></div>
<pre><code>## `summarise()` ungrouping output (override with `.groups` argument)</code></pre>
<div class="sourceCode" id="cb43"><pre class="downlit">
<span class="va">under.the.sea.palette</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"#1C2344"</span>, <span class="st">"#163D7D"</span>, <span class="st">"#118386"</span>, <span class="st">"#89D6D6"</span>, <span class="st">"#6E783D"</span>, <span class="st">"#FC564F"</span>, <span class="st">"#901546"</span>, <span class="st">"#FFD521"</span><span class="op">)</span><span class="co">#, "#010101")</span>
<span class="va">plot.fst</span> <span class="op">%&lt;&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span><span class="op">(</span>PAIRS <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/factor.html">factor</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">PAIRS</span>, levels <span class="op">=</span> <span class="va">pairs.levels</span>, ordered <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span><span class="op">(</span>data <span class="op">=</span> <span class="va">.</span>, <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">FST</span>, y <span class="op">=</span> <span class="va">PAIRS</span>, colour <span class="op">=</span> <span class="va">SOFTWARE</span><span class="op">)</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/geom_jitter.html">geom_jitter</a></span><span class="op">(</span>alpha <span class="op">=</span> <span class="fl">0.8</span><span class="op">)</span> <span class="op">+</span>
  <span class="fu">ggplot2</span><span class="fu">::</span><span class="fu"><a href="https://ggplot2.tidyverse.org/reference/scale_manual.html">scale_colour_manual</a></span><span class="op">(</span>values <span class="op">=</span> <span class="va">under.the.sea.palette</span><span class="op">)</span></pre></div>
<p><img src="fst_comparisons_files/figure-html/plot%20the%20results-1.png" width="700"></p>
</div>
</div>
<div id="simulated-datasets-10" class="section level2">
<h2 class="hasAnchor">
<a href="#simulated-datasets-10" class="anchor"></a>Simulated datasets</h2>
<div id="sim_01-high-fst" class="section level3">
<h3 class="hasAnchor">
<a href="#sim_01-high-fst" class="anchor"></a>sim_01: high Fst</h3>
<p><strong>Generate a summary tibble:</strong></p>
<div class="sourceCode" id="cb44"><pre class="downlit">
<span class="va">fst.summary.sim01</span><span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/warning.html">suppressWarnings</a></span><span class="op">(</span>
  <span class="va">assigner.sim01.fst</span> <span class="op">%&gt;%</span>
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">diversity.sim01.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">genodive.sim01.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">hierfstat.sim01.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">stampp.sim01.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">stratag.sim01.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">snprelate.sim01.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_if</a></span><span class="op">(</span>.tbl <span class="op">=</span> <span class="va">.</span>, .predicate <span class="op">=</span> <span class="va">is.numeric</span>, .funs <span class="op">=</span> <span class="va">round</span>, <span class="fl">4</span><span class="op">)</span>
<span class="op">)</span></pre></div>
<div class="sourceCode" id="cb45"><pre class="downlit">
<span class="va">fst.summary.sim01</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"fst.summary.sim01.tsv"</span>, col_types <span class="op">=</span> <span class="st">"ccnnnnnnnn"</span><span class="op">)</span>
<span class="va">fst.summary.sim01</span></pre></div>
<pre><code>## # A tibble: 10 x 10
##    POP1  POP2  ASSIGNER_SIM01 DIVERSITY_SIM01 GENODIVE_SIM01 HIERFSTAT_SIM01
##    &lt;chr&gt; &lt;chr&gt;          &lt;dbl&gt;           &lt;dbl&gt;          &lt;dbl&gt;           &lt;dbl&gt;
##  1 POP_1 POP_2          0.514           0.514          0.514           0.514
##  2 POP_1 POP_3          0.481           0.481          0.481           0.481
##  3 POP_1 POP_4          0.425           0.425          0.425           0.425
##  4 POP_1 POP_5          0.410           0.410          0.410           0.410
##  5 POP_2 POP_3          0.412           0.412          0.412           0.412
##  6 POP_2 POP_4          0.370           0.370          0.370           0.370
##  7 POP_2 POP_5          0.360           0.360          0.360           0.360
##  8 POP_3 POP_4          0.356           0.356          0.356           0.356
##  9 POP_3 POP_5          0.341           0.341          0.341           0.341
## 10 POP_4 POP_5          0.301           0.301          0.301           0.301
## # … with 4 more variables: STAMPP_SIM01 &lt;dbl&gt;, STRATAG_SIM01 &lt;dbl&gt;,
## #   SNPRELATE_MEAN_SIM01 &lt;dbl&gt;, SNPRELATE_WEIGHTED_SIM01 &lt;dbl&gt;</code></pre>
<p><strong>Generate the correlation tibble:</strong></p>
<div class="sourceCode" id="cb47"><pre class="downlit">
<span class="va">fst.corr.tibble.sim01</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span><span class="op">(</span>x <span class="op">=</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">fst.summary.sim01</span>, <span class="op">-</span><span class="va">POP1</span>, <span class="op">-</span><span class="va">POP2</span><span class="op">)</span><span class="op">)</span>, <span class="fl">6</span><span class="op">)</span> <span class="op">%&gt;%</span> 
 <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
  x <span class="op">=</span> <span class="va">.</span>, 
  na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
  relative <span class="op">=</span> <span class="cn">FALSE</span>, 
  pop.levels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"HIERFSTAT_SIM01"</span>, <span class="st">"STRATAG_SIM01"</span>, <span class="st">"ASSIGNER_SIM01"</span>, <span class="st">"DIVERSITY_SIM01"</span>, <span class="st">"STAMPP_SIM01"</span>, <span class="st">"GENODIVE_SIM01"</span>, <span class="st">"SNPRELATE_MEAN_SIM01"</span>, <span class="st">"SNPRELATE_WEIGHTED_SIM01"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span>
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ID1"</span>, <span class="st">"ID2"</span>, <span class="st">"CORRELATION_SIM01"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/desc.html">desc</a></span><span class="op">(</span><span class="va">CORRELATION_SIM01</span><span class="op">)</span><span class="op">)</span>
<span class="va">fst.corr.tibble.sim01</span></pre></div>
<pre><code>## # A tibble: 28 x 3
##    ID1             ID2             CORRELATION_SIM01
##    &lt;ord&gt;           &lt;ord&gt;                       &lt;dbl&gt;
##  1 ASSIGNER_SIM01  DIVERSITY_SIM01                 1
##  2 ASSIGNER_SIM01  GENODIVE_SIM01                  1
##  3 DIVERSITY_SIM01 GENODIVE_SIM01                  1
##  4 ASSIGNER_SIM01  HIERFSTAT_SIM01                 1
##  5 DIVERSITY_SIM01 HIERFSTAT_SIM01                 1
##  6 GENODIVE_SIM01  HIERFSTAT_SIM01                 1
##  7 ASSIGNER_SIM01  STAMPP_SIM01                    1
##  8 DIVERSITY_SIM01 STAMPP_SIM01                    1
##  9 GENODIVE_SIM01  STAMPP_SIM01                    1
## 10 HIERFSTAT_SIM01 STAMPP_SIM01                    1
## # … with 18 more rows</code></pre>
</div>
<div id="sim_02-low-fst" class="section level3">
<h3 class="hasAnchor">
<a href="#sim_02-low-fst" class="anchor"></a>sim_02: low Fst</h3>
<p><strong>Generate a summary tibble:</strong></p>
<div class="sourceCode" id="cb49"><pre class="downlit">
<span class="va">fst.summary.sim02</span><span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/warning.html">suppressWarnings</a></span><span class="op">(</span>
  <span class="va">assigner.sim02.fst</span> <span class="op">%&gt;%</span>
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">diversity.sim02.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">genodive.sim02.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">hierfstat.sim02.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">stampp.sim02.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">stratag.sim02.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate-joins.html">full_join</a></span><span class="op">(</span><span class="va">snprelate.sim02.fst</span>, by <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"POP1"</span>, <span class="st">"POP2"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
    <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/mutate_all.html">mutate_if</a></span><span class="op">(</span>.tbl <span class="op">=</span> <span class="va">.</span>, .predicate <span class="op">=</span> <span class="va">is.numeric</span>, .funs <span class="op">=</span> <span class="va">round</span>, <span class="fl">4</span><span class="op">)</span>
<span class="op">)</span></pre></div>
<div class="sourceCode" id="cb50"><pre class="downlit">
<span class="va">fst.summary.sim02</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"fst.summary.sim02.tsv"</span>, col_types <span class="op">=</span> <span class="st">"ccnnnnnnnn"</span><span class="op">)</span>
<span class="va">fst.summary.sim02</span></pre></div>
<pre><code>## # A tibble: 10 x 10
##    POP1  POP2  ASSIGNER_SIM02 DIVERSITY_SIM02 GENODIVE_SIM02 HIERFSTAT_SIM02
##    &lt;chr&gt; &lt;chr&gt;          &lt;dbl&gt;           &lt;dbl&gt;          &lt;dbl&gt;           &lt;dbl&gt;
##  1 POP_1 POP_2         0.001           0.001          0.001           0.001 
##  2 POP_1 POP_3         0.0032          0.0032         0.0032          0.0032
##  3 POP_1 POP_4         0.0021          0.0021         0.0021          0.0021
##  4 POP_1 POP_5         0.0022          0.0022         0.0022          0.0022
##  5 POP_2 POP_3         0.0001          0.0001         0.0001          0.0001
##  6 POP_2 POP_4         0.0002          0.0002         0.0002          0.0002
##  7 POP_2 POP_5         0.0005          0.0005         0.0005          0.0005
##  8 POP_3 POP_4         0              -0.0006        -0.0006         -0.0006
##  9 POP_3 POP_5         0.0028          0.0028         0.0028          0.0028
## 10 POP_4 POP_5         0.0017          0.0017         0.0017          0.0017
## # … with 4 more variables: STAMPP_SIM02 &lt;dbl&gt;, STRATAG_SIM02 &lt;dbl&gt;,
## #   SNPRELATE_MEAN_SIM02 &lt;dbl&gt;, SNPRELATE_WEIGHTED_SIM02 &lt;dbl&gt;</code></pre>
<p><strong>Generate the correlation tibble:</strong></p>
<div class="sourceCode" id="cb52"><pre class="downlit">
<span class="va">fst.corr.tibble.sim02</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/stats/cor.html">cor</a></span><span class="op">(</span>x <span class="op">=</span> <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span><span class="op">(</span><span class="va">fst.summary.sim02</span>, <span class="op">-</span><span class="va">POP1</span>, <span class="op">-</span><span class="va">POP2</span><span class="op">)</span><span class="op">)</span>, <span class="fl">6</span><span class="op">)</span> <span class="op">%&gt;%</span> 
 <span class="fu">radiator</span><span class="fu">::</span><span class="fu"><a href="https://thierrygosselin.github.io/radiator/reference/distance2tibble.html">distance2tibble</a></span><span class="op">(</span>
  x <span class="op">=</span> <span class="va">.</span>, 
  na.diag <span class="op">=</span> <span class="cn">TRUE</span>, 
  relative <span class="op">=</span> <span class="cn">FALSE</span>, 
  pop.levels <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"HIERFSTAT_SIM02"</span>, <span class="st">"STRATAG_SIM02"</span>, <span class="st">"ASSIGNER_SIM02"</span>, <span class="st">"DIVERSITY_SIM02"</span>, <span class="st">"STAMPP_SIM02"</span>, <span class="st">"GENODIVE_SIM02"</span>, <span class="st">"SNPRELATE_MEAN_SIM02"</span>, <span class="st">"SNPRELATE_WEIGHTED_SIM02"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span>
  <span class="fu">magrittr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/magrittr/man/aliases.html">set_colnames</a></span><span class="op">(</span>x <span class="op">=</span> <span class="va">.</span>, value <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"ID1"</span>, <span class="st">"ID2"</span>, <span class="st">"CORRELATION_SIM02"</span><span class="op">)</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/arrange.html">arrange</a></span><span class="op">(</span><span class="fu">dplyr</span><span class="fu">::</span><span class="fu"><a href="https://dplyr.tidyverse.org/reference/desc.html">desc</a></span><span class="op">(</span><span class="va">CORRELATION_SIM02</span><span class="op">)</span><span class="op">)</span>
<span class="va">fst.corr.tibble.sim02</span></pre></div>
<pre><code>## # A tibble: 28 x 3
##    ID1             ID2             CORRELATION_SIM02
##    &lt;ord&gt;           &lt;ord&gt;                       &lt;dbl&gt;
##  1 DIVERSITY_SIM02 GENODIVE_SIM02                  1
##  2 DIVERSITY_SIM02 HIERFSTAT_SIM02                 1
##  3 GENODIVE_SIM02  HIERFSTAT_SIM02                 1
##  4 DIVERSITY_SIM02 STAMPP_SIM02                    1
##  5 GENODIVE_SIM02  STAMPP_SIM02                    1
##  6 HIERFSTAT_SIM02 STAMPP_SIM02                    1
##  7 DIVERSITY_SIM02 STRATAG_SIM02                   1
##  8 GENODIVE_SIM02  STRATAG_SIM02                   1
##  9 HIERFSTAT_SIM02 STRATAG_SIM02                   1
## 10 STAMPP_SIM02    STRATAG_SIM02                   1
## # … with 18 more rows</code></pre>
</div>
</div>
</div>
<div id="table-of-features" class="section level1">
<h1 class="hasAnchor">
<a href="#table-of-features" class="anchor"></a>Table of features</h1>
<p>The table timing was produced using the empirical dataset.</p>
<div class="sourceCode" id="cb54"><pre class="downlit">
<span class="va">summary.table</span> <span class="op">&lt;-</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/read_delim.html">read_tsv</a></span><span class="op">(</span>file <span class="op">=</span> <span class="st">"fst_comparisons_packages_features.tsv"</span>, col_types <span class="op">=</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/cols.html">cols</a></span><span class="op">(</span>.default <span class="op">=</span> <span class="fu">readr</span><span class="fu">::</span><span class="fu"><a href="https://readr.tidyverse.org/reference/parse_atomic.html">col_character</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">)</span>
<span class="fu">knitr</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/knitr/man/kable.html">kable</a></span><span class="op">(</span><span class="va">summary.table</span><span class="op">)</span> <span class="op">%&gt;%</span> 
  <span class="fu">kableExtra</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/kableExtra/man/kable_styling.html">kable_styling</a></span><span class="op">(</span>bootstrap_options <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"striped"</span>, <span class="st">"hover"</span>, <span class="st">"condensed"</span>, <span class="st">"responsive"</span><span class="op">)</span>, full_width <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></pre></div>
<pre><code>## Warning in kableExtra::kable_styling(., bootstrap_options = c("striped", :
## Please specify format in kable. kableExtra can customize either HTML or LaTeX
## outputs. See https://haozhu233.github.io/kableExtra/ for details.</code></pre>
<table class="table">
<colgroup>
<col width="22%">
<col width="11%">
<col width="11%">
<col width="7%">
<col width="7%">
<col width="7%">
<col width="9%">
<col width="11%">
<col width="11%">
</colgroup>
<thead><tr class="header">
<th align="left">FEATURES</th>
<th align="left">HIERFSTAT</th>
<th align="left">STRATAG</th>
<th align="left">ASSIGNER</th>
<th align="left">DIVERSITY</th>
<th align="left">STAMPP</th>
<th align="left">GENODIVE</th>
<th align="left">SNPRELATE</th>
<th align="left">VCFtools</th>
</tr></thead>
<tbody>
<tr class="odd">
<td align="left">Function</td>
<td align="left">pairwise.WCfst</td>
<td align="left">popStructTest</td>
<td align="left">fst_WC84</td>
<td align="left">diffCalc</td>
<td align="left">stamppFst</td>
<td align="left">F_st</td>
<td align="left">snpgdsFst</td>
<td align="left">–weir-fst-pop</td>
</tr>
<tr class="even">
<td align="left">W&amp;C 1984 Fst</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
</tr>
<tr class="odd">
<td align="left">Language</td>
<td align="left">R</td>
<td align="left">R, C</td>
<td align="left">R</td>
<td align="left">R, C++</td>
<td align="left">R</td>
<td align="left">Objective-C</td>
<td align="left">R, C++</td>
<td align="left">Perl, C++</td>
</tr>
<tr class="even">
<td align="left">Data</td>
<td align="left">object</td>
<td align="left">object</td>
<td align="left">both</td>
<td align="left">file</td>
<td align="left">object</td>
<td align="left">file</td>
<td align="left">object</td>
<td align="left">file</td>
</tr>
<tr class="odd">
<td align="left">Format</td>
<td align="left">hierfstat</td>
<td align="left">gtypes</td>
<td align="left">several</td>
<td align="left">genepop</td>
<td align="left">genlight</td>
<td align="left">several</td>
<td align="left">SNPRelate GDS</td>
<td align="left">VCF</td>
</tr>
<tr class="even">
<td align="left">Polymorphic markers</td>
<td align="left">yes</td>
<td align="left">?</td>
<td align="left">yes</td>
<td align="left">?</td>
<td align="left">yes</td>
<td align="left">?</td>
<td align="left">yes</td>
<td align="left">yes</td>
</tr>
<tr class="odd">
<td align="left">Tailor common markers</td>
<td align="left">yes</td>
<td align="left">?</td>
<td align="left">yes</td>
<td align="left">?</td>
<td align="left">yes</td>
<td align="left">?</td>
<td align="left">?</td>
<td align="left">yes</td>
</tr>
<tr class="even">
<td align="left">Output number of markers</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">Global fst</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
</tr>
<tr class="even">
<td align="left">Pairwise fst</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no*</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">Bootstrap individuals</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">Boostrap loci</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">CI</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">P-Value</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">Locus pairwise</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">Figures</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">Tibble</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">Full upper and lower matrix</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">Upper matrix</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">Lower matrix</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="odd">
<td align="left">Combo matrix (Fst + stats)</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">Fst markers</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
</tr>
<tr class="odd">
<td align="left">Fis</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
</tr>
<tr class="even">
<td align="left">Write</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">no</td>
<td align="left">yes</td>
</tr>
<tr class="odd">
<td align="left">Parallelize</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes*</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
</tr>
<tr class="even">
<td align="left">OS (linux, macOS, windows)</td>
<td align="left">all</td>
<td align="left">all</td>
<td align="left">all</td>
<td align="left">all</td>
<td align="left">all</td>
<td align="left">macOS</td>
<td align="left">all</td>
<td align="left">all</td>
</tr>
<tr class="odd">
<td align="left">Impacted by missingness</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">no</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="left">yes</td>
</tr>
<tr class="even">
<td align="left">Timing (sec)</td>
<td align="left">1234</td>
<td align="left">657</td>
<td align="left">49</td>
<td align="left">43</td>
<td align="left">39</td>
<td align="left">3</td>
<td align="left">0.245</td>
<td align="left">2*</td>
</tr>
</tbody>
</table>
<p><em>Note:</em></p>
<ul>
<li>VCFtools: we used only 2 populations and timing is inside VCFtools only, it doesn’t account for manipulations of output.</li>
<li>SNPRelate: No out-of-the-box pairwise Fst analysis, but very quick solution is proposed in this vignette.</li>
</ul>
</div>
<div id="conclusion" class="section level1">
<h1 class="hasAnchor">
<a href="#conclusion" class="anchor"></a>Conclusion</h1>
<p>You could go and look at the 36 pairwise comparisons, but the end of the story is very simple:</p>
<ul>
<li>For Fst, I’m definitely staying away from VCFtools and SNPRelate <code>MeanFst</code>.</li>
<li>
<code>SNPRelate</code> MeanFst as a systematic downward bias and the weighted estimate is usually a little higher.</li>
<li>Empirical and simulated data: <code>assigner</code> and <code>hierfstat</code> have equal values down to a very large number of decimals!</li>
<li>The packages show different colors with empirical and simulated data.
<ul>
<li>contrary to empirical data, with simulated data all the packages have the same results.</li>
<li>missing data is probably the stats driving those differences.</li>
<li>
<code>assigner</code> and <code>hierfstat</code> show consistent behaviors in the presence of missing data.</li>
<li>high or low Fst in simulated data: doesn’t impact the packages.</li>
<li>
<code>assigner</code> is different than the others: it transform <code><a href="https://rdrr.io/r/base/Arithmetic.html">-</a></code> Fst to 0.</li>
<li>it should be worth exploring the impact of missing data patterns and level of missingness on those Fst calculations…</li>
</ul>
</li>
</ul>
<p>In the absence of missing data, because overall Fst values are similar, in the end, it’s worth looking at:</p>
<ul>
<li>
<strong>speed</strong>: if this is an issue for you (e.g. if running multiple simulations, assignment analysis, etc).</li>
<li>
<strong>features</strong>: lots of differences between packages/software.</li>
</ul>
<p><em>Please let me know if I did something wrong or forgot to mention an interesting feature of your favorite package.</em></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>Developed by Thierry Gosselin.</p>
</div>

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

      </footer>
</div>

  


  </body>
</html>
