<!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>Bring multiple raw taxonomies into alignment — normalizeTaxa • taxonomizr</title><!-- 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="Bring multiple raw taxonomies into alignment — normalizeTaxa"><meta property="og:description" content="Combine the raw taxonomy of several taxa into a single matrix where each row corresponds to a taxa and each column a taxonomic level. Named taxonomic levels are aligned between taxa then any unspecified clades are combined between the named levels. Taxonomic levels between named levels are arbitrarily combined from most generic to most specific. Working from the data provided in the NCBI taxonomy results in ambiguities so results should be used with care."><!-- 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-reference-topic">
      <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">taxonomizr</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.10.6</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav"><li>
  <a href="../reference/index.html">Reference</a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu"><li>
      <a href="../articles/usage.html">taxonomizr usage</a>
    </li>
  </ul></li>
      </ul><ul class="nav navbar-nav navbar-right"><li>
  <a href="https://github.com/sherrillmix/taxonomizr/" class="external-link">
    <span class="fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul></div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Bring multiple raw taxonomies into alignment</h1>
    <small class="dont-index">Source: <a href="https://github.com/sherrillmix/taxonomizr/blob/HEAD/R/taxa.R" class="external-link"><code>R/taxa.R</code></a></small>
    <div class="hidden name"><code>normalizeTaxa.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>Combine the raw taxonomy of several taxa into a single matrix where each row corresponds to a taxa and each column a taxonomic level. Named taxonomic levels are aligned between taxa then any unspecified clades are combined between the named levels. Taxonomic levels between named levels are arbitrarily combined from most generic to most specific. Working from the data provided in the NCBI taxonomy results in ambiguities so results should be used with care.</p>
    </div>

    <div id="ref-usage">
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">normalizeTaxa</span><span class="op">(</span></span>
<span>  <span class="va">rawTaxa</span>,</span>
<span>  cladeRegex <span class="op">=</span> <span class="st">"^clade$|^clade\\.[0-9]+$|^$|no rank"</span>,</span>
<span>  rootFill <span class="op">=</span> <span class="st">"_ROOT_"</span>,</span>
<span>  lineageOrder <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div id="arguments">
    <h2>Arguments</h2>
    <dl><dt>rawTaxa</dt>
<dd><p>A list of vectors with each vector containing a named character vector with entries specifying taxonomy for a clade and names giving the corresponding taxonomic levels e.g. the output from <code><a href="getRawTaxonomy.html">getRawTaxonomy</a></code></p></dd>


<dt>cladeRegex</dt>
<dd><p>A regex to identify ambiguous taxonomic levels. In the case of NCBI taxonomy, these unidentified levels are all labelled "clade" and <code><a href="getRawTaxonomy.html">getRawTaxonomy</a></code> may attach a unique digit attach to the end for uniqueness.</p></dd>


<dt>rootFill</dt>
<dd><p>If a clade is upstream of the highest taxonomic level then it will be labeled with this prefix</p></dd>


<dt>lineageOrder</dt>
<dd><p>A vector giving an ordering for lineages from most specific to most generic. This should be unnecessary unless the taxonomy contains ambiguities e.g. one taxa goes from species to kingdom while another goes from genus to kingdom leaving it ambiguous whether genus or species is more specific</p></dd>

</dl></div>
    <div id="value">
    <h2>Value</h2>
    

<p>a matrix with a row for each taxa and a column for each taxonomic level</p>
    </div>
    <div id="see-also">
    <h2>See also</h2>
    <div class="dont-index"><p><code><a href="getRawTaxonomy.html">getRawTaxonomy</a></code></p></div>
    </div>

    <div id="ref-examples">
    <h2>Examples</h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="va">rawTaxa</span><span class="op">&lt;-</span><span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>   <span class="st">'81907'</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span>species <span class="op">=</span> <span class="st">"Alectura lathami"</span>, genus <span class="op">=</span> <span class="st">"Alectura"</span>,</span></span>
