5  Taxonomic data

library(mia)
data("GlobalPatterns", package = "mia")
tse <- GlobalPatterns

Taxonomic information is a key part of analyzing microbiome data, and without it, any type of data analysis probably would not make much sense. However, the degree of detail of taxonomic information differs depending on the dataset and annotation data used.

Therefore, the mia package expects a loose assembly of taxonomic information and assumes certain key aspects:

5.1 Assigning taxonomy

There are a number of methods to assign taxonomic information. We like to give a short introduction about the methods available without ranking one over the other. This has to be your choice based on the result for the individual dataset.

5.1.1 DADA2

The dada2 package (Callahan et al. 2016) implements the assignTaxonomy() function, which implements the naive Bayesian classifier of the Ribosomal Database Project (Wang et al. 2007) and takes as input the ASV sequences associated with each row of data and a training dataset. For more information visit the dada2 homepage.

DADA2: High-resolution sample inference from Illumina amplicon data. Callahan et al. (2016). Nat Methods 13:581–583. doi:10.1038/nmeth.3869.
Naïve Bayesian classifier for rapid assignment of rRNA sequences into the new bacterial taxonomy. Wang et al. (2007). Appl Environ Microbiol 73:5261–5267. doi:10.1128/aem.00062-07.

5.1.2 DECIPHER

The DECIPHER package (Wright 2016; Wright 2020) implements the IDTAXA algorithm (Murali et al. 2018) to assign either taxonomic information or function information. For mia, only the first option is of interest for now and more information can be found on the DECIPHER website.

Using DECIPHER v2.0 to analyze big biological sequence data in R. Wright (2016). R J 8:352–359. doi:10.32614/RJ-2016-025.
DECIPHER: Tools for curating, analyzing, and manipulating biological sequences. Wright (2020). R package version 2.18.1.
IDTAXA: A novel approach for accurate taxonomic classification of microbiome sequences. Murali et al. (2018). Microbiome 6:140. doi:10.1186/s40168-018-0521-5.

5.2 Accessing taxonomy

5.2.1 Taxonomy ranks

checkTaxonomy() checks whether the taxonomic information is usable for mia.

checkTaxonomy(tse)
##  [1] TRUE

Since the rowData can contain other data, taxonomyRanks() will return the columns that mia assumes to contain the taxonomic information.

taxonomyRanks(tse)
##  [1] "Kingdom" "Phylum"  "Class"   "Order"   "Family"  "Genus"   "Species"

This can then be used to subset the rowData to columns as needed.

rowData(tse)[, taxonomyRanks(tse)]
##  DataFrame with 19216 rows and 7 columns
##             Kingdom        Phylum        Class        Order        Family
##         <character>   <character>  <character>  <character>   <character>
##  549322     Archaea Crenarchaeota Thermoprotei           NA            NA
##  522457     Archaea Crenarchaeota Thermoprotei           NA            NA
##  951        Archaea Crenarchaeota Thermoprotei Sulfolobales Sulfolobaceae
##  244423     Archaea Crenarchaeota        Sd-NA           NA            NA
##  586076     Archaea Crenarchaeota        Sd-NA           NA            NA
##  ...            ...           ...          ...          ...           ...
##  278222    Bacteria           SR1           NA           NA            NA
##  463590    Bacteria           SR1           NA           NA            NA
##  535321    Bacteria           SR1           NA           NA            NA
##  200359    Bacteria           SR1           NA           NA            NA
##  271582    Bacteria           SR1           NA           NA            NA
##               Genus                Species
##         <character>            <character>
##  549322          NA                     NA
##  522457          NA                     NA
##  951     Sulfolobus Sulfolobusacidocalda..
##  244423          NA                     NA
##  586076          NA                     NA
##  ...            ...                    ...
##  278222          NA                     NA
##  463590          NA                     NA
##  535321          NA                     NA
##  200359          NA                     NA
##  271582          NA                     NA

taxonomyRankEmpty() checks for empty values in the given rank and returns a logical vector of length(x).

all(!taxonomyRankEmpty(tse, rank = "Kingdom"))
##  [1] TRUE
table(taxonomyRankEmpty(tse, rank = "Genus"))
##  
##  FALSE  TRUE 
##   8008 11208
table(taxonomyRankEmpty(tse, rank = "Species"))
##  
##  FALSE  TRUE 
##   1413 17803

5.2.2 Get taxonomy labels

getTaxonomyLabels() is a multi-purpose function, which turns taxonomic information into a character vector of length(x).

