The package pbratios provides a set of R functions to efficiently extract, process and visually inspect Pb isotope ratio data obtained from csv reports generated by the Perkin Elmer ELAN ICP-MS instrument. This package is currently under development and can be installed directly from Github by

devtools::install_github("andreabz/pbratios", build_vignettes = TRUE)

Processing Pb isotope ratio data {#sec1}

Getting raw intensities and ratios by extract_data {#sec1.1}

The function extract_data is used to gather the sample names and the intensities measured for each nuclide and present them in a tidy table. The function is compatible with two different types of report: short and long.

file.short <- system.file("extdata", "sednya_2015.csv", package = "pbratios")
file.long <- system.file("extdata", "spmnya_2012.csv", package = "pbratios")

When using the function extract_data, the first argument is the path for the csv file whereas the argument report need to be equal to "short" or "long" depending on the type of csv file generated by the instrument.

Standard reference material used for standard bracketing must be labelled as "SRM" and quality control (QC) samples as "CRM". The function renames these samples as “SRM981” and “CRM482”, respectively and appends a progressive integer at the end of the label.

The output of the function is a table where each row represents a replicate and columns gather the intensities for each measured nuclides. Raw $^{20x}\mathrm{Pb}/^{20y}\mathrm{Pb}$ ratios are also displayed, where $x, y = 6, 7, 8$. These Pb isotope ratio still need to be filtered for possible outliers, summarised and corrected for instrumental mass bias.

A typical output is given by

library(pbratios)
spmnya <- extract_data(file.long, report = "long")
head(spmnya)

Removing outliers and summarising ratios by calc_ratios {#sec1.2}

Pb isotope ratio values lying outside the $\mathrm{median} \pm 2.5\, \mathrm{mad}$ range are considered outliers and automatically removed by the function calc_ratios. Only about $5\,\%$ of the data is removed. The $\mathrm{median} \pm 2.5\, \mathrm{mad}$ criterion for the outliers detection is to be preferred to the $\mathrm{mean} \pm 2\, \mathrm{sd}$ because $\mathrm{median}$ and $\mathrm{mad}$ are less influenced by extreme values than $\mathrm{mean}$ and $\mathrm{sd}$ [@leys_detecting_2013].

A table with the number of outliers removed for each sample is printed on screen.

The data set is then summarised keeping only average ratios and standard errors for each sample.

spmnya.ratios <- calc_ratios(spmnya)
head(spmnya.ratios)
head(spmnya.ratios)

These ratios still need to be corrected for mass bias before being interpreted.

Standard bracketing for mass bias correction using corr_mbf {#sec1.3}

Isotope ratios can be corrected for instrumental mass bias using several approaches. The function corr_mbf implements the standard bracketing only.

To use the corr_mbf function, standards for bracketing must be labelled as "SRM". These are diluted solutions of NIST SRM 981 with certified Pb isotope ratios. Pb isotope ratios measured in SRM solutions immediately before and after a set of samples (usually 3, 4) are divided for their certified values and averaged. The result is a mass bias factor ($k$) that has to be applied to raw Pb isotope ratios ($r$) measured in samples analysed within the two bracketing standards. The corrected Pb isotope ratios ($R$) are then easily calculated using the following equation: $$ R = r/k $$

The function subset the data set to start and end with bracketing standards, any samples before or after the first or last SRM is ignored.

corr_mbf can be used directly on the output of calc_ratios and returns a table containing the corrected $^{20x}\mathrm{Pb}/^{20y}\mathrm{Pb}$ ratios with their extended uncertainties ($U = k\, u\mathrm{,}\ k = 2$).

spmnya.corr <- corr_mbf(spmnya.ratios)
knitr::kable(head(spmnya.corr), digits = 4, pad = 0)

The three functions presented so far can be combined conveniently using the pipe operator %>% provided by the dplyr package:

file.long <- system.file("extdata", "spmnya_2012.csv", package = "pbratios")
spmnya <- file.long %>% 
          extract_data(report = "long") %>% 
          calc_ratios %>% 
          corr_mbf
head(spmnya)

The function all_ratios does exactly the same but require less typing.

file.long <- system.file("extdata", "spmnya_2012.csv", package = "pbratios")
spmnya <- all_ratios(file.long, report = "long", print = TRUE)

Displaying and saving Pb ratio data {#sec2}

Inspecting possbile outliers using check_outliers {#sec2.1}

The function calc_ratio automatically remove possible outliers and print on screen the number of outliers for each sample. However, it can be useful to have more control on the possible outliers detected for each sample.

The function check_outliers can be useful to visually inspect samples with a suspicious number of outliers.

file.long %>%
  extract_data(report = "long") %>%
  check_outliers("II.B.50m")

The first argument is the output of the function extract_data and the second argument a string matching the name of the sample to be inspected.

The function produces a plot for each Pb isotope ratio: values for each replicate are represented as dots, whereas $\mathrm{median}$, $\mathrm{median} \pm 2\, \mathrm{mad}$ and $\mathrm{median} \pm 3\, \mathrm{mad}$ are represented by solid green, yellow and red lines, respectively. Possible outliers lying outside the $\mathrm{median} \pm 2.5\, \mathrm{mad}$ are represented with the * symbol.

Additionally, raw intensities and Pb isotope ratios for the inspected sample are printed on screen.

Checking the method performances with qc_check {#sec2.2}

QC samples typically should have a matrix similar to the samples to be analysed and known values of the measurand. They are usually analysed between samples in order to asses and control the performances of the analytical method.

The qc_check function subset the data set produced by the function corr_mbf so that it contains only "CRM" samples. Pb isotope ratios for these samples are then summarised graphically by plotting points or box-plots (for $n > 10$) compared with the reference values. Data are stored in an R object and permil errors are calculated assuming the CRM to be BCR CRM 482 and using the Pb isotope ratio reference values provided by @cloquet_atmospheric_2006.

qc.short <- file.short %>%
  all_ratios(report = "short", print = TRUE) %>%
  qc_check

The new R object is a list containing Pb isotope ratios for each QC sample (first table), some descriptive statistics for both ratios (second table) and permil relative errors (third table).

knitr::kable(qc.short$data, digits = 4)
knitr::kable(qc.short$summary, digits = 4)
knitr::kable(qc.short$error, digits = 2)

Three isotope plots with isoplot_generic and isoplot.pm10 {#sec2.3}

Three isotope plots are useful tools for the interpretation of variations in Pb isotope ratios.

The function isoplot.generic can plot Pb isotope ratio values in a three-isotope space defined by the user. Additionally, data points can be differentiated by colours and a regression line can be calculated and added to the plot.

The function isoplot.pm10 is specifically designed for PM10 data collected in the Northern Hemisphere and allows the comparison of measured Pb isotope ratios with literature values (additional information are provided in section 3.2). Data points can be differentiated providing a factor but the three-isotope space is defined with $x = \phantom{}^{208}\mathrm{Pb}/^{206}\mathrm{Pb}$ and $y = \phantom{}^{207}\mathrm{Pb}/^{206}\mathrm{Pb}$.

data(pm10nya)

# remove QC samples
pm10.smp <- pm10nya[-grep("CRM", sample)]

# generate a factor year from sample names
year <- paste0("20", gsub("[[:alpha:]]+[0-9]{1,2}." , "", pm10.smp$sample))
year[grep("20-10", year)] <- "2010"
year <- as.factor(year)
year <- droplevels(year)
pm10.smp[, year := year]

isoplot_generic(pm10.smp, 
                x = "Pb208207", 
                y = "Pb206207", 
                factor = "year", 
                regression = TRUE,
                save = FALSE)

isoplot_pm10(pm10.smp, factor = "year", save = FALSE)

Using the data.table syntax, it is possible to filter the data to be plotted, for example considering only samples with small uncertainties.

isoplot_pm10(pm10.smp[Pb208206.U < 0.01], factor = "year", save = FALSE)

Both isoplot functions can save pdf, png and svg copies of the plot in the folder "output", when argument save = TRUE.

Saving data with save_table {#sec2.4}

This function is a shortcut for the function write.csv2 and it allows to save the data in a csv file in the "output" folder. File name is derived from the R object in the first argument of the function:

save_table(pm10.smp)

creates a file with the name "pm10smp.csv" in the "output" folder.

Dataset of Pb isotope ratios {#sec3}

Raw reports {#sec3.1}

The package pbratios includes two examples of csv reports generated by the instrument Perkin Elmer Elan ICP-MS: spmnya_2012.csv and sednya_2015.csv are in "long" and "short" format, respectively. They can be accessed by running the following code.

file.long  <- system.file("extdata", "spmnya_2012.csv", package = "pbratios")
file.short <- system.file("extdata", "sednya_2015.csv", package = "pbratios")

These data set contain raw Pb isotope ratios measured in marine suspended particulate matter and size-fractionated sediments in the marine coastal environment of the Kongsfjorden. Data were published in @bazzano_anthropogenic_2014 and @grotti_trace_2017.

Corrected Pb isotope ratios {#sec3.2}

The pm10nya data set contains Pb isotope ratio data measured in PM10 samples collected from 2010 to 2014 at Ny-Ålesund (Svalbard, Norwegian Arctic) and can be accessed running data(pm10nya). Pb isotope ratio values were published in @bazzano_long-range_2016.

The pm10nh data set contains Pb isotope ratio data measured by several research group in PM10 samples collected in industrialised region on the Northern Hemisphere. This data set can be accessed by data(pm10nh) and it is used internally by the function isoplot_pm10 to generate confidence ellipses for different geographical areas. Data were obtained from @zhu_lead_2010, @carignan_dispersal_2002, @bollhofer_isotopic_2001, @mukai_regional_2001 and @mukai_lead_2001.

References {-}



andreabz/pbratios documentation built on May 12, 2019, 2:42 a.m.