Boosting my R efficiency by 300%: how a robot transformed my coding experience

Yes, you read that correctly—300% faster! That’s the remarkable leap in speed I’ve experienced in tackling my most common R programming challenges ever since I enlisted the help of a certain robotic companion to think alongside me.

That companion, as you might have guessed, is none other than ChatGPT. It’s become a trusted ally in various aspects of my research. While its prowess in aiding writing tasks has been widely discussed, I stumbled upon its true strength in assisting with my all-to-common R-isuses.

Let me start with a disclaimer: I consider myself fairly decent in R, but I’m perhaps a bit old-fashioned when it comes to embracing new ideas. My focus tends to be on results, sometimes neglecting code cleanliness or efficiency. These days, I find myself using R much less frequently than during my PhD, mainly for data manipulation, while also doing a lot of debugging of student code.

So, what magic does that friendly robot perform for me?

  • First off, ChatGPT is surprisingly adept at coding. Describe an issue, and it often churns out a correct, clear, and concise solution. For example, filtering a dataset based on specific criteria and then calculating averages across factor levels—a task more proficient R users might do from memory, but one I often find myself looking up the functions for.
  • Sure, I could turn to traditional help files and forums, but with ChatGPT, everything I need is in one place. I can formulate queries easily and get immediate responses, bypassing the need to scour forums or craft elaborate forum posts myself.
  • It gets even better when faced with a series of tasks. ChatGPT remembers previous actions within the same conversation, offering suggestions that build upon each other, simplifying code integration throughout a workflow.
  • When you get a suggestion back from ChatGPT that does not do exactly what you want it to do, you can simply describe where or what is not according to expectations, and ChatGPT immediately provides an alternative. I can even paste error codes directly from R, providing the robot with the context it needs to troubleshoot effectively. This way you can truly get into conversation with the robot, slowly but steadily molding and improving the code into your wishes.
  • If you provide the dataset and column names in your queries – or even snippets of your own code – the R-code generated by ChatGPT uses these names immediately when generating code, making it much easier to see what goes where.
  • Many of the tasks I encounter in R are ones I’ve tackled before. But digging through files to find previous solutions takes time, whereas ChatGPT provides guidance swiftly and efficiently.
  • I’ve noticed my students increasingly relying on ChatGPT as well, empowering them to resolve issues independently, reducing dependency on my assistance and time.

Fabulous, no? To me, this works pretty fluently, and allowed me to effectively speed up some daunting R-tasks, especially regarding data wrangling.

I also see very few drawbacks:

  • One concern is plagiarism, though in coding, this seems less of an issue compared to academic writing. Personally, I’ve borrowed code snippets without explicit credit before, though I do ensure proper attribution for packages used, so that has not changed much by switching to the robot.
  • There is a minor drawback that ChatGPT would not include the most recent developments in R. However, for most general tasks, for example regarding data wrangling, it does have access to everything we need.
  • There’s also the minor drawback of potentially limiting oneself to popular R packages, as ChatGPT may not be well-versed in lesser-known ones. But given my pragmatic approach to coding, as long as I achieve the desired outcomes, this limitation isn’t a major concern to me.

In conclusion, integrating ChatGPT into my coding workflow has streamlined my R programming endeavors, particularly in data wrangling. There might of course be a lot more to say about this, but I thought it might be beneficial to many to at least get the conversation going.

Now, I’m curious—have you used ChatGPT for your coding issues, and if so, what has been your experience? Are there drawbacks that I have – perhaps in my naivety – overlooked?

Posted in Science | Tagged , , , , | 2 Comments

PhD defense Jan Clavel

Another milestone coming up, as The 3D Lab-member Jan Clavel is making the final preparations for his PhD defense on February 5th!

Posted in General | Leave a comment

Tropical forest understory temperatures

New paper in Nature Communications: Ismaeel et al. (2024) Patterns of tropical forest understory temperatures.

It’s a thing we do at SoilTemp: create microclimate maps over large extents for all to use. We have done this before for soil temperature at the global scale (with 1 km resolution), and have done so for European forest understory temperatures at a breathtaking 25-m resolution.