getTaxonomyLabels(tse) |> head()
##  [1] "Class:Thermoprotei"               "Class:Thermoprotei_1"            
##  [3] "Species:Sulfolobusacidocaldarius" "Class:Sd-NA"                     
##  [5] "Class:Sd-NA_1"                    "Class:Sd-NA_2"

By default, this will use the lowest non-empty information to construct a string with the following scheme level:value. If all levels are the same, this part is omitted, but can be added by setting with.rank = TRUE.

# Features whose lowest classified rank is phylum
phylum <- getTaxonomyLabels(tse, with.rank = TRUE) |> startsWith("Phylum:")
getTaxonomyLabels(tse[phylum, ]) |> head()
##  [1] "Crenarchaeota"    "Crenarchaeota_1"  "Crenarchaeota_2" 
##  [4] "Actinobacteria"   "Actinobacteria_1" "Spirochaetes"
getTaxonomyLabels(tse[phylum, ], with.rank = TRUE) |> head()
##  [1] "Phylum:Crenarchaeota"    "Phylum:Crenarchaeota_1" 
##  [3] "Phylum:Crenarchaeota_2"  "Phylum:Actinobacteria"  
##  [5] "Phylum:Actinobacteria_1" "Phylum:Spirochaetes"

By default the return value of getTaxonomyLabels() contains only unique elements by passing it through make.unique(). This step can be omitted by setting make.unique = FALSE.

getTaxonomyLabels(tse[phylum, ], with.rank = TRUE, make.unique = FALSE) |> head()
##  [1] "Phylum:Crenarchaeota"  "Phylum:Crenarchaeota"  "Phylum:Crenarchaeota" 
##  [4] "Phylum:Actinobacteria" "Phylum:Actinobacteria" "Phylum:Spirochaetes"

To apply the loop resolving function resolveLoop() from the TreeSummarizedExperiment package (Huang 2020) within getTaxonomyLabels(), set resolve.loops = TRUE.

5.2.3 Feature information

The function getUnique() gives a list of unique features for the specified taxonomic rank.

getUnique(tse, rank = "Phylum") |> head()
##  [1] "Crenarchaeota"  "Euryarchaeota"  "Actinobacteria" "Spirochaetes"  
##  [5] "MVP-15"         "Proteobacteria"

With mapTaxonomy(), you can search information on certain taxonomic features from the taxonomy table. For instance, we can check all the features that match with “Escherichia”.

mapTaxonomy(tse, taxa = "Escherichia")
##  $Escherichia
##  DataFrame with 1 row and 7 columns
##             Kingdom         Phylum               Class             Order
##         <character>    <character>         <character>       <character>
##  249227    Bacteria Proteobacteria Gammaproteobacteria Enterobacteriales
##                     Family       Genus     Species
##                <character> <character> <character>
##  249227 Enterobacteriaceae Escherichia          NA

5.3 Prune the row tree

Subsetting is explained in detail in Chapter 8. However, if you’ve already subsetted your data, you may have noticed that the phylogenetic tree does not automatically update when using the [] operators. Although the linkages between rows and tree nodes remain correct, the tree retains its original, complex structure. You may be wondering how to update the tree to reflect the newly simplified data.

mia package functions subsetBy* and agglomerateBy* (see Chapter 9) include an update.tree parameter to handle this adjustment. Note that in agglomeration, each group is collapsed into the most recent common ancestor of its features. This requires that the groups are monophyletic; otherwise, the tree is removed with a warning. However, when using [], tree pruning must be done as an additional step.

Let’s start by selecting 5 arbitrary rows.

tse_sub <- tse[1:5, ]
tse_sub
##  class: TreeSummarizedExperiment 
##  dim: 5 26 
##  metadata(0):
##  assays(1): counts
##  rownames(5): 549322 522457 951 244423 586076
##  rowData names(7): Kingdom Phylum ... Genus Species
##  colnames(26): CL3 CC1 ... Even2 Even3
##  colData names(7): X.SampleID Primer ... SampleType Description
##  reducedDimNames(0):
##  mainExpName: NULL
##  altExpNames(0):
##  rowLinks: a LinkDataFrame (5 rows)
##  rowTree: 1 phylo tree(s) (19216 leaves)
##  colLinks: NULL
##  colTree: NULL

Even though we have only 5 rows, the tree still retains its original number of tips. To align the tree with the subsetted data, we can use the TreeSummarizedExperiment’s subsetByLeaf() function, which allows us to select specific tips from the tree, effectively pruning it to match the current subset of data.

