2.2 XRF Data

2.2.1 Processed Data

This is the data most commonly used in analysis and it can be quickly imported using itraxR::itrax_import(). Note that, like for the example data, it is possible to have more than one processed data file. Typically cores have at least two, one created at the time of the scan based on settings for a single point near the top of the sequence, and another from a holistic re-analysis of the sequence.

itrax_import("CD166_19_S1/CD166_19_S1/Results.txt", depth = 0) %>%
  glimpse()
## Rows: 1,281
## Columns: 43
## $ depth    <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18…
## $ MSE      <dbl> 1.41, 1.57, 1.55, 1.41, 1.41, 1.36, 1.52, 1.38, 1.58, 1.52, 1…
## $ cps      <dbl> 34525, 38370, 39796, 40022, 41973, 41268, 40977, 41104, 41408…
## $ validity <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…
## $ Al       <dbl> 76, 57, 74, 26, 53, 27, 72, 78, 69, 70, 61, 45, 41, 51, 90, 7…
## $ Si       <dbl> 275, 306, 330, 206, 233, 347, 337, 346, 403, 381, 301, 491, 5…
## $ P        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ S        <dbl> 10, 0, 32, 21, 37, 28, 59, 19, 44, 30, 0, 54, 48, 0, 28, 35, …
## $ Cl       <dbl> 1318, 1513, 1470, 1312, 1740, 1576, 1605, 1559, 1503, 1428, 1…
## $ Ar       <dbl> 604, 595, 506, 555, 591, 504, 584, 489, 597, 512, 547, 592, 6…
## $ K        <dbl> 2565, 2628, 2378, 2265, 2947, 3179, 3376, 3193, 3220, 2732, 2…
## $ Ca       <dbl> 112734, 144287, 162938, 153194, 135879, 132183, 134094, 13857…
## $ Sc       <dbl> 0, 14, 0, 0, 106, 14, 0, 46, 0, 0, 33, 0, 0, 0, 28, 22, 0, 0,…
## $ Ti       <dbl> 1661, 1806, 2121, 2031, 1826, 1923, 2059, 2443, 2701, 2442, 2…
## $ V        <dbl> 51, 88, 22, 75, 89, 107, 0, 71, 23, 91, 55, 66, 64, 62, 143, …
## $ Cr       <dbl> 258, 326, 301, 306, 440, 401, 440, 407, 449, 336, 329, 443, 4…
## $ Mn       <dbl> 508, 559, 483, 485, 738, 792, 799, 868, 794, 647, 680, 813, 8…
## $ Fe       <dbl> 35168, 36494, 35952, 35512, 44303, 45283, 45694, 46506, 47859…
## $ Ni       <dbl> 123, 104, 134, 144, 166, 151, 125, 157, 180, 147, 132, 160, 1…
## $ Cu       <dbl> 277, 230, 150, 206, 276, 250, 217, 178, 191, 197, 189, 187, 2…
## $ Zn       <dbl> 205, 268, 123, 239, 240, 294, 284, 238, 230, 211, 210, 226, 1…
## $ Ga       <dbl> 4, 48, 0, 0, 0, 40, 8, 22, 26, 0, 47, 57, 0, 125, 0, 0, 0, 39…
## $ Ge       <dbl> 0, 40, 43, 0, 0, 48, 115, 100, 80, 164, 110, 132, 98, 90, 68,…
## $ Br       <dbl> 491, 605, 550, 609, 659, 709, 583, 582, 635, 545, 678, 535, 4…
## $ Rb       <dbl> 329, 76, 295, 313, 304, 318, 337, 323, 223, 306, 168, 252, 24…
## $ Sr       <dbl> 8306, 9181, 9644, 9940, 10287, 9917, 9931, 9897, 9209, 9869, …
## $ Y        <dbl> 15, 140, 119, 107, 180, 106, 52, 77, 112, 144, 237, 151, 188,…
## $ Zr       <dbl> 255, 322, 280, 475, 160, 312, 319, 319, 552, 484, 373, 634, 7…
## $ Pd       <dbl> 31, 78, 75, 66, 31, 72, 31, 54, 58, 70, 55, 81, 43, 6, 42, 79…
## $ Cd       <dbl> 13, 34, 55, 24, 34, 28, 56, 62, 96, 79, 41, 84, 64, 43, 75, 5…
## $ I        <dbl> 38, 48, 80, 67, 23, 58, 30, 53, 93, 43, 36, 126, 58, 85, 28, …
## $ Cs       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Ba       <dbl> 63, 48, 25, 60, 132, 93, 172, 108, 108, 22, 74, 123, 82, 67, …
## $ Nd       <dbl> 17, 67, 44, 75, 42, 97, 92, 68, 56, 59, 41, 50, 73, 56, 78, 4…
## $ Sm       <dbl> 43, 46, 39, 64, 36, 12, 24, 69, 68, 17, 47, 59, 37, 45, 28, 4…
## $ Yb       <dbl> 144, 282, 158, 218, 163, 184, 248, 166, 188, 169, 247, 216, 1…
## $ Ta       <dbl> 789, 776, 703, 794, 919, 852, 926, 840, 847, 790, 736, 805, 6…
## $ W        <dbl> 1992, 2019, 2016, 2160, 2344, 2336, 2243, 2267, 2185, 2203, 2…
## $ Pb       <dbl> 77, 0, 13, 152, 54, 54, 75, 111, 78, 0, 92, 22, 0, 81, 19, 71…
## $ Bi       <dbl> 72, 136, 199, 134, 157, 182, 151, 185, 116, 164, 141, 135, 16…
## $ `Mo inc` <dbl> 26323, 26778, 26550, 28310, 31356, 30631, 29040, 29104, 27932…
## $ `Mo coh` <dbl> 8799, 9117, 9303, 9886, 10140, 9968, 9973, 9701, 9751, 9639, …
## $ position <dbl> 32.54, 33.54, 34.54, 35.54, 36.54, 37.54, 38.54, 39.54, 40.54…