And now we do that again! This time, for an area that has long been undersampled, but that is extremely important for global biodiversity and ecosystem functioning: tropical forests. As is the case for European forests, we can expect substantial temperature buffering under tropical forest canopies. How much, that has always been hard to say.

A microclimate sensor in the tropical rainforest of Congo, one of the many that allowed mapping forest understory microclimate across the pantropics. Pic: Matti Barthel

Not anymore, as we are proud to introduce a new paper in Nature Communications: patterns of tropical forest understory temperatures. The big thing: we created maps of tropical forest understory temperatures at a resolution of just a few tens of meters for all tropical forests, in South America, Africa, and Oceania!

As expected, forest understories were on average cooler (1.58°C, to be precise) than macroclimatic temperatures, and they were also buffered more (1.72°C lower diurnal – day/night – variation) than macroclimate.

We found significant spatiotemporal variation in daily temperature offsets in tropical forest understories in South America (left), Africa (middle) and Oceania (right).

Importantly, however, these averages hide significant spatiotemporal variation in that buffering, driven by patterns in macroclimate, vegetation structure, and topography. This variation holds some important information for understanding of these important ecosystems. For example, temperature buffering is stronger in regions with a distinct dry season. Although reduced rainfall is usually associated with higher temperatures, deep-rooting tropical species can for a long time still access water reserves and keep up their ‘airconditioning’ function, effectively creating a larger difference between understory and free-air temperatures.

The former works as long as these droughts remain within reasonable limits, of course, as climate change might very well push these forests over a threshold, making them lose their airconditioning function and rapidly increasing understory microclimatic temperatures. But that’s a story for another day.

An interesting observation for me is the fact that offsets across these tropical forests are usually not so large. On a daily basis, forest understory temperatures were often less than 1°C cooler than macroclimatic temperatures outside the forests. This was especially true in Indonesia, for example, but large swaths of South American and African rainforests are showing surprisingly small offset values as well.

This phenomenon can be attributed partially to the contrast between daily maximums (which tend to be cooler in forests) and minimums (warmer within forests). However, there might be other contributing factors at play. The high humidity prevalent in tropical regions is likely another significant influencer, dampening the intensity of microclimatic differences.

Nevertheless, despite these seemingly small variations, the consistent stability of temperatures throughout the year results in a cumulative effect. Over time, these incremental differences in temperature do add up, significantly impacting the overall energy input within the ecosystem.

The marked disparities and the crucial spatial diversity present across the pantropical regions underscore the significance of the maps we’ve crafted. These visual representations hold immense importance for anyone delving into the intricate workings of tropical forest understories, spanning from deciphering species distributions to comprehending litter decomposition dynamics. The relevance of such high-resolution microclimate products has already been elegantly demonstrated in understanding the distribution patterns of European forest understory plants. It’s only a matter of time before their paramount significance in tropical ecosystems is similarly illuminated.

The maps are freely available here! For now, at a 300 m-resolution, while we figure out a good way to share the 30-m resolution files open access. The latter are currently available upon request.

Posted in General | Tagged , , , , , , , | Leave a comment

Following plants in the crags: MIREN rock face survey

Join the new MIREN rock face survey

With long-term monitoring campaigns focussing on mountain roads and trails, and divergences to railroads and rivers, we are happy to announce that MIREN wants to tackle another – perhaps more unusual – linear disturbance in a new, global survey: rock climbing!

Rock climbing is in many respects similar to mountain roads and trails, with routes serving as linear disturbances and dispersal corridors across elevation gradients, with significant effects on the local vegetation. Nevertheless, cliff vegetation, and the influence of rock climbing on it, is pretty unique: rock faces often cover strong microclimatic gradients, resulting in a unique vegetation of species at either the warm or cool edge of their distribution. 
This unique vegetation often consists of (locally) rare species with very patchy distribution, and the passage of climbing routes over their habitat might thus have substantial impact. To map that impact, and its interaction with the effects of microclimate and climate change on species redistributions, we launch this new MIREN rock face survey, and you are welcome to join!

Wilder Kaiser, Austria – by Sarane Coen

Through the MIREN rock face survey we want to learn about global similarities and interregional differences between rock faces. To do this, we will set up permanent vegetation monitoring plots on and adjacent to existing rock climbing routes to monitor local plant species richness and community composition. Wherever possible, we will also measure rock face microclimate in comparison with the microclimate in the environment.