tse_sub <- subsetByLeaf(tse_sub, rowLeaf = rownames(tse_sub))
tse_sub
##  class: TreeSummarizedExperiment 
##  dim: 5 26 
##  metadata(0):
##  assays(1): counts
##  rownames(5): 549322 522457 951 244423 586076
##  rowData names(7): Kingdom Phylum ... Genus Species
##  colnames(26): CL3 CC1 ... Even2 Even3
##  colData names(7): X.SampleID Primer ... SampleType Description
##  reducedDimNames(0):
##  mainExpName: NULL
##  altExpNames(0):
##  rowLinks: a LinkDataFrame (5 rows)
##  rowTree: 1 phylo tree(s) (5 leaves)
##  colLinks: NULL
##  colTree: NULL

Now, we can see that the phylogenetic tree has a simpler structure, including only the selected leaves.

5.4 Build a hierarchy tree

A hierarchy tree shows mapping between the taxonomic levels in taxonomic rank table (included in rowData), rather than the detailed phylogenetic relations. Usually, a phylogenetic tree refers to the latter which is why we here call the generated tree a “hierarchy tree”.

To create a hierarchy tree, getHierarchyTree() uses the information and returns a phylo object. Duplicate information from the rowData is removed.

getHierarchyTree(tse)
##  
##  Phylogenetic tree with 1645 tips and 1089 internal nodes.
##  
##  Tip labels:
##    Species:Cenarchaeumsymbiosum, Species:pIVWA5, Species:CandidatusNitrososphaeragargensis, Species:SCA1145, Species:SCA1170, Species:Sulfolobusacidocaldarius, ...
##  Node labels:
##    root:ALL, Kingdom:Archaea, Phylum:Crenarchaeota, Class:C2, Class:Sd-NA, Class:Thaumarchaeota, ...
##  
##  Rooted; includes branch length(s).

addHierarchyTree() builds the same tree and stores it as the rowTree of the object. The tree now has one leaf for each unique taxonomy.

tse_hierarchy <- addHierarchyTree(tse)
tse_hierarchy
##  class: TreeSummarizedExperiment 
##  dim: 19216 26 
##  metadata(0):
##  assays(1): counts
##  rownames(19216): 549322 522457 ... 200359 271582
##  rowData names(7): Kingdom Phylum ... Genus Species
##  colnames(26): CL3 CC1 ... Even2 Even3
##  colData names(7): X.SampleID Primer ... SampleType Description
##  reducedDimNames(0):
##  mainExpName: NULL
##  altExpNames(0):
##  rowLinks: a LinkDataFrame (19216 rows)
##  rowTree: 1 phylo tree(s) (1645 leaves)
##  colLinks: NULL
##  colTree: NULL

The implementation is based on the toTree() function from the TreeSummarizedExperiment package (Huang 2020).

TreeSummarizedExperiment: A S4 class for data with tree structures. Huang (2020). R package version 1.6.2.

5.5 Set taxonomy ranks

If your data includes taxonomy ranks that are not included by default in mia, you can set the ranks manually. By doing so, mia will be able to detect and utilize these taxonomy ranks from your data as expected.

Get default ranks of mia.

getTaxonomyRanks()
##   [1] "domain"       "superkingdom" "kingdom"      "phylum"      
##   [5] "class"        "order"        "family"       "genus"       
##   [9] "species"      "strain"

Set ranks to your own ranks. Remember that the order is meaningful.

# Set ranks
setTaxonomyRanks(c("test", "test2", "apple"))

# Get ranks
getTaxonomyRanks()
##  [1] "test"  "test2" "apple"

5.6 Visualizing phylogeny

The plotRowTree() function from the miaViz package provides a convenient way to visualize the phylogeny. For more advanced tree-data integration and visualization techniques, see Yu’s book Data Integration, Manipulation and Visualization of Phylogenetic Trees, especially the chapter on plotting trees with data (Yu 2023). Figure 5.1 shows the tree of the whole dataset.

Data integration, manipulation and visualization of phylogenetic trees. Yu (2023). Chapman & Hall/CRC. doi:10.1201/9781003279242.
Circular phylogenetic tree with a very large number of tips, one per feature, drawn without labels or colors.
Figure 5.1: Tree of all features in the GlobalPatterns dataset, visualized with plotRowTree().

