elementr: An R package for reducing elemental data from LA‐ICPMS analysis of biological calcified structures
Abstract
- Elemental analysis of biological calcified structures (e.g. fish otoliths, mollusc shelves, coral skeletons or fish and shark bones) provides invaluable information regarding ecological processes for many aquatic species. Despite this importance, the reduction of the raw data obtained through Laser‐ablation Inductively Coupled Plasma Mass Spectrometry (LA‐ICPMS) (i.e. the conversion of the machine raw signal into elemental concentrations) remains a challenge as the tools developed so far for carrying out this task have important limitations for aquatic ecologists.
- Here, we introduce the elementr R‐package which provides a handy, reliable and transparent way to reduce elemental data acquired from spot or transect LA‐ICPMS analysis of biological calcified structures. This free and open‐source software, implemented based on state‐of‐the‐art literature, handles data from both standards and samples, allowing fast and simultaneous calculations of concentration for any chemical element, correction for potential machine drift, and realignment and averaging for sample replicates when needed.
- The major attributes of elementr are: (i) its user‐friendly graphical interface which provides widgets to set all the reduction settings (i.e. no programming skills are required to run it), (ii) its reactivity whereby the software continuously observes any setting change made by the user, re‐calculates and displays all updated results, allowing therefore users to visually check the validity of their settings and to tune them if needed and (iii) an object oriented underlying that facilitates subsequent handling of LA‐ICPMS data in R.
- Despite the elementr design being most suited to the needs of aquatic ecologists, its use could be broadened to other research fields (i.e. geology, material engineering) due to its flexibility. Moreover, the open‐source approach used for programming this software allows its expansion in order to refine calculation procedures or to add new functionalities.
1 INTRODUCTION
Over the last decade, elemental microchemistry of biological calcified structures (e.g. fish otoliths, fish and shark bones, mollusc shelves or coral skeletons) has become one of the top reference methods for studying aquatic organism life cycles and past environmental conditions (Morrongiello, Thresher, & Smith, 2012). Regarding fish ecology, this approach has already proved its worth for identifying key lifetime habitats (Vasconcelos et al., 2008, 2010), discriminating populations and stocks (Campana, Chouinard, Hanson, Fréchet, & Brattey, 2000; Edmonds, Caputi, & Morita, 1991; Kerr & Campana, 2013), tracking individual migration (Jessop, Shiao, Iizuka, & Tzeng, 2002; Mercier, Mouillot, Bruguier, Vigliola, & Darnaude, 2012) or assessing habitat connectivity (Gillanders, 2005; Reis‐Santos et al., 2012). Moreover, numerous studies demonstrated that the elemental composition of mollusc shelfs or coral skeletons can be used as reliable archives for detecting water pollution (Price & Pearce, 1997; Runnalls & Coleman, 2003) and more generally for reconstructing environmental shifts in aquatic ecosystems through time (e.g. sea surface temperature— Sinclair, Kinsley, & McCulloch, 1998; salinity—Corrège, 2006). In most of these cases, the elemental composition of calcified structures is measured through a mass spectrometer coupled with a laser ablation system (LA‐ICPMS for Laser Ablation Inductively Coupled Plasma Mass Spectrometry) as this technique combines reliability, laser precision, timeliness, high sensitivity and minimal sample destruction (Durrant, 1999; Liu, Hu, Li, & Gao, 2013; Thomas, 2004). In this LA‐ICPMS technique, a laser beam is focused on the sample surface and generates fine particles by ablation (Figure 1). These particles are then transported by a gas stream into the ICPMS to be separated by their mass‐to‐charge ratio and counted by a detector translating the number of ions striking its surface into an electrical signal whose intensity (in counts per second, cps) represents the elemental composition of the analysed material (Thomas, 2004) (Figure 1). Finally, the signal is returned as a spreadsheet to user for interpretation (Figure 1). In an ecological context, two modes are classically used (even if more types of analysis could be performed): a spot mode (one or more single points analysed, e.g. Longmore et al., 2010; in order to investigate precisely a given part of the individual life) or a transect mode (one continuous segment or broken line analysed, e.g. Tabouret et al., 2011, to study elemental concentrations deposited throughout an individual's life).

In order to interpret the signals recorded by the mass spectrometer, final outputs from LA‐ICPMS must be reduced, that is, the machine signal has to be converted from counts per second (cps) to elemental concentration relatively to a standard chemical element (ppm/ppm or Mol/Mol). This data transformation involves numerous steps (e.g. standard and sample reduction, machine drift correction) already detailed in the literature (Elsdon & Gillanders, 2002; Milton & Chenery, 2001). In addition, as ecologists usually analyse several replicates per sample, the common reduction procedure is most of the time followed by an additional important step dedicated to realign (i.e. a temporal translation to match replicate curves) and average data from different replicates. This multiplicity of calculations makes data reduction generally quite tedious, especially for large datasets as those obtained with the LA‐ICPMS technique. Finally, the complexity of the calculations pipeline may result in a significant source of variations and thus of uncertainty between studies carried out in different laboratories. Consequently, the reduction of elemental data from LA‐ICPMS analysis of calcified structures remains a challenging task for ecologists and should be standardized and automatized as far as possible.
Until recently, only two solutions were given to ecologists for this. The first was to use existing commercially licensed softwares, such as glitter® (van Achterbergh, Ryan, & Griffin, 1999) or iolite® (Paton, Hellstrom, Paul, Woodhead, & Hergt, 2011). This solution offers many advantages (e.g. ready‐made, standardized procedures) but also presents strong constraints, as these softwares do not allow users to upgrade their functionalities nor to reach details about calculation procedures. Because purchasing these softwares or their environment (e.g. matlab for the FatHom Toolbox, Jones, 2015) is also quite expensive, ecologists traditionally used spreadsheet softwares (e.g. libreoffice or ms excel®) to conduct data reduction manually. However, this approach is generally highly time‐consuming, repetitive and error‐prone because of the multiplicity of the steps required. Recently, a third alternative appeared with the release of free softwares designed for LA‐ICPMS data reduction, e.g. laicpms (Rittner & Müller, 2012) or upb‐age (Solari & Tanner, 2011), both R packages, that are unfortunately not maintained anymore, Lamtrace (Jackson, 2008) or the Java written Analysis Management System (AMS) software (Mutchler, Fedele, & Bodnar, 2008). However, the schemes usually conducted in these softwares (e.g. for AMS microthermometry) do not fully match the needs or the classical procedures used by ecologists. To our knowledge, no completely free and open‐source environment for reducing elemental data from LA‐ICPMS analysis currently fits optimally with ecologists’ requirements (e.g. handling both spot and transect data or conducting transect realignment). Here, we propose to fill in this gap by making available a new open‐source software, elementr (here presented in its version 1.3.2), developed in the R language (R Core Team 2017), based on an Object‐Oriented set of classes (R6 classes, Chang, 2016) and providing a reactive graphic user‐friendly interface (GUI) for facilitating and standardizing the reduction of elemental data from LA‐ICPMS analysis of calcified structures.
2 FRAMEWORK REQUIRED FOR REDUCING ELEMENTAL DATA THROUGH elementr
The data reduction process performed by elementr is based on a session framework to ensure efficient data reduction while allowing both to correct potential machine drift with time and to average the ICPMS signal among several replicates. To define the term of “session framework” properly, it is important to consider the methodology for LA‐ICPMS analysis (Figure 1). First, prepared samples are attached on a glass slide which is then placed in the ablating cell for analysis. Besides these samples, calibration materials (thereafter called “standards” e.g. NIST 612, see for instance Arai, Hirata, & Takagi, 2007) are also attached and analysed regularly between samples in order to (1) calibrate the conversion between cps and ppm and (2) check for machine drift. Optionally, reference materials (e.g. MACS‐3) could also be added to this session in order to assess the correctness of the obtained concentrations (see for instance Warburton, Reid, Stirling, & Closs, 2016). A session of analysis therefore comprises all the data collected from the standard and samples on a single glass slide. This design could be extended to the collection of data from the analysis of several slides that comprise calibration material and samples.
When the user launches elementr and uploads the session to be reduced, elementr creates an elementR_project object (R6 class type object, Chang, 2016) which contains all the data belonging to the running session, this object being structured as the session itself (Appendix S1). The main benefit of this design is that users can easily and quickly save the current session and all associated results by exporting this single elementR_project object at any stage of the procedure. Moreover, they can re‐open the saved session for finalizing, checking or editing results by re‐loading this single object within the graphical elementr user interface or directly in the R environment to perform further statistical analyses on the reduced data (e.g. using classification methods such as random forest or discriminant analyses, Mercier et al., 2012; Tournois et al., 2013; Vasconcelos et al., 2008).
3 PROCEDURE FOR DATA REDUCTION PERFORMED BY elementr
3.1 General data reduction procedure
The successive steps followed by elementr to reduce a session of elemental data are commonly used methodologies for geochemical data reduction (Halter, Pettke, Heinrich, & Rothen‐Rutishauser, 2002; Heinrich et al., 2003; Jones, 2015; Longerich, Jackson, & Günther, 1996; Rittner & Müller, 2012; Solari & Tanner, 2011) while meeting the specific needs of aquatic ecologists (Elsdon & Gillanders, 2002; Fowler, Campana, Thorrold, & Jones, 1995; Milton & Chenery, 2001; Thorrold, Jones, & Campana, 1997). This method adopted for reducing a session therefore comprises first a reduction of the data from the standard, a verification and correction of the possible LA‐ICPMS drift with time (and consequently mass bias—Cottle, Kylander‐Clark, & Vrijmoed, 2012), then a reduction of the data from the samples and optionally a realignment (only if sample is analysed in transect mode) and averaging of the sample replicates if available (Longerich et al., 1996; Rittner & Müller, 2012). The procedure for data reduction presented here for otolith samples can be applied to any type of bio‐mineral and easily extended to any type of hard material.
Irrespective of the type of material being analysed (samples or standards), the classical procedure for data reduction starts with a correction for the baseline noise specific to the machine, which consists in evaluating the signal recorded by the LA‐ICPMS when the laser is not operating (i.e. when no ablated material is sent to the spectrometer), and to take this permanent baseline noise, hereafter called “background,” into account in the calculation of samples’ elemental concentrations. To this aim, elementr computes both the background average value (BAV) and the limit of detection (LOD = n × SD of the BAV, n being an integer usually 3 or 6 Longerich et al., 1996) of the machine. The next step consists of subtracting the BAV from the signal (i.e. the signal recorded during laser ablation, hereafter called “plateau”) (Figure 1a) and comparing the obtained values to the LOD, the values <LOD being generally discarded (Figure 1c). The ratio of each element relative to the internal standard is then calculated (generally calcium for calcified structures) (Figure 1d). The next step of the data reduction consists of detecting possible outliers generally through three types of outliers detection (Jones, 2015): via the standard deviation criterion (the points that fall beyond 2 standard deviations from the mean of the computed values, that is, after having substracted the BAV to the plateau, comparing these values to the LOD and having done the ratio to the internal standard), Grubb's test or Rosner's test.
3.2 Procedure for session reduction performed by elementr
3.2.1 Initial settings and data verification (step 1)
This first step aims to set all the settings of the analysed session (e.g. upload data—one file per standard or sample analysis—and indicate the sequential order of each standards and samples within the session, that is, ordinal numbers. The user can also choose to replace this order by the time of analysis in minutes elapsed since the beginning of the ICPMS session). When the user has provided the required information, the data intended to be reduced are automatically scanned to check possible structural errors in the elementr object created (e.g. any problem in file format or the presence of non‐numeric characters in the elemental data). If no error is found, elementr automatically guides the user through the second step of the procedure (i.e. standard data reduction, Figure 1). This step is also the opportunity for users to decide which type of settings they want to apply to the whole session (e.g. LOD = n × SD of the BAV, n being determined by the user, the value to replace in case of outliers or values < LOD).
3.2.2 Standard data reduction (step 2)


Although this automatic delineation of the background and plateau is generally time saving, the users have the choice to change these limits if they do not agree with this automatic detection.
When these limits are delineated, all further steps of the data reduction (Figure 1b–f) are automatically performed by elementr and the processed data are then displayed for user validation (see 4 in Figure 2): the user can visually check the relevance of the background and plateau limits and eventually change these settings until optimal results are obtained. The outlier detection is performed either by the SD function (for the standard deviation criterion), by grubbs.test (from the “outliers” R‐package—Komsta, 2011) or by rosnerTest (from “EnvStats” R‐package—Millard, 2013).
Once satisfied, the user can validate these settings, and move to the reduction of the data from the next standard. In any case, the final results and all corresponding settings can be modified at will throughout the whole procedure by going back on these steps and modifying former choices. Once the limits are validated and the calculations performed for all standards, the last step consists in averaging the values for each standard in order to check the machine drift.
3.2.3 Machine drift verification and correction (step 3)
The version 1.3.2 of elementr includes two possible procedures for machine drift correction depending on the machine drift tendency: a linear regression (default setting) or a nearest neighbour approach (if the drift is non‐linear, i.e. if R2 is below a customizable threshold) among standard average values (Cottle et al., 2012; Jones, 2015).
In the linear regression method, the machine drift is characterized for each element as a function of the standards sequential order in the analysis (R function lm of the stats R‐package), the significance of the slope of the regression being then displayed. Furthermore, the normality, homoscedasticity and independence of the residuals are also checked with respectively shapiro.test, hmctest and dwtest functions of the base and lmtest R‐packages (Hothorn, Zeileis, Farebrother, Cummins, & Mitchell, 2015), p.value of the slope is displayed (lm and summary functions, see Appendix S1, Case 1).
If the user considers that the machine drift is non linear (i.e. if the R2 is under a customizable threshold), elementr automatically changes the machine drift correction from a linear to a nearest neighbor approach. This method, adapted from Jones (2015), calculates for each sample a theoretical standard value based on a linear regression from the two closest standard analysis (see Appendix S2, Case 2).
In any case, users have the choice to correct or not the temporal drift of the LA‐ICPMS if they consider it as relevant. If so and irrespective the method of correction used, a theoretical standard value will be then calculated for each sample (see the detail of the calculation on Appendix S2).
3.2.4 Sample data reduction (step 4)

3.2.5 Realignment of transect sample replicates and averaging

A final table (R data.frame object) summarizing the results for each sample, obtained with (in transect mode) or without (in spot mode) realignment, the optional overlap corrected data and all associated realignment settings can be saved (and deleted) by users, when desired. In any case, all the proceeded spot/transect data are still preserved and exported even after their realignment and/or averaging.
4 elementr ASSETS, NOVELTIES AND FUTURE IMPROVEMENTS
To date, several softwares other than elementr have been developed for reducing LA‐ICPMS elemental data. However, most of them (e.g. ComPbCorr, Andersen, 2008; Upb.age, Solari & Tanner, 2011; LamDate, Košler, Forst, & Sláma, 2008) are dedicated to geologic purposes and do not fulfil the specific needs of ecologists, being highly specialized in other types of analysis. Among the remaining ones (Table 1), several require purchasing a commercial license for using them (e.g. Iolite, Paton et al., 2011; glitter®, van Achterbergh et al., 1999) or for running their environment (e.g. Matlab and a Windows or mac license for the Fathom toolbox, Jones, 2015). This is not the case for elementr, which is open‐source and that can be run under operating system such as Linux (in addition to Windows or Mac). Therefore, elementr should not only be accessible to the majority of its potential users but also, in return, benefits from their comments and potential developments.
| elementr | Upb.age | laicpms | Iolite | Glitter | FatHom Toolbox | AMS | Lametrace | |
|---|---|---|---|---|---|---|---|---|
| References | ‐ | Solari and Tanner (2011) | Rittner and Müller (2012 | Paton et al. (2011 | van Achterbergh et al. 1999 | Jones (2015 | Mutchler et al. (2008) | Jackson (2008 |
| Language/environment | R | R | R | Igor Pro | IDL | Matlab | Java | LOTUS 123 |
| Free | Yes | Yes | Yes | No | No | Partlyaa
FatHome Toolbox is free but its environment Matlab is not.
|
Yes | No |
| Open source | Yes | Yes | Yes | Partly | No | Yes | Yes | No (?) |
| Maintained | Yes | No (?) | No (?) | Yes | Yes | Yes | Yes | No (?) |
| Operating systems | Windows Mac OS XLinux | Windows | Windows Mac OS XLinux | Windows Mac OS X | Windows Mac OS X Solaris | Windows Mac OS X Linux Solaris | Windows Mac OS XLinux | Windows |
| Command lines | No | Yes | Yes | No | No | Partly | No | No (?) |
| Elements targeted | All | U, Pb, Th | All | All | All | All | All | U, Pb, Th (more?) |
| Spot analysis | Yes | Yes | (?) | Yes | Yes | Yes | Yes | Yes |
| Transect analysis | Yes | (?) | Yes | Yes | No | Yes (?) | Yes (?) | (?) |
| Element mapping | No | No | Yes | Yes | No | No (?) | No | No |
| Live behaviour | Yes | No | No | No | Yes | No | No (?) | (?) |
| Machine drift correction | Yes | Yes | No | Yes | Yes | Yes | Yes | Yes |
| Mass bias correction | Yes | Yes | Yes (?) | Yes | Yes | No | Yes | Yes (?) |
| Down‐hole fractionation | No | Yes | No | Yes | Yes | No | No (?) | No |
| Outlier detection | (1) Standard deviation criterion correction, (2) Grubbs and (3) Rosner test | Standard deviation criterion correction | Running median | Standard deviation criterion correction | Yesbb We did not found any information about the outliers detection procedures. Adapted from Rittner and Müller (2012). |
(1) Standard deviation criterion correction, (2) Grubbs and (3) Rosner Test | (?) | (?) |
| Overlap reduction (Transect mode only) | Yes | No | No | No | No | No (?) | No (?) | No (?) |
| Time‐lag in element reading (Transect mode only) | No | No | No | No (?) | No (?) | No (?) | No (?) | No (?) |
| Parameter customization | Partly | Partly | Yes | Yes | Yes | Partly | Yes | (?) |
| Sample replicates handling and sequence realignment | Yes | No | No | No | No | No | No | No (?) |
- a FatHome Toolbox is free but its environment Matlab is not.
- b We did not found any information about the outliers detection procedures. Adapted from Rittner and Müller (2012).
The open‐source feature of elementr also allows flexibility (user can customize the code) and total transparency of elementr functionalities. The only two completely free and open‐source softwares available so far to deal with elemental data reduction were AMS (java software Mutchler et al. 2008) and laicpms (R‐package Rittner & Müller, 2012), the last one being to our knowledge no longer maintained nor available. The lack of maintenance and improvement is an important point for the future of elementr. However, as the R language is increasingly used by ecologists, we believe that these points will not be an issue for this software. Moreover, although elementr takes in account the main steps of a state‐of‐art data reduction procedure, new functionalities present in commercially licensed softwares such as glitter® (van Achterbergh et al., 1999) or iolite® (Paton et al., 2011) could be implemented in the future. For instance, one of important enhancement would be to develop functionalities that take in account a correction of the down‐hole fractionation. Finally, we think that further considerations about potential methods to correct analysis autocorrelation and time‐lag between element concentration calculations of any chemical element, in transect mode are still missing and their implementation would be an important added value for elementr data reduction procedure.
Another important asset of the elementr software is its simplicity of use, as the user does not need any programming skills to install or run the function performing data reduction properly. Indeed, its user‐friendly graphical interface (GUI) allows any graphics or instructions to be displayed clearly and any settings to be configured easily (Figure 2). Moreover, its object‐oriented programming allows to export easily the whole project in a single file, providing therefore both (1) a good portability of the final data and (2) a traceability of the data reduction procedure since raw, intermediate and final data and all data reduction settings are saved in one file. These two characteristics allows researchers to share both final data and the whole data reduction procedure with only single file (the output files of elementr, an.Rdata file). We therefore believe the structure of our R6 classes represents a good starting point to provide a standard structure for storing and sharing reduced data, allowing future synthesis and meta‐analyses and paving the way for more reproducible and “open” science in the field.
Perhaps the most important novelty of elementr compared to its competitors is its reactivity, meaning that the software continuously observes any change made by the user (e.g. blank or plateau limits, realignment settings), re‐calculates and displays the updated processed data (and all intermediate data). This allows users to continually visualize the consequences of their actions on the final results and thus to finely tune all settings of the reduction procedure. Finally and in addition to deal with both spot and transect data reduction, the second major contribution of elementr to the data reduction procedure is that it provides a realignment tool for transect analysis replicates. To our knowledge, elementr is thus the first software dedicated to LA‐ICPMS data reduction providing both reactivity and possibility for realignment of transect replicates.
ACKNOWLEDGEMENTS
Authors are grateful to the three reviewers for their great contribution to improve both this manuscript and the elementr software. Moreover, we would like to thank all “beta‐testers” users and more particularly to Dr. Maylis Labonne, Dr. Jennifer Tournois, Dr. Michel Thomann and Ms. Cecile Petit. Moreover, we also thank the whole shiny community for their help (https://groups.google.com/forum/#!forum/shiny-discuss) and especially the Shiny developers who brought a great product support during the development of the elementr R‐package.
AUTHORS′ CONTRIBUTIONS
A.D., F.F. and J.P. were in charged to define the calculation steps performed by elementr (i.e. reviewing the up‐to‐date literature dedicated to the reduction of microchemical data). C.S. and F.G. wrote the code. C.S., F.F. and A.‐R.C. were responsible for the final testing and calculation validation. C.S. wrote the first draft and all authors contributed to revisions.
DATA ACCESSIBILITY
This manuscript does not include any data. However, user can find data usable as example in the elementr package (https://cran.r-project.org/web/packages/elementR/index.html or https://github.com/charlottesirot/elementR).
REFERENCES
Citing Literature
Number of times cited according to CrossRef: 4
- Pamela Toledo, Edwin J Niklitschek, Audrey M Darnaude, Félix P Leiva, Chris Harrod, Sergio Lillo, Vilma Ojeda, Sebastián Klarian, Blanca E Molina-Burgos, Patricio Gálvez, Cristian B Canales-Aguirre, The trophic ecology of partial migration: insights from Merluccius australis off NW Patagonia, ICES Journal of Marine Science, 10.1093/icesjms/fsaa065, (2020).
- Ngan T. Tran, Maylis Labonne, Huy D. Hoang, Jacques Panfili, Changes in environmental salinity during the life of Pangasius krempfi in the Mekong Delta (Vietnam) estimated from otolith Sr : Ca ratios, Marine and Freshwater Research, 10.1071/MF18269, 70, 12, (1734), (2019).
- Malte Willmes, Katherine M. Ransom, Levi S. Lewis, Christian T. Denney, Justin J. G. Glessner, James A. Hobbs, IsoFishR: An application for reproducible data reduction and analysis of strontium isotope ratios (87Sr/86Sr) obtained via laser-ablation MC-ICP-MS, PLOS ONE, 10.1371/journal.pone.0204519, 13, 9, (e0204519), (2018).
- Pamela Toledo, Audrey M Darnaude, Edwin J Niklitschek, Vilma Ojeda, Raphaël Voué, Félix P Leiva, Maylis Labonne, Cristian B Canales-Aguirre, Partial migration and early size of southern hake Merluccius australis : a journey between estuarine and oceanic habitats off Northwest Patagonia , ICES Journal of Marine Science, 10.1093/icesjms/fsy170, (2018).