If you are interested in monitoring the vegetation on and along one or a few rock climbing routes in the upcoming summer, express your interest via this form. We are currently developing a standardized protocol that can be applied with minimal effort on any rock climbing route across the globe. If you want to be involved in finalizing that methodology, you can inform us through the same form!

Posted in General | Leave a comment

Take it to the higher order

New paper: Reynaert et al. (2023) Direct and higher-order interactions in plant communities under increasing weather persistence. Oikos

Let’s knock down an open door: interactions between species are key determinants of their performance. How well an individual is growing, or even if it is growing somewhere at all, hinges significantly on the surrounding organisms. They may vie for vital resources like air or sunlight, or conversely, aid one another by providing shade against the scorching rays of summer.

It should therefore not come as a surprise that there are thousands of papers on biotic interactions and their role in ecosystem functioning. However, while we have learned a lot about this over the last decades, there is still a surprisingly big hole in that literature. And that gaping hole is the result of inevitable oversimplification. That is, we have way too often – for the sake of simply being able to grasp ecology’s complexity – limited ourselves to direct interactions: A outcompetes B, C facilitates D. Yet, natural interactions seldom adhere to such straightforward narratives. Within an ecosystem, every individual is engaged—albeit to varying degrees—in an intricate dance of relationships, influencing and being influenced in turn.

Conceptual framework of higher order interactions (HOI)

Consider, for example, a scenario where a plant species, Plant A, attracts a specific herbivorous insect. Ordinarily, these herbivores might feed on Plant A, reducing its fitness. However, another plant species, Plant B, grows nearby and emits a molecule that attracts predators of the insects. As such, Plant B is indirectly helped by Plant A, as Insect B comes to eat Insect A. Or any other orientation of interactions.