<span class="r-in"><span>     family <span class="op">=</span> <span class="st">"Megapodiidae"</span>, order <span class="op">=</span> <span class="st">"Galliformes"</span>, superorder <span class="op">=</span> <span class="st">"Galloanserae"</span>,</span></span>
<span class="r-in"><span>     infraclass <span class="op">=</span> <span class="st">"Neognathae"</span>, class <span class="op">=</span> <span class="st">"Aves"</span>, clade <span class="op">=</span> <span class="st">"Coelurosauria"</span>,</span></span>
<span class="r-in"><span>     clade.1 <span class="op">=</span> <span class="st">"Theropoda"</span>, clade.2 <span class="op">=</span> <span class="st">"Saurischia"</span>, clade.3 <span class="op">=</span> <span class="st">"Dinosauria"</span>,</span></span>
<span class="r-in"><span>     clade.4 <span class="op">=</span> <span class="st">"Archosauria"</span>, clade.5 <span class="op">=</span> <span class="st">"Archelosauria"</span>, clade.6 <span class="op">=</span> <span class="st">"Sauria"</span>,</span></span>
<span class="r-in"><span>     clade.7 <span class="op">=</span> <span class="st">"Sauropsida"</span>, clade.8 <span class="op">=</span> <span class="st">"Amniota"</span>, clade.9 <span class="op">=</span> <span class="st">"Tetrapoda"</span>,</span></span>
<span class="r-in"><span>     clade.10 <span class="op">=</span> <span class="st">"Dipnotetrapodomorpha"</span>, superclass <span class="op">=</span> <span class="st">"Sarcopterygii"</span>,</span></span>
<span class="r-in"><span>     clade.11 <span class="op">=</span> <span class="st">"Euteleostomi"</span>, clade.12 <span class="op">=</span> <span class="st">"Teleostomi"</span>, clade.13 <span class="op">=</span> <span class="st">"Gnathostomata"</span>,</span></span>
<span class="r-in"><span>     clade.14 <span class="op">=</span> <span class="st">"Vertebrata"</span>, subphylum <span class="op">=</span> <span class="st">"Craniata"</span>, phylum <span class="op">=</span> <span class="st">"Chordata"</span>,</span></span>
<span class="r-in"><span>     clade.15 <span class="op">=</span> <span class="st">"Deuterostomia"</span>, clade.16 <span class="op">=</span> <span class="st">"Bilateria"</span>, clade.17 <span class="op">=</span> <span class="st">"Eumetazoa"</span>,</span></span>
<span class="r-in"><span>     kingdom <span class="op">=</span> <span class="st">"Metazoa"</span>, clade.18 <span class="op">=</span> <span class="st">"Opisthokonta"</span>, superkingdom <span class="op">=</span> <span class="st">"Eukaryota"</span>,</span></span>
<span class="r-in"><span>     <span class="st">'no rank'</span> <span class="op">=</span> <span class="st">"cellular organisms"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>   <span class="st">'8496'</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span>species <span class="op">=</span> <span class="st">"Alligator mississippiensis"</span>,</span></span>
<span class="r-in"><span>     genus <span class="op">=</span> <span class="st">"Alligator"</span>, subfamily <span class="op">=</span> <span class="st">"Alligatorinae"</span>, family <span class="op">=</span> <span class="st">"Alligatoridae"</span>,</span></span>
<span class="r-in"><span>     order <span class="op">=</span> <span class="st">"Crocodylia"</span>, clade <span class="op">=</span> <span class="st">"Archosauria"</span>, clade.1 <span class="op">=</span> <span class="st">"Archelosauria"</span>,</span></span>
<span class="r-in"><span>     clade.2 <span class="op">=</span> <span class="st">"Sauria"</span>, clade.3 <span class="op">=</span> <span class="st">"Sauropsida"</span>, clade.4 <span class="op">=</span> <span class="st">"Amniota"</span>,</span></span>
<span class="r-in"><span>     clade.5 <span class="op">=</span> <span class="st">"Tetrapoda"</span>, clade.6 <span class="op">=</span> <span class="st">"Dipnotetrapodomorpha"</span>, superclass <span class="op">=</span> <span class="st">"Sarcopterygii"</span>,</span></span>
<span class="r-in"><span>     clade.7 <span class="op">=</span> <span class="st">"Euteleostomi"</span>, clade.8 <span class="op">=</span> <span class="st">"Teleostomi"</span>, clade.9 <span class="op">=</span> <span class="st">"Gnathostomata"</span>,</span></span>
<span class="r-in"><span>     clade.10 <span class="op">=</span> <span class="st">"Vertebrata"</span>, subphylum <span class="op">=</span> <span class="st">"Craniata"</span>, phylum <span class="op">=</span> <span class="st">"Chordata"</span>,</span></span>
<span class="r-in"><span>     clade.11 <span class="op">=</span> <span class="st">"Deuterostomia"</span>, clade.12 <span class="op">=</span> <span class="st">"Bilateria"</span>, clade.13 <span class="op">=</span> <span class="st">"Eumetazoa"</span>,</span></span>
<span class="r-in"><span>     kingdom <span class="op">=</span> <span class="st">"Metazoa"</span>, clade.14 <span class="op">=</span> <span class="st">"Opisthokonta"</span>, superkingdom <span class="op">=</span> <span class="st">"Eukaryota"</span>,</span></span>
<span class="r-in"><span>     <span class="st">'no rank'</span> <span class="op">=</span> <span class="st">"cellular organisms"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>   <span class="st">'38654'</span> <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span>species <span class="op">=</span> <span class="st">"Alligator sinensis"</span>,</span></span>
<span class="r-in"><span>     genus <span class="op">=</span> <span class="st">"Alligator"</span>, subfamily <span class="op">=</span> <span class="st">"Alligatorinae"</span>, family <span class="op">=</span> <span class="st">"Alligatoridae"</span>,</span></span>
<span class="r-in"><span>     order <span class="op">=</span> <span class="st">"Crocodylia"</span>, clade <span class="op">=</span> <span class="st">"Archosauria"</span>, clade.1 <span class="op">=</span> <span class="st">"Archelosauria"</span>,</span></span>
<span class="r-in"><span>     clade.2 <span class="op">=</span> <span class="st">"Sauria"</span>, clade.3 <span class="op">=</span> <span class="st">"Sauropsida"</span>, clade.4 <span class="op">=</span> <span class="st">"Amniota"</span>,</span></span>
<span class="r-in"><span>     clade.5 <span class="op">=</span> <span class="st">"Tetrapoda"</span>, clade.6 <span class="op">=</span> <span class="st">"Dipnotetrapodomorpha"</span>, superclass <span class="op">=</span> <span class="st">"Sarcopterygii"</span>,</span></span>
<span class="r-in"><span>     clade.7 <span class="op">=</span> <span class="st">"Euteleostomi"</span>, clade.8 <span class="op">=</span> <span class="st">"Teleostomi"</span>, clade.9 <span class="op">=</span> <span class="st">"Gnathostomata"</span>,</span></span>
<span class="r-in"><span>     clade.10 <span class="op">=</span> <span class="st">"Vertebrata"</span>, subphylum <span class="op">=</span> <span class="st">"Craniata"</span>, phylum <span class="op">=</span> <span class="st">"Chordata"</span>,</span></span>
<span class="r-in"><span>     clade.11 <span class="op">=</span> <span class="st">"Deuterostomia"</span>, clade.12 <span class="op">=</span> <span class="st">"Bilateria"</span>, clade.13 <span class="op">=</span> <span class="st">"Eumetazoa"</span>,</span></span>
<span class="r-in"><span>     kingdom <span class="op">=</span> <span class="st">"Metazoa"</span>, clade.14 <span class="op">=</span> <span class="st">"Opisthokonta"</span>, superkingdom <span class="op">=</span> <span class="st">"Eukaryota"</span>,</span></span>
<span class="r-in"><span>     <span class="st">'no rank'</span> <span class="op">=</span> <span class="st">"cellular organisms"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu">normalizeTaxa</span><span class="op">(</span><span class="va">rawTaxa</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       _ROOT_.1             superkingdom superkingdom.1 kingdom   kingdom.1  </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "cellular organisms" "Eukaryota"  "Opisthokonta" "Metazoa" "Eumetazoa"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "cellular organisms" "Eukaryota"  "Opisthokonta" "Metazoa" "Eumetazoa"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "cellular organisms" "Eukaryota"  "Opisthokonta" "Metazoa" "Eumetazoa"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       kingdom.2   kingdom.3       phylum     subphylum  subphylum.1 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Bilateria" "Deuterostomia" "Chordata" "Craniata" "Vertebrata"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "Bilateria" "Deuterostomia" "Chordata" "Craniata" "Vertebrata"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "Bilateria" "Deuterostomia" "Chordata" "Craniata" "Vertebrata"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       subphylum.2     subphylum.3  subphylum.4    superclass     </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Gnathostomata" "Teleostomi" "Euteleostomi" "Sarcopterygii"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "Gnathostomata" "Teleostomi" "Euteleostomi" "Sarcopterygii"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "Gnathostomata" "Teleostomi" "Euteleostomi" "Sarcopterygii"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       superclass.1           superclass.2 superclass.3 superclass.4</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Dipnotetrapodomorpha" "Tetrapoda"  "Amniota"    "Sauropsida"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "Dipnotetrapodomorpha" "Tetrapoda"  "Amniota"    "Sauropsida"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "Dipnotetrapodomorpha" "Tetrapoda"  "Amniota"    "Sauropsida"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       superclass.5 superclass.6    superclass.7  superclass.8 superclass.9</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Sauria"     "Archelosauria" "Archosauria" "Dinosauria" "Saurischia"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "Sauria"     "Archelosauria" "Archosauria" NA           NA          </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "Sauria"     "Archelosauria" "Archosauria" NA           NA          </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       superclass.10 superclass.11   class  infraclass   superorder    </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Theropoda"   "Coelurosauria" "Aves" "Neognathae" "Galloanserae"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  NA            NA              NA     NA           NA            </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 NA            NA              NA     NA           NA            </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       order         family          subfamily       genus      </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Galliformes" "Megapodiidae"  NA              "Alectura" </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "Crocodylia"  "Alligatoridae" "Alligatorinae" "Alligator"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "Crocodylia"  "Alligatoridae" "Alligatorinae" "Alligator"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       species                     </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 81907 "Alectura lathami"          </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 8496  "Alligator mississippiensis"</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 38654 "Alligator sinensis"        </span>
</code></pre></div>
    </div>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
    </nav></div>
</div>


      <footer><div class="copyright">
  <p></p><p>Developed by Scott Sherrill-Mix.</p>
</div>

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

      </footer></div>

  


  

  </body></html>

