Function Repository Resource:

TaxonomyTree

Source Notebook

Visualize a taxonomy tree of either a single TaxonomicSpecies entity or a list of multiple entities

Contributed by: Dave Middleton

ResourceFunction["TaxonomyTree"][species]

gives a taxonomic tree of species, a single "TaxonomicSpecies" entity or a list of entities.

Details and Options

Organisms are classified into a nested hierarchy of taxa, from the broad kingdom and phylum levels down to the specific species level. Each step in the taxonomic sequence represents taxa that belong to the level above and contain subgroups representing the level below.
ResourceFunction["TaxonomyTree"] visualizes the taxonomy of a single or multiple biological organism's entities as a tree.
ResourceFunction["TaxonomyTree"] species arguments are constrained to "TaxonomicSpecies" entities.
Tree element labels are displayed by their CommonNames. This can be overridden with Tree Graphics options.
ResourceFunction["TaxonomyTree"] will automatically correct errors in the taxonomic sequence i.e. when multiple edges connect to a single tree element. TaxonomyTree will replace them by one edge, connected to its element's parent taxon.
A taxonomy tree of a single entity can be used to study the taxonomy of the species entity in detail. ResourceFunction["TaxonomyTree"] will visualize all nested hierarchies emerging subsequently out of a higher ranking root taxon down to the species and sub-species taxon level.
The number of taxonomic levels between the root- and the species taxon-level can be set with the option "Depth".
The "Depth" option should be a positive integer (default = 3). For example: "Depth" 4 for the "Species Sapiens" is the Order Primates in the taxonomic sequence: Domain Eukaryotes -> Kingdom Animals -> Phylum Chordates -> Class Mammals -> Order Primates -> Family Hominidae -> Genus Homo -> Species Sapiens.
A taxonomy tree of a list of multiple entities can be used to study the taxonomic relationship between entities. ResourceFunction["TaxonomyTree"] will visualize all levels in the taxonomic sequence of each entity in the list, but without their nested hierarchies. Therefore the option "Depth" will be ignored by ResourceFunction["TaxonomyTree"] if a list of entities is used as an argument.

Examples

Basic Examples (2) 

Visualize a taxonomy tree of the lion species:

In[1]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "PantheraLeo::d7933"]]
Out[1]=

Visualize a taxonomy tree of a list of animal and a plant species:

In[2]:=
ResourceFunction[
 "TaxonomyTree"][{Entity["TaxonomicSpecies", "CarcharodonCarcharias::k6mys"], Entity["TaxonomicSpecies", "Quercus::k2384"]}]
Out[2]=

Scope (1) 

TaxonomyTree can visualize a taxonomic tree of entities of different taxonomic ranks. For example the single-entity taxonomy of the corona virus family:

In[3]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "Coronaviridae::s2mb5"], "Depth" -> 2]
Out[3]=

Options (3) 

The "Depth" option determines the number of taxonomic levels between the root- and the argument species taxon.

Show available sub-species at depth 1:

In[4]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "PantheraLeo::d7933"], "Depth" -> 1]
Out[4]=

TaxonomyTree accepts the visualization options of a Tree. Higher tree-depths can benefit from a left-oriented TreeLayout and a larger AspectRatio:

In[5]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "CarcharodonCarcharias::k6mys"], TreeLayout -> Left, AspectRatio -> 2]
Out[5]=

TaxonomicSpecies entities are elements of the taxonomy tree and can be visualized instead of their CommonName using this Tree option:

In[6]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "Vitis::cd68g"], TreeLayout -> Left, "Depth" -> 1, TreeElementLabelFunction -> All -> Automatic]
Out[6]=

Applications (3) 

The complete human-to-apes lineage can be visualized by TaxonomyTree with a "Depth" setting of 5, starting with the species "homo sapiens":

In[7]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "HomoSapiens::4pydj"], "Depth" -> 5, TreeLayout -> Left, AspectRatio -> 2]
Out[7]=

The taxonomy tree of a list of 18 different berry species reveals the 6 different plant orders in which they are categorized:

In[8]:=
berries = {
Entity["TaxonomicSpecies", "RubusHispidus::np7nv"], 
Entity["TaxonomicSpecies", "Vaccinium::5fb97"], 
Entity["TaxonomicSpecies", "RubusChamaemorus::cww57"], 
Entity["TaxonomicSpecies", "VacciniumMacrocarpon::544q3"], 
Entity["TaxonomicSpecies", "Ribes::5m496"], 
Entity["TaxonomicSpecies", "Sambucus::rqm95"], 
Entity["TaxonomicSpecies", "Gaylussacia::7rj7r"], 
Entity["TaxonomicSpecies", "RubusLoganobaccus::5gqdr"], 
Entity["TaxonomicSpecies", "Moraceae::82v75"], 
Entity["TaxonomicSpecies", "RubusIdaeus::n46t9"], 
Entity["TaxonomicSpecies", "RubusChamaemorus::cww57"], 
Entity["TaxonomicSpecies", "FragariaXAnanassa::xk578"], 
Entity["TaxonomicSpecies", "IlexMucronata::224c7"], 
Entity["TaxonomicSpecies", "VacciniumVitisIdaea::hjfn2"], 
Entity["TaxonomicSpecies", "VacciniumMyrtillus::846w6"], 
Entity["TaxonomicSpecies", "PhysalisPeruviana::h2fnb"], 
Entity["TaxonomicSpecies", "RubusCaesius::83c58"], 
Entity["TaxonomicSpecies", "RubusHybridCultivar::tqwk4"]};
In[9]:=
ResourceFunction["TaxonomyTree"][berries, AspectRatio -> 1/2]
Out[9]=