By default, the visualized phylogeny has only a limited amount of information. To enrich the visualization, we can select the most abundant features and visualize to which phyla they belong (Figure 5.2).

# Get top features
top <- getTop(tse, top = 50L)

# Plot
plotRowTree(
    tse[top, ],
    tip.colour.by = "Phylum"
)
Circular phylogenetic tree with 50 tips, each drawn as a point colored by the phylum of the feature.
Figure 5.2: Phylogenetic tree of the 50 most abundant features in the GlobalPatterns dataset. Tips are colored by phylum.

In addition to nodes and tips, we can also color edges based on feature metadata. Below, we color edges based on phyla and illustrate the mean abundance of features by coloring tips. Moreover, we switch to a dendrogram layout (Figure 5.3).

# Calculate mean abundance
tse <- addQC(tse, by = "rows")
rowData(tse)[["log_mean"]] <- log(rowData(tse)[["mean"]])

# Plot
plotRowTree(
    tse[top, ],
    layout = "dendrogram",
    edge.colour.by = "Phylum",
    tip.colour.by = "log_mean"
) +
    labs(colour = "Phylum", fill = "Mean abundance (log)")
Rectangular dendrogram of 50 features in which the branches are colored by phylum and the tip points are colored on a continuous scale by log mean abundance.
Figure 5.3: Dendrogram of the 50 most abundant features in the GlobalPatterns dataset. Edges are colored by phylum and tips by the logarithm of the mean abundance of each feature.

5.7 Exercises

We use the Tengeler2020 dataset.

Solve the exercises in order, as each exercise continues from the previous one. Try to solve each exercise yourself before opening the solution.

TipExercise 1: Taxonomy table in mia

Goal: Identify what kind of taxonomy information mia expects.

Imagine three datasets whose rowData contain the following columns, in this order:

Dataset Columns of rowData
A Kingdom, Phylum, Class, Order, Family, Genus
B phylum, class, family
C Genus, Family, Order

Answer the following questions without writing any code. The beginning of this chapter will help you.

  1. In which of the datasets can mia use the taxonomy information? Why?

  2. The rowData of a dataset contains, in addition to the taxonomy columns, a column called GC_content. Which function would you use to get only the names of the taxonomy columns?

  3. Your data contains taxonomy ranks that are not among the default ranks of mia. How can you make mia recognize them?

  1. Datasets A and B. In dataset A, the columns have the expected names and are in the expected order. In dataset B, the names are written in lower case and some ranks are omitted, which is allowed as long as the order remains. In dataset C, the columns are in the wrong order, so the taxonomy cannot be used. You can check this with checkTaxonomy().

  2. taxonomyRanks() returns the columns of rowData that mia assumes to contain taxonomy information.

  3. Set your own ranks with setTaxonomyRanks(). The order of the ranks is meaningful, so give them from the highest to the lowest rank. You can check the current ranks with getTaxonomyRanks().

TipExercise 2: Explore the taxonomy information

Goal: Check and explore the taxonomy information of a dataset.

  1. Load the Tengeler2020 dataset from the mia package and store it in a variable called tse.

  2. Check whether the taxonomy information is usable for mia.

  3. List the taxonomy ranks of the data.

  4. Show the taxonomy table, that is, the columns of rowData that contain taxonomy ranks.

  5. How many features do not have information at the genus level?

  6. List the unique phyla in the data.

Useful functions: data(), mia::checkTaxonomy(), mia::taxonomyRanks(), rowData(), mia::taxonomyRankEmpty(), table(), mia::getUnique()

library(mia)

# 1. Load the data
data("Tengeler2020", package = "mia")
tse <- Tengeler2020

# 2. Check the taxonomy information
checkTaxonomy(tse)
##  [1] TRUE

# 3. Taxonomy ranks
taxonomyRanks(tse)
##  [1] "Kingdom" "Phylum"  "Class"   "Order"   "Family"  "Genus"