2.2.2 Joining XRF Data

Often a core (sometimes referred to as a drive) is comprised of a sequence of individual sections, which may or may not be overlapping. Often we will want to integrate them into a continuous dataset for analytical purposes. When joining cores that do not overlap, this process is trivial — the data might simply appended in order of depth, and a new column is added with the identity of the original core section.

Where overlapping cores are present, there can be multiple measurements at a single depth (on different cores). In these cases not only will the individual measurements need to be re-ordered by depth, but an additional variable should be created that can be used in combination or alone to uniquely identify each measurement. The code below does this by creating an additional variable called label, with the name of the original core given in the named list.

mylist <- list(core1 = core1, core2 = core2)
df <- lapply(names(mylist), function(i) within(mylist[[i]], {label <- i})) %>% 
  bind_rows() %>% 
  arrange(depth)

This process can be simplified using itraxR::itrax_join(), for example:

# import the core sections
CD166_19_S1 <- itrax_import("CD166_19_S1/CD166_19_S1/Results.txt", depth_top = 0)
CD166_19_S2 <- itrax_import("CD166_19_S2/CD166_19_S2/Results.txt", depth_top = max(CD166_19_S1$depth))
CD166_19_S3 <- itrax_import("CD166_19_S3/CD166_19_S3/Results.txt", depth_top = max(CD166_19_S2$depth))
#join them together
CD166_19 <- itrax_join(list(S1 = CD166_19_S1, S2 = CD166_19_S2, S3 = CD166_19_S3))
rm(CD166_19_S1, CD166_19_S2, CD166_19_S3)
glimpse(CD166_19)
## Rows: 4,206
## Columns: 44
## $ depth    <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18…
## $ MSE      <dbl> 1.41, 1.57, 1.55, 1.41, 1.41, 1.36, 1.52, 1.38, 1.58, 1.52, 1…
## $ cps      <dbl> 34525, 38370, 39796, 40022, 41973, 41268, 40977, 41104, 41408…
## $ validity <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…
## $ Al       <dbl> 76, 57, 74, 26, 53, 27, 72, 78, 69, 70, 61, 45, 41, 51, 90, 7…
## $ Si       <dbl> 275, 306, 330, 206, 233, 347, 337, 346, 403, 381, 301, 491, 5…
## $ P        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ S        <dbl> 10, 0, 32, 21, 37, 28, 59, 19, 44, 30, 0, 54, 48, 0, 28, 35, …
## $ Cl       <dbl> 1318, 1513, 1470, 1312, 1740, 1576, 1605, 1559, 1503, 1428, 1…
## $ Ar       <dbl> 604, 595, 506, 555, 591, 504, 584, 489, 597, 512, 547, 592, 6…
## $ K        <dbl> 2565, 2628, 2378, 2265, 2947, 3179, 3376, 3193, 3220, 2732, 2…
## $ Ca       <dbl> 112734, 144287, 162938, 153194, 135879, 132183, 134094, 13857…
## $ Sc       <dbl> 0, 14, 0, 0, 106, 14, 0, 46, 0, 0, 33, 0, 0, 0, 28, 22, 0, 0,…
## $ Ti       <dbl> 1661, 1806, 2121, 2031, 1826, 1923, 2059, 2443, 2701, 2442, 2…
## $ V        <dbl> 51, 88, 22, 75, 89, 107, 0, 71, 23, 91, 55, 66, 64, 62, 143, …
## $ Cr       <dbl> 258, 326, 301, 306, 440, 401, 440, 407, 449, 336, 329, 443, 4…
## $ Mn       <dbl> 508, 559, 483, 485, 738, 792, 799, 868, 794, 647, 680, 813, 8…
## $ Fe       <dbl> 35168, 36494, 35952, 35512, 44303, 45283, 45694, 46506, 47859…
## $ Ni       <dbl> 123, 104, 134, 144, 166, 151, 125, 157, 180, 147, 132, 160, 1…
## $ Cu       <dbl> 277, 230, 150, 206, 276, 250, 217, 178, 191, 197, 189, 187, 2…
## $ Zn       <dbl> 205, 268, 123, 239, 240, 294, 284, 238, 230, 211, 210, 226, 1…
## $ Ga       <dbl> 4, 48, 0, 0, 0, 40, 8, 22, 26, 0, 47, 57, 0, 125, 0, 0, 0, 39…
## $ Ge       <dbl> 0, 40, 43, 0, 0, 48, 115, 100, 80, 164, 110, 132, 98, 90, 68,…
## $ Br       <dbl> 491, 605, 550, 609, 659, 709, 583, 582, 635, 545, 678, 535, 4…
## $ Rb       <dbl> 329, 76, 295, 313, 304, 318, 337, 323, 223, 306, 168, 252, 24…
## $ Sr       <dbl> 8306, 9181, 9644, 9940, 10287, 9917, 9931, 9897, 9209, 9869, …
## $ Y        <dbl> 15, 140, 119, 107, 180, 106, 52, 77, 112, 144, 237, 151, 188,…
## $ Zr       <dbl> 255, 322, 280, 475, 160, 312, 319, 319, 552, 484, 373, 634, 7…
## $ Pd       <dbl> 31, 78, 75, 66, 31, 72, 31, 54, 58, 70, 55, 81, 43, 6, 42, 79…
## $ Cd       <dbl> 13, 34, 55, 24, 34, 28, 56, 62, 96, 79, 41, 84, 64, 43, 75, 5…
## $ I        <dbl> 38, 48, 80, 67, 23, 58, 30, 53, 93, 43, 36, 126, 58, 85, 28, …
## $ Cs       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
## $ Ba       <dbl> 63, 48, 25, 60, 132, 93, 172, 108, 108, 22, 74, 123, 82, 67, …
## $ Nd       <dbl> 17, 67, 44, 75, 42, 97, 92, 68, 56, 59, 41, 50, 73, 56, 78, 4…
## $ Sm       <dbl> 43, 46, 39, 64, 36, 12, 24, 69, 68, 17, 47, 59, 37, 45, 28, 4…
## $ Yb       <dbl> 144, 282, 158, 218, 163, 184, 248, 166, 188, 169, 247, 216, 1…
## $ Ta       <dbl> 789, 776, 703, 794, 919, 852, 926, 840, 847, 790, 736, 805, 6…
## $ W        <dbl> 1992, 2019, 2016, 2160, 2344, 2336, 2243, 2267, 2185, 2203, 2…
## $ Pb       <dbl> 77, 0, 13, 152, 54, 54, 75, 111, 78, 0, 92, 22, 0, 81, 19, 71…
## $ Bi       <dbl> 72, 136, 199, 134, 157, 182, 151, 185, 116, 164, 141, 135, 16…
## $ `Mo inc` <dbl> 26323, 26778, 26550, 28310, 31356, 30631, 29040, 29104, 27932…
## $ `Mo coh` <dbl> 8799, 9117, 9303, 9886, 10140, 9968, 9973, 9701, 9751, 9639, …
## $ position <dbl> 32.54, 33.54, 34.54, 35.54, 36.54, 37.54, 38.54, 39.54, 40.54…
## $ label    <chr> "S1", "S1", "S1", "S1", "S1", "S1", "S1", "S1", "S1", "S1", "…

2.2.3 Raw Data

Sometimes it is useful to work with raw data rather than the calculated intensity data from the Q-Spec software. In this case, the raw data can be read directly from the individual files in the relevant directory. For individual measurements this is fairly trivial, although it must be considered that the data output is not calibrated to an energy and the data are in counts, not intensities. If the entire scan is read, some mechanism to iterate through the individual data files, adding them to a structured data object with relevant metadata (positions, for example) is required.