Tilia Ergonomics – Generate taxa codes and groups

Many palaeoecologists and other scientists working with stratigraphical data use Tilia as a software for production and visualization of quality time-series graph. This software from Eric C. Grimm needs you to present your data in a particular way, so as to work properly. There is nothing difficult here, just something to pay attention about.

Here is an example of an Excel template for Tilia, ready to fill in with (your) data:

An Excel template for Tilia An Excel template for Tilia In this template, the user reports the taxa names in column B, starting from row 11, towards down. The sample analyzed (i.e. depths) are gathered starting from column H, towards right; the counts are gathered starting from cell H11, towards right and down. The resulting Excel file would be the exact pendant of the Tilia spreadsheet file. But first, there are a few more data to add to the Excel file.

Eric C. Grimm strongly recommends to add a unique code for each taxa, so as to prevent mistakes when Tilia will perform calculations. Also, Tilia will need each taxa to be assigned to a particular group. In long dataset, this is a tedious task. Here I explain a simple R code to generate such data.

  1. Import the Excel file in R, using the xlsx package

library(xlsx) TiliaReadyDataset

  1. Save a vector containing the taxa names

TaxaSequence Note the specific arguments: the TaxaSequence object is made out of the column 2 of the total dataset (i.e. the object TiliaReadyDataset previously generated from the Excel file), and starting from the row 11, as explained above.

  1. Generate a vector of taxa codes (i.e. unique abbreviated names)

AbbTaxa Note that the abbreviated names (i.e. the taxa codes for Tilia) will be unique only if the TaxaSequence has no duplicates. See the help for the abbreviate() function in R:

?abbreviate To check if your TaxaSequence contains only unique values, you can use this code:

if ( length(TaxaSequence[duplicated(TaxaSequence)]) > 0 ) warning( paste("Duplicate taxa in TaxaSequence! Check your data file for ", TaxaSequence[duplicated(TaxaSequence)], ".", sep = "") )

  1. Import a reference list of potential taxa names and their corresponding code

Here comes something to be careful about. This step requires access to an additional file, which should be regarded as a long-term reference, locally stored on your system and regularly kept up-to-date. It is a simple two-columns Excel file, gathering all the potential taxa you encountered so far and their corresponding group. Below is an example of this reference file:

An example of a reference file for taxa groups An example of a reference file for taxa groups This file is imported in R like this:

GroupTable

  1. Generate a vector of group codes

A simple loop can generate a vector of the groups matching exactly the TaxaSequence created before (i.e. from the data):

GroupSequence Note that, if a taxa name is not present in your reference list, R will warn you that “NA” have been introduced in the GroupSequence. If this happens, check your taxa names for typing mistakes, and check if all of them are listed in your reference file.

  1. Save the table
write.table(
    # table structure
    cbind(  as.vector(AbbTaxa),
        as.data.frame(TaxaSequence),
        "",
        "",
        "",
        "",# 4 empty columns, allows faster Copy+Paste in Tilia
        GroupSequence
        ), 
    # name of the file
    "... Tilia Taxa Codes.csv",
    # additionnal settings
    row.names=FALSE,
    col.names=FALSE,
    dec=".",
    sep=","
    )

This will save a 7-columns CSV file in your R working directory. The first column gathers the unique taxa codes, the second the taxa names (identical to your original data), the next four columns are empty, and finally the last one gathers the taxa groups. These 7 columns can be copied and pasted in Tilia in one step in columns A to G, starting from row 11.

Posted by Benjamin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.