# 4. Taxonomy table
rowData(tse)[, taxonomyRanks(tse)]
##  DataFrame with 151 rows and 6 columns
##                                       Kingdom          Phylum
##                                   <character>     <character>
##  Bacteroides                         Bacteria   Bacteroidetes
##  Bacteroides_1                       Bacteria   Bacteroidetes
##  Parabacteroides                     Bacteria   Bacteroidetes
##  Bacteroides_2                       Bacteria   Bacteroidetes
##  Akkermansia                         Bacteria Verrucomicrobia
##  ...                                      ...             ...
##  Unidentified_Gastranaerophilales    Bacteria   Cyanobacteria
##  Halomonas                           Bacteria  Proteobacteria
##  Lachnoclostridium_4                 Bacteria      Firmicutes
##  Parabacteroides_8                   Bacteria   Bacteroidetes
##  Unidentified_Lachnospiraceae_14     Bacteria      Firmicutes
##                                                 Class               Order
##                                           <character>         <character>
##  Bacteroides                              Bacteroidia       Bacteroidales
##  Bacteroides_1                            Bacteroidia       Bacteroidales
##  Parabacteroides                          Bacteroidia       Bacteroidales
##  Bacteroides_2                            Bacteroidia       Bacteroidales
##  Akkermansia                         Verrucomicrobiae  Verrucomicrobiales
##  ...                                              ...                 ...
##  Unidentified_Gastranaerophilales     Melainabacteria Gastranaerophilales
##  Halomonas                        Gammaproteobacteria   Oceanospirillales
##  Lachnoclostridium_4                       Clostridia       Clostridiales
##  Parabacteroides_8                        Bacteroidia       Bacteroidales
##  Unidentified_Lachnospiraceae_14           Clostridia       Clostridiales
##                                                Family             Genus
##                                           <character>       <character>
##  Bacteroides                           Bacteroidaceae       Bacteroides
##  Bacteroides_1                         Bacteroidaceae       Bacteroides
##  Parabacteroides                   Porphyromonadaceae   Parabacteroides
##  Bacteroides_2                         Bacteroidaceae       Bacteroides
##  Akkermansia                      Verrucomicrobiaceae       Akkermansia
##  ...                                              ...               ...
##  Unidentified_Gastranaerophilales                                      
##  Halomonas                             Halomonadaceae         Halomonas
##  Lachnoclostridium_4                  Lachnospiraceae Lachnoclostridium
##  Parabacteroides_8                 Porphyromonadaceae   Parabacteroides
##  Unidentified_Lachnospiraceae_14      Lachnospiraceae        uncultured

# 5. Features with empty genus information
table(taxonomyRankEmpty(tse, rank = "Genus"))
##  
##  FALSE  TRUE 
##    134    17

# 6. Unique phyla
getUnique(tse, rank = "Phylum")
##  [1] "Bacteroidetes"   "Verrucomicrobia" "Proteobacteria"  "Firmicutes"     
##  [5] "Cyanobacteria"
  1. taxonomyRankEmpty() returns TRUE for the features whose genus is empty. The number of TRUE values in the table is the number of features without genus information.
TipExercise 3: Taxonomy labels

Goal: Create taxonomy labels and search for information on specific taxa.

  1. Create taxonomy labels for the features and show the first of them.

  2. Most labels start with Genus:, but some start with another rank, such as Family:. Why?

  3. Create the labels again, but do not make them unique. Show the first labels and compare them to the labels from step 1.

  4. Search the taxonomy table for the genus Akkermansia. To which phylum does it belong?

Useful functions: mia::getTaxonomyLabels(), head(), mia::mapTaxonomy()

# 1. Taxonomy labels
labels <- getTaxonomyLabels(tse)
head(labels)
##  [1] "Genus:Bacteroides"     "Genus:Bacteroides_1"   "Genus:Parabacteroides"
##  [4] "Genus:Bacteroides_2"   "Genus:Akkermansia"     "Genus:Bacteroides_3"

# 3. Labels that are not made unique
labels_not_unique <- getTaxonomyLabels(tse, make.unique = FALSE)
head(labels_not_unique)
##  [1] "Genus:Bacteroides"     "Genus:Bacteroides"     "Genus:Parabacteroides"
##  [4] "Genus:Bacteroides"     "Genus:Akkermansia"     "Genus:Bacteroides"

# 4. Search for Akkermansia
mapTaxonomy(tse, taxa = "Akkermansia")
##  $Akkermansia
##  DataFrame with 1 row and 6 columns
##                  Kingdom          Phylum            Class              Order
##              <character>     <character>      <character>        <character>
##  Akkermansia    Bacteria Verrucomicrobia Verrucomicrobiae Verrucomicrobiales
##                           Family       Genus
##                      <character> <character>
##  Akkermansia Verrucomicrobiaceae Akkermansia
  1. getTaxonomyLabels() uses the lowest rank that is not empty. Most features have genus information, but some are classified only to a higher rank, such as family or order. Because the labels come from different ranks, the rank is added to the label.

  2. Several features can belong to the same genus. By default, these duplicated labels are made unique by adding a number to the end, for example Genus:Bacteroides_1. With make.unique = FALSE, the labels are returned as they are, so the same label can appear several times.

  3. The output of mapTaxonomy() shows the full taxonomy of the matching features. The phylum is shown in the Phylum column.

