The past three years I have been co-instructor for a graduate course at Northwestern: PSC450 “Field and Laboratory Methods in Plant Biology and Conservation.” It’s a survey-style course where first-year (Masters and Ph.D.)students are exposed to many different aspects of conservation science research. We rotate between several instructors for sections such as Field Methods, Databasing, Molecular Methods, and GIS.
I teach the Phylogenetics section, which includes a lecture on tree-thinking, terminology, and the methods for reconstructing phylogenies with traditional morphological methods and with molecular data. Much of the lecture and hands-on assignments are focused on phylogenetics as a tool for systematics. Because many of the students are in the program to study restoration ecology or population genetics, this year I wanted to showcase additional applications of phylogenetics to others areas of study. My lecture was inspired by the Modern Phylogenetic Comparative Methods book and covered ancestral state reconstruction, community phylogenetics, and basic phylogenetic comparative methods.
One trouble introducing students to phylogenetics, especially analytical methods, is that hands-on activities usually require the use of command line tools. There isn’t enough time to bring the students through a command-line tutorial, so demonstration of concepts often relies on tools developed by others. In the introduction to phylogenetics lesson, my students work through a hands-on assignments using phylogenetic tools available online (like those at Mobyle) or with graphical interfaces, like MEGA. The advantages of these platforms is the short learning curve, so that students can apply concepts quickly. Unfortunately, nothing similar exists for other applications of phylogenetics, such as comparative methods.
Enter Shiny, the platform for developing responsive, reactive apps in R that work in any browser. Apps are developed by implementing “server code,” much of which is R code that would normally be executed in a script, and “UI code” that determines the placement of features in HTML in the browser. There is also a free to use hosting service, shinyapps.io that I can publish apps to, from within RStudio. Because the R platform has the most active development for phylogenetic comparative methods, this is a perfect platform to present the material in an accessible way for students.
We try to keep a theme throughout the otherwise disconnected topics in the course by returning to the same organisms in each section– usually the evening primroses (Oenothera). I found a paper from 2007 which detected phylogenetic signal in climate preferences for Oenothera species in southwestern North America and recreated the phylogenetic reconstruction with Bayesian inference. Making use of the phylogenetic packages ape, phytools, and picante I wrote an app that demonstrated:
- The difference between simple regression and phylogenetic independent contrasts.
- Calculating Pagel’s lambda and Blomberg’s K and conducting hypothesis tests.
- Visualizing phylogenetic signal with a traitgram.
- The effect of phylogenetic uncertainty on comparative method analysis.
From start to finish the app took about six hours to develop. It is not the most polished of interfaces, but even the most basic UI has a good functional design. Most of the trouble I had was the age-0ld programming problem: keeping track of parentheses and curly braces, which I don’t usually have to deal with writing scripts in Python! The Shiny app tutorials and example galleries were very useful. It became much easier once I got used to the way the user input data interacts with the server code to generate output. Deploying the app with RStudio into shinyapps.io couldn’t have been easier. With a small class of eight students, I was in no danger of using up the CPU hours available in the free tier.
I got very good feedback from the students on the in-class assignment, especially the interactive nature of it. In the future they may be more likely to dedicate the time to understanding scripting in R now that they know the types of analysis they can do.
The app is available to view here, including the document the students used to walk through the analysis: https://mossmatters.shinyapps.io/Phylo_Comp_Methods_Shiny
The code for the app is available on GitHub: https://github.com/mossmatters/Phylo_Comp_Methods_Shiny