Making YOUR Code Reproducible: Tips and Tricks

When we were putting together the British Ecological Society’s Guide to Reproducible Code we asked the community to send us their advice on how to make code reproducible. We got a lot of excellent responses and we tried to fit as many as we could into the Guide. Unfortunately, we ran out of space and there were a few that we couldn’t include.

Luckily, we have a blog where we can post all of those tips and tricks so that you don’t miss out. A massive thanks to everyone who contributed their tips and tricks for making code reproducible – we really appreciate it. Without further ado, here’s the advice that we were sent about making code reproducible that we couldn’t squeeze into the Guide:

Organising Code

©Leejiah Dorward

“Don’t overwrite data files. If data files change, create a new file. At the top of an analysis file define paths to all data files (even if they are not read in until later in the script).” – Tim Lucas, University of Oxford

“Keep one copy of all code files, and keep this copy under revision management.” – April Wright, Iowa State University

“Learn how to write simple functions – they save your ctrl c & v keys from getting worn out.” – Bob O’Hara, NTNU

For complex figures, it can make sense to pre-compute the items to be plotted as its own intermediate output data structure. The code to do the calculation then only needs to be adjusted if an analysis changes, while the things to be plotted can be reused any number of times while you tweak how the figure looks.” – Hao Ye, UC San Diego Continue reading

Making Your Research Reproducible with R

Post provided by Laura Graham

tweetReproducible research is important for three main reasons. Firstly, it makes it much easier to revisit a project a few months down the line, for example when making revisions to a paper which has been through peer review.

Secondly, it allows the reader of a published article to scrutinise your results more easily – meaning it is easier to show their validity. For this reason, some journals and reviewers are starting to ask authors to provide their code.

Thirdly, having clean and reproducible code available can encourage greater uptake of new methods. It’s much easier for users to replicate, apply and improve on methods if the code is reproducible and widely available

Throughout my PhD and Postdoctoral research, I have aimed to ensure that I use a reproducible workflow and this generally saves me time and helps to avoid errors. Along the way I’ve learned a lot through the advice of others, and trial and error. In this post I have set out a guide to creating a reproducible workflow and provided some useful tips. Continue reading

A Quickstart Guide for Building Your First R Package

Post Provided By DR IAIN STOTT

Iain is a Postdoctoral Researcher at the Max Planck Institute for Demographic Research and the MaxO Center at the University of Southern Denmark. He is currently working as a part of MaxNetAging, a Research Network on Aging. Iain was one of the presenters at the UK half of the Methods in Ecology and Evolution 5th Anniversary Symposium in April. You can watch his talk, ‘Methods Put to Good Use: Advances in population ecology through studies of transient demography’ here.

If you’re anything like me, you might experience a minor existential crisis weekly. As scientists we question the world around us and, for me, this questioning turns all-too-often inwards to my career. I don’t think that’s unusual: ask any scientist about their ‘Plan B’, and the extent to which it’s thought through is often astonishing (if a café-cum-cocktail bar ever opens in Glasgow’s West End, which specialises in drinks that employ spice blends from around the world and are named after old spice trade routes and trading vessels, then you know I’ve jumped the science ship).

Contributing open-source software is something which has made my work feel a bit more relevant and helped me feel a bit less of an imposter. I’ll explain why that is, give some tips to beginners for building a first R package, and hopefully persuade other (especially early-career) researchers to do the same. Continue reading