These intricate and multifaceted relationships are labeled higher-order interactions (HOIs), a domain that has consumed a considerable amount of my time to get a hold of them in a convincing, statistically sound way. In a first attempt, we used real-world data from our mountain vegetation monitoring initiative (MIREN, http://www.mountaininvasions.org). However, that turned out very tricky, as there were simply way too many things changing at the same time to isolate something as complex as these higher-order interactions. After many an attempt, that idea was moved to the ‘death paper pile’.

In a new attempt, however, expertly led by UAntwerp-colleague Simon Reynaert and now published in Oikos, we took a different turn. We made use of a fascinating controlled experiment performed at our university campus, where precipitation was manipulated for 256 so-called mesocosms (in essence: pots with plants). What made this experiment especially useful was the uniform conditions experienced by all plants and pots, with precipitation being the sole variable—specifically, not even the AMOUNT, but the timing of rainfall.


An explanatory framework illustrating how changes in rainfall patterns, specifically increased variability, can impact the moisture levels in the soil. The grey bars represent daily rainfall amounts. Across all panels, the total precipitation matches historical weather averages (a).
When weather becomes more intense (b), it leads to less frequent but heavier rainfall episodes interspersed with extended periods of dryness, particularly during higher temperatures. This scenario could worsen the effects of droughts or floods.
On the other hand, when weather patterns become more persistent (c), it results in prolonged stretches of both dryness and wetness. This persistence might intensify the fluctuations in soil moisture content, potentially causing more extreme variations.
In both scenarios, there’s an increased likelihood of surpassing critical soil moisture levels. This excess—either too much or too little moisture—can detrimentally impact how ecosystems function.

By holding all these conditions constant, except for the precipitation regime, we could finally test how extreme events affect HOIs. And yes, lo and behold, our results indicate that species interactions (including HOIs) are an important determinant of plant performance under this increasing weather persistence. Moreover, the importance of these interactions changed substantially along the gradient of weather persistence, with  HOIs showing a shift towards stronger facilitation (or weaker competition) as drought persistence increased.

What was thus interesting, was that HOIs – at least partially – counteracted the effects of direct competition by neighbours, a conclusion that has been made in other studies as well. This could mean good news for biodiversity, as complex interactions could as such help support a higher diversity. However, a cautionary note is necessary: this counteractive effect was truly only partial, and could not overcome the increased drought intensity experienced in the most extreme precipitation regimes. In the end, species succumbed on their own to the extreme drought, and no positive higher-order interaction effect could prevent that from happening.

The complex interactions between individuals in such a meadow might help a bit in reducing the impact of extreme drought events.

There was a lot more to the results, of course, with perhaps the main conclusion that, indeed, HOIs are bloody complicated to analyze statistically. Even in this extremely controlled setting, picking up on these trends remained difficult. Thus, while ample papers have shown the theoretical importance of HOIs, we are still a long way from routineously integrating these complexities in our ecological analyses.

Posted in Belgium | Tagged , , , , , , , | Leave a comment

Blockchains and biodiversity

tl;dr: we will be looking for a database manager who wants to join our SoilTemp team, based in Antwerp, Belgium, with the main goal to make the database more accessible and more flexible. Knowledge of R required, of SQL a plus.

Blockchains and biodiversity? While these words are not too far away from each other in the dictionary, it is not that common to see them brought together in one sentence. Yet that is exactly what we aim to do in a new project that just got funded by Europe’s BiodivERsA+-funding scheme.

The project is called ForestWeb 3.0, and its goal is to help biodiversity with the power of the next generation of internet – Web 3.0, with its fancy developments like blockchain, and others.

An old birch tree in the Abisko area. Forest biodiversity like this requires long-term monitoring to observe subtle trends, but also real-time follow-up to catch sudden changes. In this project, we want to improve data availability for both.

So, how is that supposed to work? Well, biodiversity monitoring is all about data availability, and when we are talking about global monitoring, that is a LOT of data. This data is owned by LOTS of people, who spend blood, sweat, tears and a lot of chocolate and trail mix on collecting that data out in the real world. If we want to track the impacts of global change on biodiversity, we need all those monitoring initiatives – and especially the long-term ones – available in one place.

This is something we have been doing for a while in SoilTemp, especially for the vital microclimate data underlying any complete biodiversity monitoring initiative. However, there are three things to note about that:

  1. There is still a lot more data out there than we have currently brought together (especially given that data from the latest call is still frantically being processed).
  2. This data is not yet as available as one might hope. It still needs to be made open access, and the framework to access it should be made as user-friendly as possible.
  3. Not everyone is that keen to send their precious data to this unknown guy in Belgium, and understandably so. What if we can ensure people can store their data locally, and it’s only the LINK to that data that gets sent to the central database?

Points one and two are things we were planning to do anyway. Point three is where the blockchain and Web 3.0 come in, with these new technologies specifically designed to increase trust, transparency and control of the data, something we are all aspiring to.

ForestWeb 3.0 also wants to go further than that. Biodiversity is economically valuable, and increasingly so. Conserving that biodiversity is as well, and should be even more. What if we could increase that economical value for biodiverse land owners, to enhance the incentives to conserve nature? Doing so, however, requires good (and fast) monitoring of biodiversity and ecosystem services.

In part two of ForestWeb 3.0, we’ll explore how this can be done. First, we’ll work on digital twins of nature, tracking biodiversity and ecosystem functions (e.g., microclimate buffering) in quasi-real time to ensure we can put better numbers to the value of biodiversity. Second, we’ll work on systems to monetize that biodiversity, and give (financial) credit to the actual people putting in the actual effort to conserve and restore nature.

Our team at the University of Antwerp is in charge of that first part: bringing together as much biodiversity and microclimate data as possible (through SoilTemp), make it accessible (both open access ánd easy to use), and make that database able to talk to remote datasets (over blockchain) and to real-time sensor networks.

Think that sound cool? Well, then we’ll soon have an opportunity for you! We will be looking for a postdoc (or predoc) to join our team and work on making SoilTemp bigger and better! A position based in Antwerp, initially for 1,5 years, for a person who loves data and databases, and is proficient in R and at least eager to learn about SQL and Web 3.0. Contribution to – and potentially leading of – global SoilTemp-papers can become part of the deal. Interested, feel free to reach out already by email (lembrechtsjonas [.ad.] gmail.com)

Posted in Norway, Sweden | Tagged , , , , , , , | Leave a comment