Coding in plant biology, who knew?

By Juliana Medeiros, Plant Biologist

Woman Coding

I never viewed myself as a math person, let alone a computer coder. I have always loved nature, animals and plants, these are what drew me to plant biology. But somehow, coding has become one of my favorite parts of my research at Holden Forests & Gardens. Looking back, maybe it isn’t too surprising. In 1977 my mother was one of the few women in the world working on a graduate degree in computer science, with 7-year-old me in tow as she taught her evening course. She jokes about how I used to doodle with my markers and then raise my little hand to ask and answer questions in her class, and now I often reflect on this as the first moments of joy I found in coding.

For me, science is about action, solving problems. So, it was a shock at first when I found that I can completely lose myself in coding. On the surface coding seems static, boring, you are just staring at a computer full of seemingly indecipherable strings of text. But I can spend an afternoon, a week, a month, going back and forth with the code, futzing and studying how to achieve the outcome that I can see in my mind. Coding actually has a special kind of hands-on feel. It is problem solving in its purest form. And, unlike most scientific problems, with coding I can see the results of my efforts emerge almost miraculously, after all the commands are correctly written, when that last missed comma is finally put in place.

In my work at Holden, I use coding primarily to analyze my data and draw figures showing the data we collect, although we also use coding to run devices that measure plant function. We use a coding language called “R”. It’s what’s known as an “object-oriented” language, meaning that you make objects, like a mathematical formula for example, and then you can manipulate the objects by putting them on a graph or passing the result of the formula on to another formula. R has become very popular with biologists because it has infinite capacity to develop new approaches, new methods for data. R is also popular because anyone can build an “R package” which is just a bit of code that simplifies complex coding problems by giving you standard formulas to use. In addition to being popular among scientists, R is used extensively by media outlets to create many of the beautiful graphs you see on webpages. Here you see code for a graph that I am making using a package called “ggplot”. A lot of the code looks confusing, but if you focus on the individual lines you can see familiar words, like the names of colors.

coding for biology using R

That code makes a figure showing data we collected on Rhododendron flowers. For this project, we were interested in how leaf and flower traits work together to help plants survive and reproduce in stressful environments. We looked at leaf traits (shown in green), and flower traits like the size of male reproductive structures (blue), the size of the female reproductive structures (gold) and the size of the flowering branch (pink). In this type of graph we can see that some traits are close together, for example leaf size and stigma diameter (shown as STIG_diam). Their close proximity shows that these traits are strongly correlated, such that Rhododendrons with bigger leaves will also have larger stigmas. Other traits are far apart, for example leaf size is far from all the male traits in blue, which means that Rhododendrons can change their leaf size without a change in their male traits. Why does this matter? The correlations between traits has a huge effect on the evolution of diversity, because it determines which traits might be mixed and matched as species adapt to new environments.

R code for biology

At the end of the day, coding brings me joy because it’s about solving the problem of how to show my data to the world. Sharing your data is the last, and perhaps most important step in science. Next time you see a beautiful computer graphic, remember, you are actually looking at computer code. Although this joy I have found in coding was totally unexpected, in retrospect, it clearly combines all the interests that I had as a marker doodling 7-year-old, and yes I am still raising my hand to ask questions about coding!

 

Dr. Medeiros is a research scientist at Holden Forests & Gardens focused on understanding the complex relationship between plants and climate, particularly the role of climate variability across space and time in shaping the diversity of plant life on Earth. Her work takes an interdisciplinary approach, combining methods from physiology, ecology and evolutionary biology to conduct comparative studies using genus Rhododendron as a model system. Prior to coming to Holden, Dr. Medeiros obtained her PhD in Plant Physiological Ecology at the University of New Mexico and completed a postdoctoral appointment in Plant Evolutionary Ecology at the University of Kansas.