Plotting a phylogeny with the package ggtree (5 min)

Installing the package ggtree (10 min)

Exercise 1

  1. Download this phylogenetic tree of species from the Portal Project Teaching Database, by clicking on the link and saving it to your data-raw folder.
  2. Open the file by clicking on its name on the Files tab of RStudio’s Plots pane. It should look like this:
  3. Use the main function of the package ggtree (it is also called ggtree()) to visualize portal-tree.tre:
    ggtree(portal_tree)
    
  4. What differences can you note between a ggtree() plot and one generated with plot.phylo()?

The phylo class structure (10 min)

Connecting a phylogeny with data from a table

Exercise 2: 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.

Exercise 3: Connecting a tree and a table for your final project

  1. Connect the data table you chose for your final project to a tree with taxa on your table that you obtained from Open Tree of Life.
  2. Plot the tree and color the tips following one variable on the data table.

Homework - Exercise 4: 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.