Adrián A. Davín’s website

Longer articles

Simulating an Alien Fauna

phylogenetics

For the past few days, I have been simulating a population of “aliens” to create original teaching materials for an upcoming phylogenetics workshop. While I initially considered using the classic Caminalcules (a group of imaginary creatures created by the evolutionary biologist Joseph H. Camin in the 1960s), I decided to develop a dataset from scratch. To me, using an artificial dataset has at least two distinct pedagogical advantages:

  • Neutrality: Students cannot rely on prior biological knowledge, forcing them to focus strictly on character traits and data.
  • Ground Truth: As the creator, I have access to the “true” evolutionary history, including exact divergence times, fossil ages, and ancestral states.

My goal is to provide a modern framework for exploring parsimony, likelihood, and Bayesian inference, techniques that have mostly been developed in the field of phylogenetics since the original Caminalcules were conceived. My “aliens” remain nameless for now, but I hope that after some feedback from the workshop we can come up with something suitable together.

One of my alien creatures

Initially, I intended to generate the dataset exclusively through simulation. However, I realized that balancing a didactic, easy-to-analyze dataset with a fully automated pipeline would require several additional weeks of work. I ended up moving to a hybrid approach, simulating parts of my dataset and manually curating others. I did take the time to make something that was general enough so that I could possibly reuse it in a more ambitious setting or expand it into a proper scientific tool.

Coding (Phylosim)

The GitHub repository is here.

The tool itself is a collection of scripts (temporarily named Phylosim) with 3 main modes:

  • T : To simulate species trees The simulator produces phylogenetic trees using a birth-death process (so, forward in time). The idea that fossils “mostly” belong to extinct diversity that branches off the extant diversity is an important concept that for some reason is hard to grasp (even for reviewers of scientific publications, as I sadly had the opportunity to experience firsthand).

  • E: To simulate the evolution of traits On top of the species tree, you simulate the evolution of traits. I wrote two probabilistic models: the first one was to simulate discrete characters using Markov Chains. The user can define his own model, including as many states as he desires and different transition rates (in the same time units as the species tree). The second one was a model of Brownian evolution for continuous characters.

  • A: To manually add specific evolutionary events This is an additional function that would allow me to pinpoint a specific branch and a specific point within the branch to add a trait. All species descended from that point inherit that trait. Multiple traits can be added (creating nested evolution). This is the part where most of the manual curation happens.

Once the simulator was ready, I simulated a dataset of about 100 species, including extinct lineages. The resulting table looked something like this:

Node in the Species TreeBodyMouthEyesColor RColor GColor B
n1010120140100
n2111909590
n312220120150

Some of the traits were simulated with the E mode: the eyes were simulated using a discrete Markov Chain. The colors were simulated using 3 independent variables that evolved following a Brownian motion. The other traits were controlled manually to create an example of evolution that was suitable for the classroom.

Art

It is much more fun to work with something visual. For that reason, I decided to create sprites for the different aliens. I had some help here! My sister did the drawings in Procreate using her iPad. We divided the aliens into multiple parts that could be easily combined:

The challenge here was making all parts compatible, meaning that any head could fit any antenna, any body would match any side appendix, etc. Once we had about 5 or 6 sprites for each body part, the rest was a matter of combining them. I wrote a simple Python script that would take every row of the table with the different traits and combine them into a single image. The original images were all grayscale: the color variables that had evolved were incorporated by applying a tint to the images. These were some of the creatures resulting from this procedure:

Creatures of an alien fauna

Preparing the material

I took all the images and rendered each one using Gemini as a photorealistic image. The prompt I used was:

A photorealistic 3D render of the creature in the image, preserving all its features. The shot is a macro photograph on a solid white background with professional studio lighting. The skin is insect-like. Be as close as you can to the original image”

I thought of also including different textures as variables to evolve, such as slimy, hairy or spiky, but for the sake of simplicity I did not go that way

I sampled 23 leaves from the simulated tree and added 7 fossils. I was strategic with the sampling, trying to cover most of the interesting diversity we had generated and avoiding species that were too similar to each other. Fossils were sampled from extinct lineages (at the end of the branch, though an even better option would have been sampling somewhere before the extinction). Since the tree is measured in time units, I gave the different fossils an age.

For the sake of simplicity, I also changed the names of the species that were sampled (the simulator uses n1, n2, n3, etc to name the different nodes of the tree) to letters of the Latin alphabet for extant organisms and Greek letters for fossil ones. Using a package I wrote to plot trees (Phylustrator) I also generated phylogenies for the full tree, the extant tree and the sampled tree. Everything is in the GitHub repository in the form of Jupyter notebooks.

The sampled tree, including the images of the common ancestors all over the tree. It also includes the timeline on the left

I spent quite a while putting all the images together in a document using Affinity (in hindsight, I should have also written a script for this). I made two PDFs, one with the original renders and another one with the photorealistic images.

The original renders

I printed the resulting images onto photographic paper. I tried two sizes, A4 and A3. At A4 size the figures are too small and important details are lost, such as the number of eyes. However, the figures at A3 size are a little too big. The idea is that the students put all the leaves of the tree along the border of a big sheet of white cardboard and they draw the phylogeny.

Discussing the evolution of traits

It really helps to use these figures in which the different parts are represented with different colors. Using Phylustrator it is easy to generate these plots that indicate with small squares the points of transition from one body to another body.

In the exercise, the students need to recognize that the aliens have multiple parts and that these parts are homologous. Some of them are very easy to notice: the body shape, the side appendices, the tails, etc. By comparing them it is relatively easy at least to identify the major groups in the exercise (WKLH, NUSM, etc). The challenging part is (I think!) to reconstruct the deeper relationships between the groups.

There is one trait that is misleading on purpose: the eyes. The eyes evolve in the tree using the following model:

Eye evolution

The rate of change was set high enough to see multiple transitions across the tree. Due to the high rate of change, eyes (in isolation) are not a good trait to recover the phylogeny. There are a lot of cases of convergent evolution all over. The changes can be visualized in the following phylogeny:

Some pedagogical observations

I am planning to use the evolution of eyes to explain how probabilities are computed in a phylogeny, both forward for simulation and “backwards”, for likelihood inference. Many possibilities stem from here, from explaining the different parts of probability models to Felsenstein’s pruning algorithm. My goal is not a highly mathematical description of these ideas but a clear explanation that shows, first and foremost, the problems that scientists face when inferring phylogenies. I think very often lecturers spend way too much time focusing mostly on the techniques and algorithms that people have found to approach different challenges and not enough time presenting the problems themselves to the students. In my opinion, the correct thing to do is to invert the time devoted to each part: much more emphasis should be put on presenting the problems before they are given any solutions whatsoever.