install.packages('devtools', depen=T)
library(devtools)
install_github('sebkopf/isotopia')
install_github('sebkopf/isoread')
Here, we read a simple isodat file that is provided as an example in the module. isoread takes all the information directly from the binary, which makes it easy to record each step of what is happening with the data.
library(isoread)
file <- isoread(
system.file("extdata", "6520__F8-5_5uL_isodat2.cf", package="isoread"),
type = "H_CSIA")
## Reading file /Library/Frameworks/R.framework/Versions/3.2/Resources/library/isoread/extdata/6520__F8-5_5uL_isodat2.cf
The file variable now contains an isoread object with all the information from the binary file and we can take a look at the chromatographic data in the object, here we look at the first 10 lines (using the k-table or kable command from the knitr package for table output):
library(knitr)
## Warning: package 'knitr' was built under R version 3.2.5
kable(head(file$get_mass_data(), n = 10))
time | mass2 | mass3 | time.s | time.min | mass2.offset | mass3.offset |
---|---|---|---|---|---|---|
0.209 | 194.5682 | 60.01971 | 0.209 | 0.0034833 | 394.5682 | 60.01971 |
0.418 | 194.5418 | 60.04760 | 0.418 | 0.0069667 | 394.5418 | 60.04760 |
0.627 | 194.5365 | 60.21315 | 0.627 | 0.0104500 | 394.5365 | 60.21315 |
0.836 | 194.5630 | 59.91891 | 0.836 | 0.0139333 | 394.5630 | 59.91891 |
1.045 | 194.5735 | 59.71668 | 1.045 | 0.0174167 | 394.5735 | 59.71668 |
1.254 | 194.5444 | 59.69523 | 1.254 | 0.0209000 | 394.5444 | 59.69523 |
1.463 | 194.5153 | 59.58589 | 1.463 | 0.0243833 | 394.5153 | 59.58589 |
1.672 | 194.5233 | 59.72385 | 1.672 | 0.0278667 | 394.5233 | 59.72385 |
1.881 | 194.5096 | 59.73885 | 1.881 | 0.0313500 | 394.5096 | 59.73885 |
2.090 | 194.5206 | 59.73885 | 2.090 | 0.0348333 | 394.5206 | 59.73885 |
For convenience, isoread also implements several plotting functions based on standard plot
as well as the ggplot
module so we can have a look at the whole chromatograms:
file$make_ggplot()
## Need help getting started? Try the cookbook for R:
## http://www.cookbook-r.com/Graphs/
Notice that isoread plots all masses and ratios by default and labels the peaks with their peak numbers (reference peaks are marked with *). The plotting functions are of course a lot more flexible and we can use isoread functionality to plot just a specific time window of the mass trace chromatogram, and switch the time units to minutes instead of seconds as illustrated below:
file$plot_masses(tlim = c(12.3, 12.6), tunits = "min")
Since isoread has access to the original raw binary data file, it can extract other parameters stored with the data, here shown with the example of the H3factor registered as the most current during the analysis:
kable(file$get_info("H3factor"))
Property | Value | |
---|---|---|
11 | H3factor | 2.79431047797221 |
The table of peaks detected by isodat during the analysis or added by the user later on are also directly accessible. The complete set of 29 columns is available through isoread, here a small subset of key components:
kable(
subset(file$get_data_table(), select = c("Peak Nr.", "Status",
"Ref. Peak", "Component", "Rt", "Start", "End", "Ampl. 2",
"d 2H/1H")))
Peak Nr. | Status | Ref. Peak | Component | Rt | Start | End | Ampl. 2 | d 2H/1H |
---|---|---|---|---|---|---|---|---|
1 | Auto | FALSE | - | 286.3 | 283.4 | 293.0 | 3978 | -160.879 |
2 | Auto | FALSE | - | 321.2 | 318.3 | 327.9 | 3979 | -160.397 |
3 | Auto | FALSE | - | 612.0 | 606.3 | 634.9 | 4993 | -154.208 |
4 | Auto | TRUE | - | 671.5 | 666.1 | 699.3 | 4906 | -151.900 |
5 | Auto | FALSE | - | 747.8 | 740.7 | 768.1 | 5227 | -218.117 |
6 | Auto | FALSE | - | 809.5 | 801.5 | 829.3 | 5044 | -210.429 |
7 | Auto | TRUE | - | 860.7 | 855.4 | 889.5 | 4129 | -151.900 |
8 | Auto | FALSE | - | 936.5 | 927.8 | 961.6 | 4534 | -155.523 |
9 | Auto | FALSE | - | 1002.2 | 993.4 | 1023.1 | 4354 | -198.128 |
10 | Auto | TRUE | - | 1055.0 | 1049.0 | 1086.0 | 4070 | -151.900 |
11 | Auto | FALSE | - | 1135.9 | 1126.7 | 1154.3 | 4377 | -189.484 |
12 | Auto | FALSE | - | 1201.3 | 1191.9 | 1223.1 | 4384 | -207.897 |
13 | Auto | TRUE | - | 1249.4 | 1244.2 | 1283.1 | 4160 | -151.900 |
14 | Auto | FALSE | - | 1333.6 | 1324.4 | 1356.2 | 4316 | -168.142 |
15 | Auto | FALSE | - | 1395.3 | 1386.3 | 1416.8 | 3706 | -193.293 |
16 | Auto | TRUE | - | 1459.4 | 1453.6 | 1490.2 | 4183 | -151.900 |
17 | Auto | FALSE | - | 1608.7 | 1600.9 | 1636.5 | 4303 | -154.332 |
18 | Auto | FALSE | - | 1739.7 | 1736.4 | 1746.2 | 3974 | -160.124 |
19 | Auto | FALSE | - | 1779.4 | 1776.7 | 1786.1 | 3972 | -160.550 |
Currently, none of the Components in this peak table are identified, but we can generate a mapping file that identifies which component comes out approximately at which retention time. A simple mapping table, which identifies peaks by retention time, could look like this (here only for 2 components):
map <- data.frame(Rt = c(940, 1135), Component = c("C16:0 FAME", "C18:0 FAME"), stringsAsFactors=F)
kable(map)
Rt | Component |
---|---|
940 | C16:0 FAME |
1135 | C18:0 FAME |
Typically, one would maintain this information for example in an excel file and load it directly from there. The map can then be applied to the peak table by isoread, which makes the identified peaks accessible by name:
file$map_peaks(map)
kable(
file$get_peak_by_name(c("C16:0 FAME", "C18:0 FAME"),
select = c("Peak Nr.", "Component", "Rt", "Start", "End", "Ampl. 2", "d 2H/1H")))
Peak Nr. | Component | Rt | Start | End | Ampl. 2 | d 2H/1H | |
---|---|---|---|---|---|---|---|
8 | 8 | C16:0 FAME | 936.5 | 927.8 | 961.6 | 4534 | -155.523 |
11 | 11 | C18:0 FAME | 1135.9 | 1126.7 | 1154.3 | 4377 | -189.484 |
Lastly, the delta value reported in column d 2H/1H is automatically loaded as a delta value object using isotopia and can be used accordingly with all the functionality from isotopia. For a simple example, conversion to a fractional abundance (and switch to percent notation):
library(isotopia)
d <- file$get_peak_by_name(c("C16:0 FAME", "C18:0 FAME"), select = "d 2H/1H")
print(d)
## An isotope value object of type 'Delta value': d2H [permil] vs. VSMOW
## [1] -155.523 -189.484
print(switch_notation(to_abundance(d), "percent"))
## Successfully found a registered standard to convert delta value: VSMOW R 2H/1H: 0.0001558
## An isotope value object of type 'Abundance value': F 2H [%]
## [1] 0.01315220 0.01262335
Having this information available of course opens various possibilities for the implementation of useful features that are specific to the data. For example, an overview of how consistent the reference peaks in a run were is helpful for determining if one of them might be offset by an overlapping analyte or contaminant. This is implement in isoread by the plot_refs() functionality:
file$plot_refs()