TaxonomyTree replaced the two edges connecting the "rosids" sub-class to "flowering plants" class and "Streptophytina" sub-phylum, by one edge to the "flowering plants" class. The error originated in the loganberry taxonomic sequence. These errors will break the taxonomy tree when left unaddressed.


Visualize the taxonomy tree of a total of 5 random species, one per kingdom:

In[10]:=
species = {EntityClass["TaxonomicSpecies", "PlantSpecies"], EntityClass["TaxonomicSpecies", "MammalSpecies"], EntityClass["TaxonomicSpecies", "ArchaeanSpecies"], EntityClass["TaxonomicSpecies", "BacteriumSpecies"], EntityClass["TaxonomicSpecies", "VirusSpecies"]};
In[11]:=
ResourceFunction["TaxonomyTree"][#["RandomEntity"] & /@ species, TreeLayout -> Left]
Out[11]=

Possible Issues (6) 

TaxonomyTree only supports TaxonomicSpecies entities:

In[12]:=
ResourceFunction["TaxonomyTree"][Entity["FoodType", "Strawberry"]]
In[13]:=
ResourceFunction[
 "TaxonomyTree"][{Entity["FoodType", "Strawberry"], Entity["TaxonomicSpecies", "Vaccinium::5fb97"], Entity["FoodType", "Grape"]}]

A list of entities of length one is not valid:

In[14]:=
ResourceFunction[
 "TaxonomyTree"][{Entity["TaxonomicSpecies", "PantheraLeo::d7933"]}]

A "Depth" option value that is not an integer larger than 1, is not valid:

In[15]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "NorwalkVirus::23h5h"], "Depth" -> 0.5]

The "Depth" option will be ignored by TaxonomyTree when its argument is a list of entities:

In[16]:=
ResourceFunction[
 "TaxonomyTree"][{Entity["TaxonomicSpecies", "CarcharodonCarcharias::k6mys"], Entity["TaxonomicSpecies", "Quercus::k2384"]}, "Depth" -> 6]
Out[16]=

If the "Depth" option for a single-entity TaxonomyTree results in a tree of a size of more than 10,000 Elements, the Entity Framework may fail to download all values and will show an error message: . The tree size at which this download error may occur may vary by species. The error can be prevented by choosing a lower value for the “Depth” option.


TaxonomyTree will automatically correct errors in the taxonomic sequence. In some cases, this may result in an orphan taxon. For example:

In[17]:=
ResourceFunction["TaxonomyTree"][
 Entity["TaxonomicSpecies", "Lonicera::3gqqp"], TreeLayout -> Left, "Depth" -> 1]
Out[17]=

The orphan taxon issue will be resolved by setting a higher "Depth" value.

Neat Examples (3) 

Exploration of a species' taxonomy may start with a single entity. For example, the entire shark species taxonomy can be visualized by TaxonomyTree with a Depth setting of 7, commencing with the "great white shark" entity:

In[18]:=
sharks = ResourceFunction["TaxonomyTree"][
   Entity["TaxonomicSpecies", "CarcharodonCarcharias::k6mys"], "Depth" -> 7, TreeLayout -> Left];

TaxonomyTree preserves the entities in the tree, which allows one to select a subtree using a common name:

In[19]:=
TreeSelect[sharks, CommonName@TreeData@# == "Alopiidae" &]
Out[19]=

From the subtree, the entity objects can be copied to access their properties:

In[20]:=
TreeData /@ TreeLeaves@First@%
Out[20]=
In[21]:=
Entity["TaxonomicSpecies", "CetorhinusMaximus::93h8n"][
  "Dataset"] // DeleteMissing
Out[21]=

Publisher

Dave Middleton

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.2 – 21 February 2024
  • 1.0.1 – 12 February 2024
  • 1.0.0 – 07 February 2024

Related Resources

Author Notes

A multiple-entity taxonomy tree can result in disjoint trees because there is no root taxon connecting each super-kingdom available in the entity framework. TaxonomyTree introduced EntityClass["TaxonomicSpecies", All] as a root element, connecting all five super-kingdoms i.e. archaea, bacteria, eukaryotes and viruses as a solution to preserve the tree structure of the taxonomy.

License Information