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