Learning Objectives This week, students will:

  • work with newick Files
  • learn to read phylogenies into R.
  • access and list the elements of a phylo object
  • understand the relationship between lists and the phylo class as data structures.
  • plot phylogenies with ape::plot.phylo() and ggtree::ggtree()
  • customize phylogenetic plots with ggtree::ggtree()
  • obtain phylogenetic data from the Open Tree of Life
  • get dated phylogenies using datelife

Practice Objectives

  • Exploring the structure of an object

Non Objectives

  • simulate phylogenies
  • plot phylogenies with ape

Day 1: Reading and plotting phylogenies

Setup your RStudio project (5 min)

The newick format (10 min)

The package ape (5 min)

Read a phylogeny into R (10 min)

The phylo class structure (10 min)

Compare all outputs as applied to a data frame, such as surveys <- read.csv("../data-raw/surveys.csv")

Plot a phylogeny with the package ape (5 min)

Installing the package ggtree (10 min)

Plot a phylogeny with the package ggtree (5 min)

Display a scale (5 min)

Access Branch lengths (5 min)

Exercise 1: A scale for small_tree (10 min)

A mouse lemur (Primates) A kangaroo rat (Rodentia)

Plot tip labels (5 min)

Exercise 2: Tip labels for small_tree (5 min)



Day 2: Joining phylogenies to data tables

Setup your RStudio project (5 min)

Define a phylogenetic tree (10 min)

Both of these phylogenetic trees shows the relationship of the three domains of life (Bacteria, Archaea, and Eukarya), but the (a) rooted tree attempts to identify when various species diverged from a common ancestor, while the (b) unrooted tree does not.

Caption from original Figure 20.1𝐴.1 of LibreTexts

Tree representation: layouts (5 min))

ggtree(tr = portal_tree, layout = "roundrect")

-

ggtree(portal_tree, layout="slanted")
ggtree(portal_tree, layout="ellipse")
ggtree(portal_tree, layout="circular")
ggtree(portal_tree, layout="fan", open.angle=120)
ggtree(portal_tree, layout="fan", open.angle=15)
ggtree(portal_tree, layout="equal_angle")
ggtree(portal_tree, layout="daylight")

Subplots

Exercise: Tree representation.

  1. Try the following layouts on your tree of Portal species:
    ggtree(portal_tree, layout="ape")
    ggtree(portal_tree, layout="rectangular")
    ggtree(portal_tree, layout="roundrect")
    ggtree(portal_tree, layout="slanted")
    ggtree(portal_tree, layout="ellipse")
    ggtree(portal_tree, layout="dendogram")
    ggtree(portal_tree, layout="circular")
    ggtree(portal_tree, layout="radial")
    ggtree(portal_tree, layout="fan", open.angle = 90)
    ggtree(portal_tree, layout="equal_angle")
    ggtree(portal_tree, layout="daylight")
    ggtree(portal_tree, layout="unrooted")
    
  2. Create a plot containing a subplot for each one of them.
  3. As title for each subplot, indicate if the tree representation is rooted or unrooted.
  4. Which layout options display the same tree visualization?

Difference between phylogeny and taxonomy (5 min)

In a broad sense, taxonomy is the method used for organizing similar content into relevant groups. To put it even more broadly, taxonomy is how we classify things. From its conception, taxonomies have played an important role in biological science, where it has been largely used to organize the animal kingdom. Think of mammals vs. birds vs. reptiles and all the details in between: within the mammals group, we have cats, whales, apes, etc.; as we move further down the line, we have different species of apes such as gorilla, chimpanzees, etc. If you can visualize this as a tree of sorts, you’re already on the way to understanding what a taxonomy is at its basic level.

Text from Taxonomy management 101.

Connecting a phylogeny with data from a table

Exercise: A taxonomy table for small_tree

  1. Find the appropriate scientific group labels for each genus in small_tree using this tree as guide.
  2. Create a data frame with 3 columns:
    • a "label" column with the names of the tip labels of small_tree. Tip: extract the element "tip.label" from your phylo object to get a vector of tip labels that you can then join to the other vectors to create a data frame.
    • a "taxa" column with the scientific names of the group that each genus belongs to.
    • a "common_name" column with the common names of the group that each genus belongs to. Tip: use the function c() to create the vectors that will be columns "taxa" and "common_name"
  3. Join your tree and your table using left_join().
  4. Create two different tree plots using taxa and common name to color the tips of the tree.


Day 3:

Setup your RStudio project (5 min)

Review: Creating data Tables (40 min)

Intro to the data set (10 min)

Plot Data to tree tips (10 min)

Exercise: Mapping weight data from surveys CSV table to the portal tree (10 min)

  1. Get the average weight and hindfoot length per species.
  2. Create a new data frame that contains the taxonomy data plus the averaged data per species that you got on last question.
  3. Create two plots with data on the tips, one with the average weight and the other with average hindfoot length. Make sure to also add tip labels, formatted in italics.



Day 4

Review: Joining trees and data

Setup your RStudio project

Access elements of a "treedata" object

Plot node labels from a data table

Exercise: Node labels for the Portal tree

Plot node labels from a tree

Exercise: More node labels for the Portal tree

Getting trees from an Open data base