Italic species names in Mendeley exported *.bib files

I stumbled upon this annoying problem with my reference manager Mendeley: while it is fully capable of italicising journal names where necessary, it lacks the ability to italicise species names.

Screen Shot 2017-08-09 at 07.24.18.png

An easy solution is to simply use the HTML code for italic font:

Screen Shot 2017-08-09 at 07.26.18.png

And there you go, now the species name will be italicised when you let Mendeley automatically generate a reference list in, say, MS Word. However, in case you export your references as *.bib file to use it in LaTeX you will find that the HTML code was not translated correctly and thus your References will look like this:

Screen Shot 2017-08-09 at 07.58.03.png

Well, that isn’t useful at all. Fortunately, some little programming can help here. The following code, provided by Kathy Lam (see here), opens the exported *.bib file,  searches for the italics HTML code and replaces it with the correct LaTeX code.

If you want to run the code on your Mac, simply copy the following code to a text file:


#!/usr/bin/python

# By: Kathy Lam
# Date: January 11, 2016
# Purpose: Replace all instances of "<i>" with "\textit{"
# and "</i>" with "}" in bibtex file generated by Mendeley

oldbib = open("bibliography.bib", "r")
newbib = open("new_bibliography.bib", "w")

for line in oldbib:
    if line.startswith("title"):
        if "<i>" in line:
            fixed_open_tags = line.replace("<i>", "\\textit{")
            fixed_both = fixed_open_tags.replace("</i>", "}")
            newbib.write(fixed_both)
        else:
            newbib.write(line)
    else:
        newbib.write(line)

Replace bibliography.bib with the name of your *.bib file. Save this text file as a *.py file. Then, to make it executable, change over to the Terminal and type chmod +x FILE.py, where FILE is the name of the text file you just created. Finally, put the python file and your bib file in the same directory and then double click the python file. All reference should be fixed now. Let’s see:

Screen Shot 2017-08-09 at 08.13.23.png

Thanks Kathy! And good luck everyone with fixing your references.

By the way, there is an even faster way, see Ozan’s comment.

Advertisements

Julia – The first contact

Today I tried Julia for the first time. I have read about it before, and kept considering whether or not it is worth learning another programming language (see e.g. Should I learn new programming langauge Julia?). And there are many thoughtful comments online on the benefits of Julia compared to other popular high-level programming languages like R, Python, MATLAB, etc. (here, or here), but there are also critical voices (like here). In any case, I decided to have a look at it anyway. My background is in R, so learning Julia should not be too much of a problem. Right?

First, I installed Julia directly from the developers’ website. But, you can also use homebrew to setup Julia. After installation, Julia is immediately accessible through the terminal. 

Screen Shot 2017-08-06 at 11.41.33.png

While I have no problems using the terminal, I still prefer a good IDE. Yeah, I am that kind of person. Previously, I used RStudio and texstudioand am very happy with the additional functionality an IDE provides. I decided to install Juno, which is an extension for the Atom text editor. Simply search and install the uber-junopackage within the Atom editor. It takes a while to load install all the dependencies. Once this is done a new Julia session is initiated. This first start up will also take a few moments.

Hacking 2+2 into the console results in 4. Good, the first test was successful. Now, on to something more adventures. Plotting. I know, this might be too advanced for the first day, but hey, in R plotting belongs to the core functions, and enjoy plotting my data and results. Simply type plot(1:10) in an R console and a plot will appear somewhere.

Screen Shot 2017-08-06 at 11.53.11

Great. So, how to do this in Julia? The Julialang website offers three different options for plotting: Plots, PyPlot, and Gadfly. In order they are the generic way of plotting in Julia, a variant relying on Python's matplotlib, and one that is similar to R's ​ ggplot2 . (I really like ggplot2 a lot, and in combination with cowplot you can make really nice plots, so I guess, in the long run, I will stick with making plots in R).

First, install the Plots package, then call it for the session by using using and then let us plot 2 sets of data each with 10 random numbers:

Pkg.add("Plots")
using Plots
plot(rand(10,2))

And here we go. A quick way to plot:

Screen Shot 2017-08-07 at 17.58.22.pngInterestingly, the created figure is interactive. You can zoom in on data, and pan around. That’s certainly different from the generic R plot.

These first steps have definitely made me interested in exploring Julia more. Less for plotting, but more for using it as my go to agent-based modelling language.

Open questions about culture

I found my notes with the big questions and controversies, which came up at the Culture Conference I mentioned earlier. I think the most prominent one was:

How do we define cultural evolution?

Of course, it would ideal to have a definition of cultural evolution we could all agree on. But, given the diverse backgrounds of researchers currently working on the topic it is unlikely to be agreed on in the near future. I guess, we still have not understand this phenomenon enough to put it into words. This is similar to life, the species concept, or fitness, which are concepts happily used by many researchers but all of which are lacking a universal definition.

Further questions regarded:

How important is high-fidelity imitation/copying for cumulative culture?

Where lies the origin of cumulative culture?

What constitutes primate and non-primate innovation, how do they emerge, and how are they dispersed (if at all)?

Which types of social learning (imitation, emulation, teaching) do we find in other species and how important are they for cumulative culture?

These are all fascinating questions and each seems to have the potential to fill an entire life of research. Let us use our social learning and cooperative abilities and tackle them together.

(Please fell free to use the comment section in case you have got more questions which you feel are important for our research field.)