TipExercise 4: Prune the tree

Goal: Update the phylogenetic tree after subsetting the data.

  1. Select the first 10 rows of tse with the [] operator and store the result in a variable called tse_sub.

  2. Print tse and tse_sub. How many leaves does the rowTree have in each of them?

  3. Prune the tree of tse_sub so that it includes only the selected features. Print tse_sub again. How many leaves does the tree have now?

  4. Why do you need to prune the tree yourself after subsetting with []?

Useful functions: TreeSummarizedExperiment::subsetByLeaf(), rownames()

# 1. Select the first 10 rows
tse_sub <- tse[1:10, ]

# 2. Number of leaves before pruning
tse
##  class: TreeSummarizedExperiment 
##  dim: 151 27 
##  metadata(0):
##  assays(1): counts
##  rownames(151): Bacteroides Bacteroides_1 ... Parabacteroides_8
##    Unidentified_Lachnospiraceae_14
##  rowData names(6): Kingdom Phylum ... Family Genus
##  colnames(27): A110 A111 ... A38 A39
##  colData names(4): patient_status cohort patient_status_vs_cohort
##    sample_name
##  reducedDimNames(0):
##  mainExpName: NULL
##  altExpNames(0):
##  rowLinks: a LinkDataFrame (151 rows)
##  rowTree: 1 phylo tree(s) (151 leaves)
##  colLinks: NULL
##  colTree: NULL
tse_sub
##  class: TreeSummarizedExperiment 
##  dim: 10 27 
##  metadata(0):
##  assays(1): counts
##  rownames(10): Bacteroides Bacteroides_1 ... Bacteroides_5
##    Parabacteroides_2
##  rowData names(6): Kingdom Phylum ... Family Genus
##  colnames(27): A110 A111 ... A38 A39
##  colData names(4): patient_status cohort patient_status_vs_cohort
##    sample_name
##  reducedDimNames(0):
##  mainExpName: NULL
##  altExpNames(0):
##  rowLinks: a LinkDataFrame (10 rows)
##  rowTree: 1 phylo tree(s) (151 leaves)
##  colLinks: NULL
##  colTree: NULL

# 3. Prune the tree
tse_sub <- subsetByLeaf(tse_sub, rowLeaf = rownames(tse_sub))
tse_sub
##  class: TreeSummarizedExperiment 
##  dim: 10 27 
##  metadata(0):
##  assays(1): counts
##  rownames(10): Bacteroides Bacteroides_1 ... Bacteroides_5
##    Parabacteroides_2
##  rowData names(6): Kingdom Phylum ... Family Genus
##  colnames(27): A110 A111 ... A38 A39
##  colData names(4): patient_status cohort patient_status_vs_cohort
##    sample_name
##  reducedDimNames(0):
##  mainExpName: NULL
##  altExpNames(0):
##  rowLinks: a LinkDataFrame (10 rows)
##  rowTree: 1 phylo tree(s) (10 leaves)
##  colLinks: NULL
##  colTree: NULL
  1. The number of leaves is shown on the rowTree line of the printed object. After subsetting with [], the tree still has the same number of leaves as the tree of the original data.

  2. After pruning, the tree has one leaf for each selected feature.

  3. The [] operator keeps the links between the rows and the tree nodes correct, but it does not change the tree itself.

TipExercise 5: Visualize the tree

Goal: Visualize the phylogenetic tree together with the taxonomy information.

  1. Visualize the phylogenetic tree of tse.

  2. Visualize the tree again and color the tips by Phylum.

  3. Visualize the tree with a dendrogram layout, and color the edges by Phylum.

Useful functions: miaViz::plotRowTree()

library(miaViz)

# 1. Visualize the tree
plotRowTree(tse)


# 2. Color tips by phylum
plotRowTree(tse, tip.colour.by = "Phylum")


# 3. Dendrogram layout with edges colored by phylum
plotRowTree(tse, layout = "dendrogram", edge.colour.by = "Phylum")

When the tips or edges are colored by phylum, you can see where the features of each phylum are located in the tree. If the features of a phylum are close to each other in the tree, the phylogeny and the taxonomy agree for that phylum.

Back to top