Dual Inlet Examples
2021-02-15
Introduction
Isoreader supports several dual inlet IRMS data formats. This vignette shows some of the functionality for dual inlet data files. For additional information on operations more generally (caching, combining read files, data export, etc.), please consult the operations vignette. For details on downstream data processing and visualization, see the isoprocessor package.
# load isoreader package
library(isoreader)
Reading files
Reading dual inlet files is as simple as passing one or multiple file or folder paths to the iso_read_dual_inlet()
function. If folders are provided, any files that have a recognized continuous flow file extensions within those folders will be processed (e.g. all .did
and .caf
). Here we read several files that are bundled with the package as examples (and whose paths can be retrieved using the iso_get_reader_example()
function).
# all available examples
iso_get_reader_examples() %>% knitr::kable()
continuous_flow_example.cf |
continuous flow |
Isodat |
Continuous Flow file format (older) |
continuous_flow_example.dxf |
continuous flow |
Isodat |
Continuous Flow file format (newer) |
continuous_flow_example.iarc |
continuous flow |
ionOS |
Continuous Flow data archive |
dual_inlet_example.caf |
dual inlet |
Isodat |
Dual Inlet file format (older) |
dual_inlet_example.did |
dual inlet |
Isodat |
Dual Inlet file format (newer) |
dual_inlet_nu_example.txt |
dual inlet |
Nu |
Dual Inlet file format |
background_scan_example.scn |
scan |
Isodat |
Scan file format |
full_scan_example.scn |
scan |
Isodat |
Scan file format |
peak_shape_scan_example.scn |
scan |
Isodat |
Scan file format |
time_scan_example.scn |
scan |
Isodat |
Scan file format |
# read dual inlet examples
di_files <-
iso_read_dual_inlet(
iso_get_reader_example("dual_inlet_example.did"),
iso_get_reader_example("dual_inlet_example.caf"),
iso_get_reader_example("dual_inlet_nu_example.txt"),
nu_masses = 49:44
)
#> Info: preparing to read 3 data files...
#> Info: reading file 'dual_inlet_example.did' with '.did' reader...
#> Info: reading file 'dual_inlet_example.caf' with '.caf' reader...
#> Info: reading file 'dual_inlet_nu_example.txt' with '.txt' reader...
#> Info: finished reading 3 files in 3.95 secs
File summary
The di_files
variable now contains a set of isoreader objects, one for each file. Take a look at what information was retrieved from the files using the iso_get_data_summary()
function.
di_files %>% iso_get_data_summary() %>% knitr::kable()
#> Info: aggregating data summary from 3 data file(s)
dual_inlet_example.did |
7 cycles, 6 ions (44,45,46,47,48,49) |
16 entries |
standards, resistors |
7 rows, 8 columns |
dual_inlet_example.did |
dual_inlet_example.caf |
8 cycles, 6 ions (44,45,46,47,48,49) |
22 entries |
standards, resistors |
8 rows, 9 columns |
dual_inlet_example.caf |
dual_inlet_nu_example.txt |
82 cycles, 6 ions (44,45,46,47,48,49) |
9 entries |
no method info |
no vendor data table |
dual_inlet_nu_example.txt |
Problems
In case there was any trouble with reading any of the files, the following functions provide an overview summary as well as details of all errors and warnings, respectively. The examples here contain no errors but if you run into any unexpected file read problems, please file a bug report in the isoreader issue tracker.
di_files %>% iso_get_problems_summary() %>% knitr::kable()
di_files %>% iso_get_problems() %>% knitr::kable()
Resistors
Additionally, some IRMS data files contain resistor information that are useful for downstream calculations (see e.g. section on signal conversion later in this vignette):
di_files %>% iso_get_resistors() %>% knitr::kable()
#> Info: aggregating resistors info from 3 data file(s)
dual_inlet_example.did |
1 |
3.000000e+08 |
44 |
dual_inlet_example.did |
2 |
3.000000e+10 |
45 |
dual_inlet_example.did |
3 |
1.000000e+11 |
46 |
dual_inlet_example.did |
4 |
1.000000e+12 |
47 |
dual_inlet_example.did |
5 |
5.000000e+11 |
48 |
dual_inlet_example.did |
6 |
1.000000e+12 |
49 |
dual_inlet_example.caf |
1 |
2.970297e+08 |
44 |
dual_inlet_example.caf |
2 |
1.500000e+10 |
45 |
dual_inlet_example.caf |
3 |
5.000000e+10 |
46 |
dual_inlet_example.caf |
4 |
5.000000e+11 |
47 |
dual_inlet_example.caf |
5 |
9.900990e+09 |
48 |
dual_inlet_example.caf |
6 |
5.000000e+11 |
49 |
Reference values
As well as isotopic reference values for the different gases:
# reference delta values without ratio values
di_files %>% iso_get_standards(file_id:reference) %>% knitr::kable()
#> Info: aggregating standards info from 3 data file(s)
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 13C/12C |
-3.56 |
VPDB |
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 18O/16O |
25.01 |
VSMOW |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 13C/12C |
-2.82 |
VPDB |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 18O/16O |
-4.67 |
VPDB |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 47CO2/44CO2 |
0.00 |
None |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 48CO2/44CO2 |
0.00 |
None |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 49CO2/44CO2 |
0.00 |
None |
# reference values with ratios
di_files %>% iso_get_standards() %>% knitr::kable()
#> Info: aggregating standards info from 3 data file(s)
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 13C/12C |
-3.56 |
VPDB |
C |
R 13C/12C |
0.0111802 |
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 13C/12C |
-3.56 |
VPDB |
O |
R 18O/16O |
0.0020672 |
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 13C/12C |
-3.56 |
VPDB |
O |
R 17O/16O |
0.0003860 |
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 18O/16O |
25.01 |
VSMOW |
H |
R 2H/1H |
0.0001558 |
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 18O/16O |
25.01 |
VSMOW |
O |
R 17O/16O |
0.0003799 |
dual_inlet_example.did |
Caltech-1960C |
CO2 |
d 18O/16O |
25.01 |
VSMOW |
O |
R 18O/16O |
0.0020052 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 13C/12C |
-2.82 |
VPDB |
C |
R 13C/12C |
0.0111802 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 13C/12C |
-2.82 |
VPDB |
O |
R 18O/16O |
0.0020672 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 13C/12C |
-2.82 |
VPDB |
O |
R 17O/16O |
0.0003860 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 18O/16O |
-4.67 |
VPDB |
C |
R 13C/12C |
0.0111802 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 18O/16O |
-4.67 |
VPDB |
O |
R 18O/16O |
0.0020672 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 18O/16O |
-4.67 |
VPDB |
O |
R 17O/16O |
0.0003860 |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 47CO2/44CO2 |
0.00 |
None |
NA |
NA |
NA |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 48CO2/44CO2 |
0.00 |
None |
NA |
NA |
NA |
dual_inlet_example.caf |
CO2clump tank |
CO2 |
d 49CO2/44CO2 |
0.00 |
None |
NA |
NA |
NA |
Raw Data
The raw data read from the IRMS files can be retrieved similarly using the iso_get_raw_data()
function. Most data aggregation functions also allow for inclusion of file information using the include_file_info
parameter, which functions identically to the select
parameter of the iso_get_file_info
function discussed earlier.
# get raw data with default selections (all raw data, no additional file info)
di_files %>% iso_get_raw_data() %>% head(n=10) %>% knitr::kable()
#> Info: aggregating raw data from 3 data file(s)
dual_inlet_example.did |
standard |
0 |
15946.42 |
19001.94 |
21960.62 |
2513.280 |
29.78742 |
-181.2712 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
1 |
15941.14 |
18995.66 |
21954.19 |
2512.345 |
29.80048 |
-180.9752 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
2 |
15933.54 |
18986.64 |
21943.58 |
2511.280 |
29.81818 |
-180.7748 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
3 |
15916.58 |
18966.34 |
21919.97 |
2508.497 |
29.78074 |
-180.4583 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
4 |
15901.62 |
18948.60 |
21899.17 |
2506.104 |
29.76304 |
-180.2311 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
5 |
15896.00 |
18941.97 |
21891.49 |
2505.600 |
29.75818 |
-180.3095 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
6 |
15884.63 |
18928.51 |
21876.19 |
2503.555 |
29.72923 |
-180.2013 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
standard |
7 |
15875.89 |
18918.12 |
21863.96 |
2502.444 |
29.69513 |
-180.0340 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
sample |
1 |
15955.18 |
19122.71 |
22237.99 |
2559.245 |
31.09436 |
-181.2460 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
dual_inlet_example.did |
sample |
2 |
15945.64 |
19111.16 |
22224.65 |
2557.857 |
31.09153 |
-180.9976 |
NA |
NA |
NA |
NA |
NA |
NA |
NA |
# get specific raw data and add some file information
di_files %>%
iso_get_raw_data(
# select just time and the two ions
select = c(type, cycle, v44.mV, v45.mV),
# include the Analysis number fron the file info and rename it to 'run'
include_file_info = c(run = Analysis)
) %>%
# look at first few records only
head(n=10) %>% knitr::kable()
#> Info: aggregating raw data from 3 data file(s), selecting data columns 'c(type, cycle, v44.mV, v45.mV)', including file info 'c(run = Analysis)'
dual_inlet_example.did |
49077 |
standard |
0 |
15946.42 |
19001.94 |
dual_inlet_example.did |
49077 |
standard |
1 |
15941.14 |
18995.66 |
dual_inlet_example.did |
49077 |
standard |
2 |
15933.54 |
18986.64 |
dual_inlet_example.did |
49077 |
standard |
3 |
15916.58 |
18966.34 |
dual_inlet_example.did |
49077 |
standard |
4 |
15901.62 |
18948.60 |
dual_inlet_example.did |
49077 |
standard |
5 |
15896.00 |
18941.97 |
dual_inlet_example.did |
49077 |
standard |
6 |
15884.63 |
18928.51 |
dual_inlet_example.did |
49077 |
standard |
7 |
15875.89 |
18918.12 |
dual_inlet_example.did |
49077 |
sample |
1 |
15955.18 |
19122.71 |
dual_inlet_example.did |
49077 |
sample |
2 |
15945.64 |
19111.16 |
Data Processing
The isoreader package is intended to make raw stable isotope data easily accessible. However, as with most analytical data, there is significant downstream processing required to turn these raw signal intensities into properly referenced isotopic measurement. This and similar functionality as well as data visualization is part of the isoprocessor package which takes isotopic data through the various corrections in a transparent, efficient and reproducible manner.
That said, most vendor software also performs some of these calculations and it can be useful to be able to compare new data reduction procedures against those implemented in the vendor software. For this purpose, isoreader retrieves vendor computed data tables whenever possible, as illustrated below.
Vendor Data Table
As with most data retrieval functions, the iso_get_vendor_data_table()
function also allows specific column selection (by default, all columns are selected) and easy addition of file information via the include_file_info
parameter (by default, none is included).
# entire vendor data table
di_files %>% iso_get_vendor_data_table() %>% knitr::kable()
#> Info: aggregating vendor data table from 3 data file(s)
dual_inlet_example.did |
1 |
3.3287770 |
37.330647 |
2.1929917 |
37.366456 |
6.202321 |
1.108056 |
0.2075809 |
NA |
NA |
NA |
dual_inlet_example.did |
2 |
3.3209553 |
37.311799 |
2.1852948 |
37.347605 |
6.192886 |
1.108048 |
0.2075772 |
NA |
NA |
NA |
dual_inlet_example.did |
3 |
3.3263384 |
37.317514 |
2.1908570 |
37.353314 |
6.195743 |
1.108054 |
0.2075783 |
NA |
NA |
NA |
dual_inlet_example.did |
4 |
3.3200304 |
37.317207 |
2.1841057 |
37.353021 |
6.195597 |
1.108047 |
0.2075782 |
NA |
NA |
NA |
dual_inlet_example.did |
5 |
3.3187408 |
37.329768 |
2.1822644 |
37.365600 |
6.201893 |
1.108045 |
0.2075808 |
NA |
NA |
NA |
dual_inlet_example.did |
6 |
3.3177548 |
37.322849 |
2.1814601 |
37.358675 |
6.198427 |
1.108044 |
0.2075794 |
NA |
NA |
NA |
dual_inlet_example.did |
7 |
3.3217518 |
37.318368 |
2.1859087 |
37.354180 |
6.196176 |
1.108049 |
0.2075785 |
NA |
NA |
NA |
dual_inlet_example.caf |
1 |
0.7000753 |
7.543204 |
0.4669423 |
7.550236 |
6.316518 |
NA |
NA |
15.65910 |
22.50135 |
-58.12863 |
dual_inlet_example.caf |
2 |
0.6846506 |
7.518991 |
0.4512997 |
7.526031 |
6.304043 |
NA |
NA |
15.62094 |
22.59733 |
-54.25812 |
dual_inlet_example.caf |
3 |
0.6827013 |
7.503826 |
0.4497784 |
7.510853 |
6.296221 |
NA |
NA |
15.56356 |
22.81077 |
-52.21288 |
dual_inlet_example.caf |
4 |
0.6940694 |
7.513421 |
0.4616176 |
7.520432 |
6.301158 |
NA |
NA |
15.64200 |
23.18259 |
-66.43734 |
dual_inlet_example.caf |
5 |
0.6748151 |
7.499821 |
0.4414657 |
7.506862 |
6.294164 |
NA |
NA |
15.56706 |
22.81533 |
-67.80591 |
dual_inlet_example.caf |
6 |
0.6836593 |
7.492892 |
0.4512181 |
7.499905 |
6.290578 |
NA |
NA |
15.65654 |
23.33585 |
-66.66771 |
dual_inlet_example.caf |
7 |
0.6960376 |
7.491672 |
0.4645483 |
7.498654 |
6.289934 |
NA |
NA |
15.56031 |
23.89354 |
-42.32076 |
dual_inlet_example.caf |
8 |
0.6929899 |
7.499328 |
0.4609894 |
7.506326 |
6.293888 |
NA |
NA |
15.45959 |
24.43994 |
-48.39355 |
# get specific parts and add some file information
di_files %>%
iso_get_vendor_data_table(
# select cycle and all carbon columns
select = c(cycle, matches("C")),
# include the Identifier 1 fron the file info and rename it to 'id'
include_file_info = c(id = `Identifier 1`)
) %>% knitr::kable()
#> Info: aggregating vendor data table from 3 data file(s), including file info 'c(id = `Identifier 1`)'
dual_inlet_example.did |
CIT Carrara |
1 |
3.3287770 |
37.330647 |
2.1929917 |
1.108056 |
NA |
NA |
NA |
dual_inlet_example.did |
CIT Carrara |
2 |
3.3209553 |
37.311799 |
2.1852948 |
1.108048 |
NA |
NA |
NA |
dual_inlet_example.did |
CIT Carrara |
3 |
3.3263384 |
37.317514 |
2.1908570 |
1.108054 |
NA |
NA |
NA |
dual_inlet_example.did |
CIT Carrara |
4 |
3.3200304 |
37.317207 |
2.1841057 |
1.108047 |
NA |
NA |
NA |
dual_inlet_example.did |
CIT Carrara |
5 |
3.3187408 |
37.329768 |
2.1822644 |
1.108045 |
NA |
NA |
NA |
dual_inlet_example.did |
CIT Carrara |
6 |
3.3177548 |
37.322849 |
2.1814601 |
1.108044 |
NA |
NA |
NA |
dual_inlet_example.did |
CIT Carrara |
7 |
3.3217518 |
37.318368 |
2.1859087 |
1.108049 |
NA |
NA |
NA |
dual_inlet_example.caf |
2H6 |
1 |
0.7000753 |
7.543204 |
0.4669423 |
NA |
15.65910 |
22.50135 |
-58.12863 |
dual_inlet_example.caf |
2H6 |
2 |
0.6846506 |
7.518991 |
0.4512997 |
NA |
15.62094 |
22.59733 |
-54.25812 |
dual_inlet_example.caf |
2H6 |
3 |
0.6827013 |
7.503826 |
0.4497784 |
NA |
15.56356 |
22.81077 |
-52.21288 |
dual_inlet_example.caf |
2H6 |
4 |
0.6940694 |
7.513421 |
0.4616176 |
NA |
15.64200 |
23.18259 |
-66.43734 |
dual_inlet_example.caf |
2H6 |
5 |
0.6748151 |
7.499821 |
0.4414657 |
NA |
15.56706 |
22.81533 |
-67.80591 |
dual_inlet_example.caf |
2H6 |
6 |
0.6836593 |
7.492892 |
0.4512181 |
NA |
15.65654 |
23.33585 |
-66.66771 |
dual_inlet_example.caf |
2H6 |
7 |
0.6960376 |
7.491672 |
0.4645483 |
NA |
15.56031 |
23.89354 |
-42.32076 |
dual_inlet_example.caf |
2H6 |
8 |
0.6929899 |
7.499328 |
0.4609894 |
NA |
15.45959 |
24.43994 |
-48.39355 |
For expert users: retrieving all data
For users familiar with the nested data frames from the tidyverse (particularly tidyr’s nest
and unnest
), there is an easy way to retrieve all data from the iso file objects in a single nested data frame:
all_data <- di_files %>% iso_get_all_data()
#> Info: aggregating all data from 3 data file(s)
# not printed out because this data frame is very big
Saving collections
Saving entire collections of isofiles for retrieval at a later point is easily done using the iso_save
function which stores collections or individual isoreader file objects in the efficient R data storage format .rds
(if not specified, the extension .di.rds
will be automatically appended). These saved collections can be conveniently read back using the same iso_read_dual_inlet
command used for raw data files.
# export to R data archive
di_files %>% iso_save("di_files_export.di.rds")
#> Info: exporting data from 3 iso_files into R Data Storage 'di_files_export.di.rds'
# read back the exported R data storage
iso_read_dual_inlet("di_files_export.di.rds")
#> Info: preparing to read 1 data files...
#> Info: reading file 'di_files_export.di.rds' with '.di.rds' reader...
#> Info: loaded 3 data files from R Data Storage
#> Info: finished reading 1 files in 0.12 secs
#> Data from 3 dual inlet iso files:
#> # A tibble: 3 x 6
#> file_id raw_data file_info method_info vendor_data_tab… file_path
#> <chr> <glue> <chr> <chr> <chr> <chr>
#> 1 dual_inlet… 7 cycles, 6 … 16 entries standards, … 7 rows, 8 colum… dual_inlet…
#> 2 dual_inlet… 8 cycles, 6 … 22 entries standards, … 8 rows, 9 colum… dual_inlet…
#> 3 dual_inlet… 82 cycles, 6… 9 entries no method i… no vendor data … dual_inlet…
Data Export
At the moment, isoreader supports export of all data to Excel and the Feather file format (a Python/R cross-over format). Note that both export methods have similar syntax and append the appropriate file extension for each type of export file (.di.xlsx
and .di.feather
, respectively).
# export to excel
di_files %>% iso_export_to_excel("di_files_export")
#> Info: exporting data from 3 iso_files into Excel 'di_files_export.di.xlsx'
#> Info: aggregating all data from 3 data file(s)
# data sheets available in the exported data file:
readxl::excel_sheets("di_files_export.di.xlsx")
#> [1] "file info" "raw data" "standards"
#> [4] "resistors" "vendor data table" "problems"
# export to feather
di_files %>% iso_export_to_feather("di_files_export")
#> Info: exporting data from 3 iso_files into .di.feather files at 'di_files_export'
#> Info: aggregating all data from 3 data file(s)
# exported feather files
list.files(pattern = ".di.feather")
#> [1] "di_files_export_file_info.di.feather"
#> [2] "di_files_export_problems.di.feather"
#> [3] "di_files_export_raw_data.di.feather"
#> [4] "di_files_export_resistors.di.feather"
#> [5] "di_files_export_standards.di.feather"
#> [6] "di_files_export_vendor_data_table.di.feather"