Since 2017, for every article I work on, I now do my best to release the code I used to obtain the results presented therein (see my research compendia in the software section). In my humble opinion, this is the least I can do cause the numerical part of a study (often a large part of my work) is relatively easy to reproduce, though it requires some time to master the tools to do so. As I now perceived reproducibility of my work as a duty, I felt guilty regarding a paper I published back in 2015.
In “On the integration of biotic interaction and environmental constraints at the biogeographical scale”, my co-authors and I extended the classical Theory of Island Biogeography (TIB) and the Trophic TIB1 published in 2011. We show that the TIB and the TTIB are generalizable using a Markov chain2 and I remember spending a lot of time on the numerical implementation, which is the reason why I had regrets not releasing the code.
As I still had some of the original code in a good shape, in 2017, I created a GitHub repository, biogeonet to share this code. But I did not have the energy to complete the code so one could easily reproduce the analysis in the paper. Two years after the first commit, I finally found the energy thanks to one of Olivier Gimenez’s tweets.
This makes me realize that I still have to finish cleaning up the code related to a paper we published back in 2016 (https://t.co/5LJLrLZdoW) on a similar topic. Not 100% done, but most functions are available and documented https://t.co/yMNnNnIWcl— Kevin Cazelles (@KCazelles) April 16, 2020
He basically reminded me the importance of releasing numerical implementations, even if they are >4 years old! I am aware that it is likely that nobody has ever tried to reproduce my study but it does not mean that I shouldn’t help a potential somebody to do so, and I am also aware that this person may be future me. Moreover, working on a computational study often means to find new computational tricks that can be helpful to others. For instance, for this study, I had used Rcpp for the first time, others in my discipline may have considered using it and so my code could be one more example of how to use it! Also, while working on this code, I discovered the power of working with bits and it was a very important trick for the entire implementation.
TIB and bits operators, … why? Because as I dealt with all possible combinations of presence/absence of $n$ species in a community, I figured it could be done using bits. Let say I have a 3 species community, working with presence/absence, there are $2^3 = 8$ combinations, let’s refer to them as $0, 1, … 7$. Now, let’s write them as 3 digits binary numbers, i.e $0 = 000$, $1 = 001$, … $7 = 111$ and let’s consider that first bit represents first species (species 1), the second bit, species 2 and the third bit species 3. In this case, the bit binary representation of the number of a given state holds all the presence/absence information I needed. Plus, summing the bits that equal 1 gave the species richness of a given community, as shown in the table below.
|State||Species 3||Species 2||Species 1||Total richness|
Dealing with bits is no less that one of the foundations of computer science, and so, in various programming languages, there are specific operators to manipulate them called bitewise operators and I have used them extensively for this study. For instance, I created a simple function to sum bits (see buildMarkov.cpp):
With the code available on GitHub, you can see all the bit tricks I have used! Also, as I had worked on a bunch of equations, I was looking for a way to publish them online and it turned out it is very easy to do so with pkgdown: I created a vignette and now you can see the entire supplementary information nicely formatted.
I’m happy that I took some time to do this even though it was not always easy to take some time to work on something that should have been done years ago… That said, going through this old code gave me ideas about possible future projects! Overall, I’d say it was pretty useful! So, well, I guess it is never too late to share your codes
Gravel et. al. (2011) 10.1111/j.1461-0248.2011.01667.x ↩︎
for more details, see the Supplementary Information. ↩︎